[AnnotationsToAttributes] Convert external @depends ClassName::method to #[DependsExternal]#679
Merged
Merged
Conversation
… to #[DependsExternal] (fixes rectorphp/rector#9539)
Member
Author
|
LGTM 👍 |
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.
Fixes rectorphp/rector#9539
When a
@dependsannotation references a method on another test class (@depends OtherTest::testMethod),DependsAnnotationWithValueToAttributeRectorleft it untouched. PHPUnit expresses a cross-class dependency with a dedicated attribute that takes the class and method as two arguments:Previously this case fell through all resolvers and produced no change (or, as reported, a malformed single-argument
#[Depends(Other::testIsImmutable)]).What changed
resolveDependsExternalClassMethod()branch that recognisesClassName::method(skipping::class, already handled byDependsOnClass, andclone …, handled byDependsUsingDeepClone) and emits#[DependsExternal(ClassName::class, 'method')].[attributeClass, items[]]so attributes can carry more than one argument (the existing single-argument cases keep their behaviour).Tests
Fixture/depends_external.php.inc.rules-tests/AnnotationsToAttributessuite is green; ECS, PHPStan and Rector pass on the changed rule.Scope note: the deep-clone external variant (
@depends clone OtherTest::method→DependsExternalUsingDeepClone) is intentionally left out of scope and explicitly skipped, so its current behaviour is unchanged.