Skip to content

feat: Add YagniPreset to detect and remove unused interfaces, abstract classes, and traits on scanned paths - #308

Draft
samsonasik wants to merge 10 commits into
mainfrom
add-yagni-preset
Draft

feat: Add YagniPreset to detect and remove unused interfaces, abstract classes, and traits on scanned paths#308
samsonasik wants to merge 10 commits into
mainfrom
add-yagni-preset

Conversation

@samsonasik

@samsonasik samsonasik commented Aug 18, 2026

Copy link
Copy Markdown
Member

This PR introduce new interfaces:

  • Boundwize\StructArmed\Rule\UsedInterfaceAwareRuleInterface
  • Boundwize\StructArmed\Rule\UsedTraitAwareRuleInterface

that used on new YagniPreset in addition of existing:

  • Boundwize\StructArmed\Rule\ExtendedClassAwareRuleInterface

The YagniPreset can do:

  • find unused abstract classes
  • find unused interfaces
  • find unused traits

The rules for them is support --fix so you can remove above violations and the file (if only consist of declarion).

You can define YAGNI preset:

<?php

declare(strict_types=1);

use Boundwize\StructArmed\Architecture;
use Boundwize\StructArmed\Preset\Preset;
use Boundwize\StructArmed\Preset\Presets\Psr1Preset;
use Boundwize\StructArmed\Rule\Rules\Class_\MustBeFinalRule;

return Architecture::define()
     // ... other config ...
-    ->withPresets(Preset::PSR1(), Preset::PSR12(), Preset::PSR4());
+    ->withPresets(Preset::PSR1(), Preset::PSR12(), Preset::PSR4(), Preset::YAGNI());

@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@samsonasik
samsonasik marked this pull request as draft August 18, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant