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