Repository navigation
[perf] Read attribute-class from node attrGroups in RemoveUnusedConstructorParamRector - #8720
Merged
Merged
Conversation
…ructorParamRector
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.
What
RemoveUnusedConstructorParamRectorskips attribute marker classes (their constructor params are meta, not dead code). It did that by resolving the class reflection and callingClassReflection::isAttributeClass().Whether a class carries
#[Attribute]is declared directly on the class - it is not inherited - so it is fully visible in the node'sattrGroups. This reads it straight off theClass_node instead, and runs the check beforeresolveClassReflection(). An attribute marker class with a doc-commented constructor now bails before any reflection resolves.Same node-direct pattern as the sibling attribute checks already in the dead-code rules.
ReflectionResolverstays - it is still needed for the interfacehasNativeMethodcontract check below.Bench
bench/remove_unused_constructor_param_attribute_bench.php- 150 attribute marker classes with doc-commented constructors,refactor()driven over each (9000 calls), CPU time (user+sys), warmup excluded.The win is the skipped
resolveClassReflection()on the attribute-marker path; behaviour is unchanged.Tests
Existing
skip_attribute_marker.php.inc(FQ#[\Attribute]) still passes. Addedskip_imported_attribute_marker.php.incto lock the imported + argumented form#[Attribute(Attribute::TARGET_CLASS)], which the node name-resolution path must also recognise. Full rule test green (16 tests).