Skip to content

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

Description

@michielgerritsen

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions