Skip to content

Conversation

@AronNovak
Copy link
Member

@AronNovak AronNovak commented Sep 17, 2025

Status

image

Summary

  • Port NoRedundantTraitUseRule
  • Detects redundant trait usage when a trait is already included via another trait

Port the rule from phpstan-strict-rules PR #279 to detect when a class
uses both a trait A and trait B, where trait A already uses trait B.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@AronNovak AronNovak changed the title Add NoRedundantTraitUseRule to detect nested traits WIP: Add NoRedundantTraitUseRule to detect nested traits Sep 17, 2025
@AronNovak
Copy link
Member Author

I tried to do a generic contribution at:
phpstan/phpstan-strict-rules#279
mglaman/phpstan-drupal#912
phpstan/phpstan#13520

No luck.

Analyzed trait dependency hierarchies and removed 39 redundant trait imports across:
- RoboFile.php: Removed DeploymentTrait (included via ImportToUi)
- EntityViewBuilder classes: Removed various redundant traits
- StyleGuideController: Removed 7 redundant traits

Key architectural findings:
- ElementMediaThemeTrait includes ElementWrapThemeTrait
- ElementNodeNewsThemeTrait includes multiple traits (EntityDateTrait, LineSeparatorThemeTrait, etc.)
- Many theme traits follow hierarchical patterns with common base traits

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@AronNovak

This comment was marked as spam.

@AronNovak AronNovak changed the title WIP: Add NoRedundantTraitUseRule to detect nested traits Add NoRedundantTraitUseRule to detect nested traits Sep 17, 2025
@AronNovak AronNovak requested a review from amitaibu September 17, 2025 10:12
Copy link
Member

@amitaibu amitaibu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@amitaibu amitaibu merged commit 08a2320 into main Sep 17, 2025
1 check passed
@amitaibu amitaibu deleted the phpstan-nested-traits branch September 17, 2025 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants