Skip to content

[deprecation] Deprecate AddInterfaceByTraitRector - #8346

Merged
TomasVotruba merged 1 commit into
mainfrom
deprecate-add-interface-by-trait-rector
Aug 10, 2026
Merged

[deprecation] Deprecate AddInterfaceByTraitRector#8346
TomasVotruba merged 1 commit into
mainfrom
deprecate-add-interface-by-trait-rector

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Pairing a trait with an interface is specific to a single project or package. In practice the mapping needs extra conditions - only for classes in a certain namespace, only when the trait is used directly, only when a matching method exists - none of which a plain trait => interface map can express. A custom rule is a better fit.

The rule is not part of any set - neither in rector-src config/set/, nor in rector-symfony, rector-doctrine, rector-phpunit, rector-laravel or drupal-rector.

What the rule did:

$rectorConfig->ruleWithConfiguration(AddInterfaceByTraitRector::class, [
    'SomeTrait' => 'SomeInterface',
]);
-class SomeClass
+class SomeClass implements SomeInterface
 {
     use SomeTrait;
 }

The class carried an @api used in rector-doctrine note, but rector-doctrine has no reference to it anymore, so the tag was stale and is dropped.

Follows the same shape as the recently deprecated rules - DeprecatedInterface, refactor() throws, tests removed.

@TomasVotruba
TomasVotruba force-pushed the deprecate-add-interface-by-trait-rector branch from ec5511b to 4144291 Compare August 10, 2026 22:13
@TomasVotruba
TomasVotruba enabled auto-merge (squash) August 10, 2026 22:14
@TomasVotruba
TomasVotruba merged commit 768539a into main Aug 10, 2026
52 checks passed
@TomasVotruba
TomasVotruba deleted the deprecate-add-interface-by-trait-rector branch August 10, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant