Skip to content

Fix PHP 7 parse error in the Escaper stub - #359

Open
michielgerritsen wants to merge 2 commits into
bitExpert:masterfrom
michielgerritsen:fix/php7-escaper-stub
Open

Fix PHP 7 parse error in the Escaper stub#359
michielgerritsen wants to merge 2 commits into
bitExpert:masterfrom
michielgerritsen:fix/php7-escaper-stub

Conversation

@michielgerritsen

@michielgerritsen michielgerritsen commented Sep 3, 2026

Copy link
Copy Markdown

Fixes #358. The Escaper stub added in 0.43.0 declares escapeHtml() with a native union type, and MockAutoloader require()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 touching Magento\Framework\Escaper aborts with an internal error. ?array is equivalent from PHP 7.1 on. Nothing checks src/Magento today, since phpstan.neon lists only src/bitExpert, cs-check ignores it and CI runs 8.4 exclusively, so the rest closes that gap.

Change Why
bin/ci_php_lint, from a new lint job on 7.4, 8.1 and 8.5 real php -l at both ends of the composer constraint
phpstan-stubs.neon, as analyze-stubs its own config because a phpVersion range on phpstan.neon at level: max reports 267 unrelated errors

Worth 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.

@shochdoerfer

Copy link
Copy Markdown
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 :)

@michielgerritsen

Copy link
Copy Markdown
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.

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.

v0.43.0 ships PHP 8 syntax in a stub, breaking the declared PHP 7 support

2 participants