[BetterPhpDocParser] inject phpdoc node decorators explicitly to keep required order - #8379
Merged
Conversation
TomasVotruba
force-pushed
the
tv-no-tagged
branch
from
August 25, 2026 18:38
d9c5826 to
2933ae4
Compare
…xplicitly in order Move the four PhpDocNodeDecorator services out of the PhpDocParser namespace into a dedicated NodeDecorator namespace, and inject them into BetterPhpDocParser as explicit constructor params instead of a tagged collection. The decorators have a required run order: DoctrineAnnotationDecorator must run before ArrayItemClassNameDecorator, which resolves class names in the array items the former produces (e.g. inside doctrine annotations). Explicit ordered injection guarantees this; tagged or autodiscovered registration would not.
TomasVotruba
force-pushed
the
tv-no-tagged
branch
from
August 25, 2026 18:39
2933ae4 to
7593cdc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PHP doc node decorators had a required run order that autodiscovery does not guarantee.
DoctrineAnnotationDecoratortransforms a rawGenericTagValueNodeannotation into aDoctrineAnnotationTagValueNodetree, creating theArrayItemNodes.ArrayItemClassNameDecoratorthen resolves class names inside those nodes. So Doctrine must run first.Autodiscovering the
NodeDecorator/directory ordered them by filesystem, droppingDoctrineAnnotationDecoratorto last:With Doctrine last,
ArrayItemClassNameDecoratorruns on un-transformed text, never marks the annotation class usages, andremoveUnusedImports()then strips imports that are actually used inside annotations:Fix
Inject the four decorators as explicit
__construct()params, in the required order, instead of autodiscovering them — the order is now encoded in the service and documented with a comment. Container autowires each concrete decorator by type.