Introduce a marker interface for annotation/attribute classes #1529
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 standalone attribute driver doesn't do any kind of filtering on attribute classes that it tries to use, compared to the deprecated attribute reader decorator (implementing the
doctrine/annotations
reader interface) which uses a namespace filter. This PR introduces a marker interface for the serializer's annotation/attribute classes and adjusts the ReflectiongetAttributes()
calls to filter down to attribute classes that implement the interface. This solves the issue of trying to handle missing classes or trying to work with incompatible attributes by telling the engine to filter down to only supported classes without the need for other creative checks.Since #1525 added tests dealing with missing classes, there's no need to add any other test cases as the fixtures already have classes with attributes from mixed providers. If anything, the benchmark slightly improves since it won't try to instantiate unsupported attribute classes anymore (or have to check those in the driver while building the metadata object).