Skip to content

feat: Add YAGNI preset - #308

Merged
samsonasik merged 24 commits into
mainfrom
add-yagni-preset
Aug 20, 2026
Merged

feat: Add YAGNI preset#308
samsonasik merged 24 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: MustBeUsedAbstractClassRule
  • find unused interfaces: MustBeUsedInterfaceRule
  • find unused traits: MustBeUsedTraitRule

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

There is also rule that can find non-abstract class that only extended, never instantiated, it should be abstract:

  • ExtendedClassMustBeAbstractOrInstantiatedRule, this also support --fix that can update class to abstract:
-class SomeClassOnlyExtended
+abstract class SomeClassOnlyExtended

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
@samsonasik samsonasik changed the title feat: Add YagniPreset to detect and remove unused interfaces, abstract classes, and traits on scanned paths feat: Add YAGNI preset Aug 19, 2026
@samsonasik
samsonasik marked this pull request as ready for review August 20, 2026 01:58
@samsonasik
samsonasik merged commit f6610c0 into main Aug 20, 2026
14 checks passed
@samsonasik
samsonasik deleted the add-yagni-preset branch August 20, 2026 01:59
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