You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
object|<Class> docblocks in DispatchTrait break metadata warmup under symfony/type-info 7.4 (Cannot create union with both "object" and class type) #8312
With symfony/type-info 7.4 installed, the PhpStanExtractor that API Platform
wires as api_platform.property_info.php_stan_extractor throws an Exception while building
the type graph whenever it parses such a docblock:
Symfony\Component\TypeInfo\Exception\InvalidArgumentException:
Cannot create union with both "object" and class type.
at vendor/symfony/type-info/Type/UnionType.php:75
object|Envelope is redundant — object already subsumes every class type.
The legacy symfony/property-infoType model tolerated this; symfony/type-info
7.4 rejects it hard.
This regressed cache:clear / routing warmup on the Symfony 7.3 → 7.4 bump.
PR #8206 (released in 4.3.10) isolated the frameworkproperty_info service
from API Platform's extractors via private api_platform.property_info.* tags +
a bridge compiler pass. That fixed the path where API Platform's PhpStanExtractor
leaked into the framework service (Sylius @template T of object crash).
It does not cover this case: API Platform's ownPhpStanExtractor still
parses object|<Class> docblocks during metadata warmup and hits the same type-info exception. The remaining 4.3 path is still affected.
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
The gist invokes the exact extractor API Platform wires as api_platform.property_info.php_stan_extractor directly Title:
on a property whose
docblock mirrors the DispatchTrait shape (@var object|Envelope).
You can also confirm the offending docblocks directly:
Drop the redundant |Envelope from both DispatchTrait docblocks — the
method already declares object $message / : Envelope in the signature, so
the docblock carries no extra information:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Fixed by #8410 (0864f2f), first released in v4.3.18. Verified on v4.4.0: both src/Symfony/Messenger/DispatchTrait.php and src/Doctrine/Common/Messenger/DispatchTrait.php no longer carry the @param object|Envelope docblock, and cache:clear --env=prod warms up cleanly again. Thanks @ousamabenyounes!
One note for anyone landing here with the same error message after upgrading to Symfony 7.4 — the api-platform docblocks were not the only source. symfony/type-info also resolves @template bounds (TypeContext\TypeContextFactory::collectTemplates()), and that path is reached through api-platform's own property metadata:
In our stack the remaining offender is gedmo/doctrine-extensions, which declares @phpstan-template T of Loggable|object on AbstractLogEntry (also LogEntryRepository and LoggableListener) — tracked at doctrine-extensions/DoctrineExtensions#3044 with an open PR doctrine-extensions/DoctrineExtensions#3046. Same exception, different library, so the symptom is easy to mistake for this issue still being unfixed.
Correction to my comment above, so the record is precise: the DispatchTrait docblocks are indeed gone as of v4.4.0 — that part is verified. But our cache:clear --env=prod only warms up cleanly because we still neutralise Symfony's property_info.phpstan_extractor on our side. With the real PhpStanExtractor active on api-platform 4.4.0 / symfony 7.4.19 / type-info 7.4.17, warmup still aborts — on the gedmo @phpstan-template T of Loggable|object bounds described above, not on anything in api-platform. So this issue is correctly closed; the remaining failure belongs to doctrine-extensions/DoctrineExtensions#3044.
Activity
Fix symfony/type-info InvalidArgumentException during cache warmup
github-actions commentedon Aug 16, 2026
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
schmunk42 commentedon Aug 16, 2026
This is still an issue and others are also affected by this, please let me know if I should provide additional information or create a PR.
Upgrade to symfony/mcp-bundle ^0.13 with multi-server support
schmunk42 commentedon Sep 22, 2026
Fixed by #8410 (
0864f2f), first released in v4.3.18. Verified on v4.4.0: bothsrc/Symfony/Messenger/DispatchTrait.phpandsrc/Doctrine/Common/Messenger/DispatchTrait.phpno longer carry the@param object|Envelopedocblock, andcache:clear --env=prodwarms up cleanly again. Thanks @ousamabenyounes!One note for anyone landing here with the same error message after upgrading to Symfony 7.4 — the api-platform docblocks were not the only source.
symfony/type-infoalso resolves@templatebounds (TypeContext\TypeContextFactory::collectTemplates()), and that path is reached through api-platform's own property metadata:In our stack the remaining offender is
gedmo/doctrine-extensions, which declares@phpstan-template T of Loggable|objectonAbstractLogEntry(alsoLogEntryRepositoryandLoggableListener) — tracked at doctrine-extensions/DoctrineExtensions#3044 with an open PR doctrine-extensions/DoctrineExtensions#3046. Same exception, different library, so the symptom is easy to mistake for this issue still being unfixed.Closing this as resolved.
schmunk42 commentedon Sep 22, 2026
Correction to my comment above, so the record is precise: the
DispatchTraitdocblocks are indeed gone as of v4.4.0 — that part is verified. But ourcache:clear --env=prodonly warms up cleanly because we still neutralise Symfony'sproperty_info.phpstan_extractoron our side. With the realPhpStanExtractoractive on api-platform 4.4.0 / symfony 7.4.19 / type-info 7.4.17, warmup still aborts — on the gedmo@phpstan-template T of Loggable|objectbounds described above, not on anything in api-platform. So this issue is correctly closed; the remaining failure belongs to doctrine-extensions/DoctrineExtensions#3044.