#110522PHPStan reports Extbase annotation alias as non-attribute
Description
Problem
The nightly pipeline for branch 14.3 fails in the job phpstan php 8.2 max
since 2026-08-23. The commit is identical to the one that passed the day
before, so no TYPO3 change is involved.
PHPStan reports three errors with the identifier attribute.notAttribute in
the fixture extension test_validators, model AliasedModel, stating that the
class TYPO3\CMS\Extbase\Annotation\Validate is not an attribute class.
Cause
The only relevant package change is phpstan/phpstan, from 2.2.8 to 2.2.9. A
bisect with everything else kept at the same state shows 2.2.7 and 2.2.8
clean, and 2.2.9 failing.
The rule itself did not change. The attributes check is byte identical
between 2.2.7 and 2.2.9. What changed is which file PHPStan reflects for that
class name.
The name TYPO3\CMS\Extbase\Annotation\Validate does not exist as a source
class. At runtime it is a class alias to TYPO3\CMS\Extbase\Attribute\Validate,
created from the extbase class alias map, and that target does carry the
attribute marker. PHPStan instead reflects the IDE stub below the extbase
migrations code folder, where the same name is declared as a plain subclass.
PHP does not inherit the attribute marker to subclasses, so the report follows
from the stub rather than from the real class.
Up to 2.2.8 the autoload functions source locator was consulted first, so the
name resolved through the class alias loader to the real attribute class.
With 2.2.9 custom autoloaders are consulted after the static locators.
PHPStan identifies the composer loader by comparing the registered autoload
callable against the composer class loader class. The package
typo3/class-alias-loader replaces that loader with its own, so the detection
finds nothing and every custom autoloader is demoted below the static
locators. The directory locator over the extension sources then wins and
returns the stub.
Upstream reference: phpstan-src pull request 6069.
This affects every TYPO3 installation analysed with phpstan 2.2.9 or newer,
because the class alias loader is used throughout the ecosystem.
Branch main is not affected, because the deprecated annotation namespace and
its aliases were removed for v15. Branch 13.4 is not affected either, it
still ships real classes in that namespace.
Solution
Keep the IDE stub files out of the PHPStan source locator. They are guarded
against execution and never loaded at runtime, they exist only for IDE
indexing and static analysis. PHPStan then resolves the name through the
class alias loader again, which matches the runtime situation.
Reviews 1
History 24
-
Gerrit Code Review pushed patch set 1 for 14.3 to change 95387 status
NewUnder Review <span data-processor="relativetime" data-value="2026-08-23T13:51:18+00:00" > 08/23/26, 13:51 </span> -
Gerrit Code Review pushed patch set 2 for 14.3 to change 95387 <span data-processor="relativetime" data-value="2026-08-23T14:36:06+00:00" > 08/23/26, 14:36 </span>
-
Stefan Bürk commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-08-23T14:50:09+00:00" > 08/23/26, 14:50 </span>Applied in changeset commit:ca26e4338682ad503dfdb961349364195c353374.
Reported upstream as phpstan/phpstan issue 15102:
https://github.com/phpstan/phpstan/issues/15102
The regression comes from phpstan-src pull request 6069, released with 2.2.9.
Its composer loader detection looks for a Composer ClassLoader instance in the
autoload queue, but typo3/class-alias-loader removes that callable and
registers itself in its place, so the detection cannot succeed and every custom
autoloader is consulted after the static locators.
Our change only keeps the IDE stubs out of the source locator, which is a
workaround. If upstream fixes the bucketing, the exclusion can stay regardless,
since analysing those stubs is never useful.