Fix PHP 7 parse error in the Escaper stub - #359
Open
michielgerritsen wants to merge 2 commits into
Open
Conversation
michielgerritsen
force-pushed
the
fix/php7-escaper-stub
branch
from
September 3, 2026 10:11
441d3e7 to
f3f6fb0
Compare
Member
|
Do you have an older Magento project to test this change against? I am not fully sure if we run into problems when changing the method signature when analyzing classes that inherit the "original" Magento class. But that's probably an edge-case and something to fix by future you anyways :) |
Author
|
I have. I ran it against PHP 7.2-8.5 against the corresponding Magento versions as a test. It turns out that, since PHPStan 2.0 is required, it's not possible to install it on anything lower than 7.4. I updated the PR to reflect that in the composer.json. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #358. The
Escaperstub added in 0.43.0 declaresescapeHtml()with a native union type, andMockAutoloaderrequire()s the stubs into the process running PHPStan, so on PHP 7 that is a fatal parse error rather than a skipped file: every analysis touchingMagento\Framework\Escaperaborts with an internal error.?arrayis equivalent from PHP 7.1 on. Nothing checkssrc/Magentotoday, sincephpstan.neonlists onlysrc/bitExpert,cs-checkignores it and CI runs 8.4 exclusively, so the rest closes that gap.bin/ci_php_lint, from a newlintjob on 7.4, 8.1 and 8.5php -lat both ends of the composer constraintphpstan-stubs.neon, asanalyze-stubsphpVersionrange onphpstan.neonatlevel: maxreports 267 unrelated errorsWorth a look: only the 7.4 entry catches this bug, 8.1 and 8.5 guard the other direction. The composer constraint moves from ^7.2 to ^7.4 in the same PR because phpstan/phpstan ^2.0 already requires 7.4, so 7.2 and 7.3 could not install 0.43.0 in the first place.