api-platform/core 4.3 ships redundant union docblocks object|<Class> in its
own source:
src/Symfony/Messenger/DispatchTrait.php:28→@param object|Envelope $messagesrc/Doctrine/Common/Messenger/DispatchTrait.php:28→@param object|Envelope $message
With symfony/type-info 7.4 installed, the PhpStanExtractor that API Platform
wires as api_platform.property_info.php_stan_extractor throws while building
the type graph when it parses such a docblock during cache:clear / metadata
warmup:
Symfony\Component\TypeInfo\Exception\InvalidArgumentException:
Cannot create union with both "object" and class type.
at symfony/type-info/Type/UnionType.php:75
object|Envelope is redundant — object already subsumes every class type.
Legacy symfony/property-info Type tolerated it; symfony/type-info 7.4
rejects it hard.
PR #8206 (4.3.10) isolated the
framework property_info service from API Platform's extractors, but API
Platform's own extractor still parses these docblocks → same crash.
composer install
php repro.phpExpected output (bug reproduced, exit code 1):
PHP : 8.4.22
api-platform/core: v4.3.13
symfony/type-info: v7.4.9
symfony/property-info: v7.4.8
------------------------------------------------------------
[KO] Symfony\Component\TypeInfo\Exception\InvalidArgumentException: Cannot create union with both "object" and class type.
thrown from: .../symfony/type-info/Type/UnionType.php:75
No app kernel required — repro.php invokes the failing extractor directly on a
property whose docblock mirrors the DispatchTrait shape.
Drop the redundant |Envelope from both DispatchTrait docblocks (the signature
already declares object $message/: Envelope):
- /**
- * @param object|Envelope $message
- */
private function dispatch(object $message): Envelope