Uh oh!
There was an error while loading. Please reload this page.
Simplify PHPStan configuration - #3
Conversation
Signed-off-by: Viktor Szépe <viktor@szepe.net>
mscurtescu
commented
Nov 13, 2022
Thanks again @szepeviktor Merging here on |
Hi @szepeviktor , I finally merged your simplification into Running into an issue with phpstan that I cannot figure, as far as I can tell it properly pulls in the WordPress stubs but it seems to be confused about number of parameters: It's not complaining about all WordPress functions, only some. For now I am ignoring these specific errors so I can see the real issues being brought up. Any idea where is this coming from? Some extra libraries being imported unnecessarily? Thanks in advance Link to phpstan.neon.dist |
szepeviktor
commented
Apr 26, 2023
Investigating 🏃🏻♂️ |
szepeviktor
commented
Apr 26, 2023
On PHP 7.4 I get |
mscurtescu
commented
Apr 27, 2023
I was getting the errors when running locally, either: grunt shell:phpstanor directly: ./vendor/bin/phpstan analyze |
Try clearing composer cache, removing |
mscurtescu
commented
Apr 27, 2023
clearing the cache made no difference :-( |
I see. All I can see static analysis here on GitHub Actions recognizes those functions. |
mscurtescu
commented
Apr 27, 2023
Thanks, your help is much appreciated. Will try on a different computer with a clean state. |
I wish you to keep all of your computers clean all the time. |
mscurtescu
commented
May 2, 2023
On a clean computer it works as expected, thanks for your help. Yes, I have to figure what exactly is messing with phpstan. |
Really puzzling, still running into this error on one computer:
Since I am seeing the error in a brand new git clone the cause must reside outside of the git repo folder. Beyond phpstan and composer caches not sure what it can be. I also nuked the Also, using |
szepeviktor
commented
May 3, 2023
From the extension's configuration: https://github.com/szepeviktor/phpstan-wordpress/blob/master/extension.neon#L116 |
mscurtescu
commented
May 4, 2023
So that's under |
szepeviktor
commented
May 4, 2023
No, it is loaded from the extension. |
mscurtescu
commented
May 4, 2023
Maybe I am looking at it the wrong way and it's not a caching issue, what would generate an error like:
How does phpstan determine that admin_url requires 0 parameters? I checked the stub and the stub has the expected signature which is: functionadmin_url($path = '', $scheme = 'admin')
{
} |
szepeviktor
commented
May 4, 2023
Search for |
mscurtescu
commented
May 4, 2023
$ find . -name \*.php -exec grep -iHn "function admin_url" {} \;
./vendor/php-stubs/wordpress-stubs/wordpress-stubs.php:110462: functionadmin_url($path = '', $scheme = 'admin')
./wordpress/wp-includes/link-template.php:3522:function admin_url( $path = '', $scheme = 'admin' ) {
./wordpress/wp-admin/includes/noop.php:80:function admin_url() {}This is the suspicious one: I deleted the whole Questions:
|
mscurtescu
commented
May 4, 2023
Answering question 2, on the machine where phpstan worked, there is also the exact same |
|
szepeviktor
commented
May 4, 2023
Here is our perpetrator!!! Line 65 in e842276 |
mscurtescu
commented
May 4, 2023
The content of parameters:
level: 5inferPrivatePropertyTypeFromConstructor: truebootstrapFiles:
- tests/phpstan-bootstrap.phppaths:
- hello-login.php
- includes/ |
szepeviktor
commented
May 4, 2023
The cause is in the previous comment! |
mscurtescu
commented
May 4, 2023
So on some machines classes are loaded in some order and on other machines in a different one? |
szepeviktor
commented
May 4, 2023
That makes the difference. |
mscurtescu
commented
May 4, 2023
Yes, removing |
mscurtescu
commented
May 4, 2023
I don't think it's that, running |
mscurtescu
commented
May 4, 2023
adding: excludePaths:
- wordpress/also works, yay! |
mscurtescu
commented
May 4, 2023
köszönöm szépen |
All Submissions: