-
Notifications
You must be signed in to change notification settings - Fork 12
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
-externalpath and phpstan #3
Comments
In the above, I forgot: you need a phpstan extension that you can install by: cd phpstan You are in the directory that was created by Composer (you see a composer.json file, then you are in the right place). Type: composer require --dev phpstan/extension-installer Now, the problems: First of all some minor issues:
-save yes -savefilename autoload
Error Conflict:Class with name ... -> /xxx/bla/bla is already defined. File ./xxx/bla/bla... (where '/xxx*' is in -excludepath)
-excludepath '/xxx/,/yyy/,/zzz/' did not exclude the local directories ./xxx, ./yyy and ./zzz from scanning their classes. I had to use the wildcard * at the end. These are minor annoyances however. What bothers me is this: Trying to pass the resulting autoload.php to phpstan with /full/path/to/phpstan/phpstan analyse --level 0 -a autoload.php relative-path-to-some-php-file-to-check from inside /my/project/dir/, results in: In autoload.php line 194:
AutoLoadOne Error: No file found for class [PHPStan\ExtensionInstaller\GeneratedConfig] but PHPStan\ExtensionInstaller is included in autoload.php, in the xxxxxx__arrautoload array, with a relative path (relative to /my/project/dir/) 'PHPStan\ExtensionInstaller' => '../relative/path/to/phpstan/vendor/phpstan/extension-installer/src' The only way to make autoload.php load it, is to make $xxxxxx__arrautoload and $autoloadone__debug global: global $xxxxxx__arrautoload;
global $autoloadone__debug; which is nowhere mentioned and is something whose logic evades me. And then, when I do this and rerun /full/path/to/phpstan/phpstan analyse --level 0 -a autoload.php relative-path-to-some-php-file-to-check the PHPStan\ExtensionInstaller\GeneratedConfig class is obviously found and loaded(!), because now I get: In Resolver.php line 342:
Service 'php8Lexer' (type of PhpParser\Lexer\Emulative): AutoLoadOne Error: No file found for class [mixed]
In autoload.php line 193:
AutoLoadOne Error: No file found for class [mixed] which is too much for me. Can you help? Why can't autoload.php find php8Lexer? Is it because (as far as I can see) php8Lexer is inside phpstan's PHAR and the whole phpstan code is actually "hidden" inside the phpstan.phar file (which, possibly, cannot be traversed or handled by AutoLoadOne)??? |
:-| |
Any progress on this? |
Sorry, but I didn't have time to check it. :-P First, I decided to update to PHP 8.1 and drop the support of any version of PHP lower than PHP 7.1.5 ps: I also blame the pandemic 😷 |
Hello,
I feel very honored to be the first person to report something here. :-) I hope it will be of use and interest to you, as it is a tight knot I cannot untangle for me. So let's start:
I have a PHP code where I would like to do some static analysis with phpstan. For this, I did, in some working directory (it doesn't matter where):
This creates a phpstan directory inside your working directory, with all you need from phpstan.
Trying it a bit, I realized that it needs to know the paths to the class files, otherwise it cannot work (of course, since it is a static analyzer, it cannot run the code to execute the include's). This is described in phpstan/phpstan#5276 - so it is a good idea to read that too, so I don't have to repeat it here. My question there was:
Now you see: AutoLoadOne is this tool! :-) Thus I am trying to make it create an autoload.php for me that I can pass to phpstan with its -a option so that it can find my classes. For this I did:
This indeed creates an autoload.php file. But there are problems - that I will discuss in my next post, so stay tuned...
The text was updated successfully, but these errors were encountered: