larastan: Bug with autoloading on phpstan 0.12.22
- Larastan Version: 0.5.7
- PhpStan Version: 0.12.22
--levelused: max
Description
For latest version of phpstan (0.12.22)!
On analyze action:
ErrorException thrown in /builds/trv3/core/vendor/nunomaduro/larastan/src/ApplicationResolver.php on line 109 while loading bootstrap file /builds/trv3/core/vendor/phpstan/phpstan/../../nunomaduro/larastan/bootstrap.php: Undefined index: AI\Core\
Method ApplicationResolver@getProjectSearchDirs has wrong composer dir:
Expected: /home/vagrant/projects/core/vendor/composer
Actual: phar:///home/vagrant/projects/ai/core/vendor/phpstan/phpstan/phpstan/vendor/composer
phpstan code reference: https://github.com/phpstan/phpstan-src/commit/a1d3990c95b7a064a0451111153a6bef39f5d9a2
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 20 (4 by maintainers)
Commits related to this issue
- Probable fix for #559 — committed to ondrejmirtes/larastan by ondrejmirtes 4 years ago
- Probable fix for #559 — committed to ondrejmirtes/larastan by ondrejmirtes 4 years ago
- Revert "Probable fix for #559" This reverts commit d671511346aaefbeca9421a272b87355d76a4c02. — committed to ondrejmirtes/larastan by ondrejmirtes 4 years ago
- Merge pull request #561 from ondrejmirtes/fix-559 Probable fix for #559 — committed to larastan/larastan by nunomaduro 4 years ago
PHPStan 0.12.21 gives the same error for me, using 0.12.20 however works
Could you tell us about your project that uses Larastan but not Laravel?
Something along these lines will probably be sufficient: https://github.com/nunomaduro/larastan/pull/561
You don’t even need my suggestion with
%composerAutoloaderProjectPaths%because I noticed that you’re gettingcomposer.jsonfrom the current working directory anyway, so there’s no need for reflection to tell us the path to the Composer class loader…I am a little bit tired today, maybe someone on the community would like to jump in: https://twitter.com/enunomaduro/status/1257400309212680197.
In that class, we are trying to find all the service providers that the application uses. And register them to the Laravel app.
Looks like the issue is here: https://github.com/nunomaduro/larastan/blob/master/src/ApplicationResolver.php#L102-L104
When we request
ClassLoadervia reflection looks like it gets thevendor/phpstan/phpstan/phpstan/vendor/composer/ClassLoader.phpfile. Not thevendor/composer/ClassLoader.phpRight now I don’t have the time to look deeper. Just a pointer if anyone wants to attempt a fix.