Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#99 Fix PHP Stan error with DrupalAutoloader. #101

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"dealerdirect/phpcodesniffer-composer-installer": "*",
"mglaman/phpstan-drupal": "^1.1",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0"
"phpstan/phpstan-deprecation-rules": "^1.0",
"webflo/drupal-finder": "^1.3"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also adding requirement to version as the new class was added in 1.3 webflo/drupal-finder@1.2.2...1.3.0#diff-19dafcffb2094365c57f581c138aede2762e021675c6d8dab34c5dbb78508128R1

},
"autoload": {
"psr-4": {
Expand Down
5 changes: 2 additions & 3 deletions src/Drupal/DrupalAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Wunderio\GrumPHP\Drupal;

use Drupal\Core\DependencyInjection\ContainerNotInitializedException;
use DrupalFinder\DrupalFinder;
use DrupalFinder\DrupalFinderComposerRuntime;
use Drush\Drush;
use mglaman\PHPStanDrupal\Drupal\Extension;
use mglaman\PHPStanDrupal\Drupal\ExtensionDiscovery;
Expand Down Expand Up @@ -90,8 +90,7 @@ class DrupalAutoloader {
* Path to Drupal root.
*/
public function register(string $drupalRoot): void {
$finder = new DrupalFinder();
$finder->locateRoot($drupalRoot);
$finder = new DrupalFinderComposerRuntime();

$drupalRoot = $finder->getDrupalRoot();
$drupalVendorRoot = $finder->getVendorDir();
Expand Down
8 changes: 8 additions & 0 deletions src/Task/Psalm/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
Copy link
Collaborator Author

@hkirsman hkirsman May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to current PR. It's something I missed in the GrumpPHP 2.5 update - just a nasty error if psalm task is enabled in grumphp.yml:
image

Wunderio\GrumPHP\Task\Psalm\PsalmTask:
class: Wunderio\GrumPHP\Task\Psalm\PsalmTask
arguments:
- '@process_builder'
- '@formatter.raw_process'
tags:
- {name: grumphp.task, task: psalm}