composer.json declares "php": "^7.2.0 || ^8.1.0", but v0.43.0 added src/Magento/Framework/Escaper.php, which uses a PHP 8.0 union type on line 17:
public function escapeHtml($data, array|null $allowedTags = null) {}
MockAutoloader does a plain require() on that stub at runtime, so on PHP 7.x it is a fatal parse error rather than a skipped file. Every analysis run that touches a class using Magento\Framework\Escaper dies with:
Internal error: syntax error, unexpected '|', expecting variable (T_VARIABLE)
while analysing file .../vendor/magento/module-cms/Ui/Component/Listing/Column/PageActions.php
Top of the stack trace:
## /data/vendor/bitexpert/phpstan-magento/src/Magento/Framework/Escaper.php(17)
#0 .../SourceLocator/AutoloadFunctionsSourceLocator.php(60): bitExpert\PHPStan\Magento\Autoload\MockAutoloader->autoload()
Reproduce
Magento 2.4.3 on PHP 7.4, with phpstan/phpstan 2.2.9 and bitexpert/phpstan-magento v0.43.0 (2.2.10+ is unusable because of #356):
vendor/bin/phpstan analyse vendor/magento/module-cms --level 2
Downgrading to v0.42.0, which has no Escaper.php, completes the analysis normally.
Fix
?array $allowedTags = null is equivalent and valid since PHP 7.1. That one line is the only problem: with it changed, every file under src/ passes php -l on PHP 7.4.
The stub arrived in 570cca8 (July 2025, from #343) and stayed unreleased until v0.43.0, so this has only been reachable since late June 2026. CI runs PHP 8.4 exclusively, which is why it went unnoticed. Worth adding a 7.4 lint job, or dropping ^7.2 from composer.json if PHP 7 is no longer meant to be supported.
composer.json declares
"php": "^7.2.0 || ^8.1.0", but v0.43.0 addedsrc/Magento/Framework/Escaper.php, which uses a PHP 8.0 union type on line 17:MockAutoloader does a plain require() on that stub at runtime, so on PHP 7.x it is a fatal parse error rather than a skipped file. Every analysis run that touches a class using Magento\Framework\Escaper dies with:
Top of the stack trace:
Reproduce
Magento 2.4.3 on PHP 7.4, with phpstan/phpstan 2.2.9 and bitexpert/phpstan-magento v0.43.0 (2.2.10+ is unusable because of #356):
Downgrading to v0.42.0, which has no Escaper.php, completes the analysis normally.
Fix
?array $allowedTags = null is equivalent and valid since PHP 7.1. That one line is the only problem: with it changed, every file under src/ passes php -l on PHP 7.4.
The stub arrived in 570cca8 (July 2025, from #343) and stayed unreleased until v0.43.0, so this has only been reachable since late June 2026. CI runs PHP 8.4 exclusively, which is why it went unnoticed. Worth adding a 7.4 lint job, or dropping ^7.2 from composer.json if PHP 7 is no longer meant to be supported.