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

Add PHPStan bleeding edge compatibility #98

Merged
merged 14 commits into from
May 2, 2022
Merged

Add PHPStan bleeding edge compatibility #98

merged 14 commits into from
May 2, 2022

Conversation

johnbillion
Copy link
Contributor

It looks like the hook docblock detection broke in PHPStan bleeding edge in 1.6 due to removal of the parent attribute: https://phpstan.org/blog/preprocessing-ast-for-custom-rules .

The getNullableNodeComment() method needs to be updated so it doesn't use the parent node attribute.

@szepeviktor
Copy link
Owner

szepeviktor commented Apr 26, 2022

Sounds like greek to me.

@johnbillion
Copy link
Contributor Author

Yeah the AST processing code is wild

@johnbillion johnbillion marked this pull request as ready for review April 26, 2022 21:46
@johnbillion
Copy link
Contributor Author

I think I know why the parsing on PHP < 7.4 isn't working, I'll take a look tomorrow.

@szepeviktor
Copy link
Owner

szepeviktor commented Apr 26, 2022

I think I know why the parsing on PHP < 7.4 isn't working

phpstan/phpstan 1.4.10

No 1.6 :(

https://github.com/phpstan/phpstan/blob/1.6.1/composer.json#L6

kép

@szepeviktor
Copy link
Owner

szepeviktor commented Apr 26, 2022

For the PHP error in PHPCS on PHP 8.1: WordPress/WordPress-Coding-Standards#2035 (comment) 👀
WordPress/WordPress-Coding-Standards@e9c4858 👩‍💻

@szepeviktor
Copy link
Owner

Still fails on PHP 7.2

--- Expected
+++ Actual
@@ @@
-'string'
+'PHPUnit\Framework\MockObject\Stub\ReturnStub'

https://github.com/szepeviktor/phpstan-wordpress/blob/master/tests/data/apply_filters.php#L84-L90

@herndlm
Copy link
Contributor

herndlm commented May 2, 2022

I started debugging this, not sure yet why it only happens on 7.2 but the returnValue helper function from here seems to be clashing with https://github.com/sebastianbergmann/phpunit/blob/main/src/Framework/Assert/Functions.php#L2676 which is also global. 2 possible fixes that I can think of

  • add the same namespace to test/functions.php and drop the global use from the test files
  • rename returnValue

I can open a PR against your branch John, if you like. or anyone of you feel free and go ahead and just adapt it, if that's faster :)

UPDATE: opened #101, feel free to merge that or use parts from it here, whatever you prefer.

@herndlm
Copy link
Contributor

herndlm commented May 2, 2022

sorry for the PR noise, @johnbillion checkout https://github.com/johnbillion/phpstan-wordpress/pull/1 if you have time. that should fix it

@szepeviktor
Copy link
Owner

@johnbillion Is it my turn now?

@johnbillion
Copy link
Contributor Author

Sure 🍸

@szepeviktor szepeviktor changed the title PHPStan bleeding edge compatibility Add PHPStan bleeding edge compatibility May 2, 2022
@szepeviktor szepeviktor merged commit 37eaf7e into szepeviktor:master May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants