Remove "Wrapper" abstract class#1655
Conversation
6066fea to
8a43a0b
Compare
There was a problem hiding this comment.
Pull request overview
This PR removes the Wrapper abstract class from the codebase, replacing it with direct implementations in the validators that previously extended it. With PHP's promoted properties, the minimal functionality provided by Wrapper (constructor and evaluate() proxy) is no longer necessary, especially since most extending classes had their own evaluate() implementations.
Changes:
- Removed the
Wrapperabstract class and its test files - Updated 13 validator classes to implement
Validatorinterface directly instead of extendingWrapper - Updated migration documentation to remove
Wrapperfrom the list of available base classes
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Validators/Core/Wrapper.php | Deleted abstract class that provided constructor and evaluate() method |
| tests/unit/Validators/Core/WrapperTest.php | Deleted test file for Wrapper class |
| tests/src/Validators/Core/ConcreteWrapper.php | Deleted test stub for Wrapper class |
| src/Validators/UndefOr.php | Now implements Validator directly with promoted properties |
| src/Validators/Templated.php | Now implements Validator directly with promoted properties |
| src/Validators/Size.php | Now implements Validator directly with promoted properties |
| src/Validators/PropertyOptional.php | Now implements Validator directly with promoted properties |
| src/Validators/Property.php | Now implements Validator directly with promoted properties |
| src/Validators/NullOr.php | Now implements Validator directly with promoted properties |
| src/Validators/Not.php | Now implements Validator directly with promoted properties |
| src/Validators/Named.php | Now implements Validator directly with promoted properties |
| src/Validators/Length.php | Now implements Validator directly with promoted properties |
| src/Validators/KeyOptional.php | Now implements KeyRelated (extends Validator) directly |
| src/Validators/Key.php | Now implements KeyRelated (extends Validator) directly |
| src/Validators/Core/Reducer.php | Now implements Validator directly with custom logic |
| src/Validators/Core/FilteredNonEmptyArray.php | Abstract class now implements Validator directly with protected property |
| docs/migrating-from-v2-to-v3.md | Removed Wrapper from list of available base classes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
99d5a90 to
5122e4f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1655 +/- ##
============================================
+ Coverage 99.20% 99.29% +0.09%
- Complexity 917 920 +3
============================================
Files 191 190 -1
Lines 2146 2141 -5
============================================
- Hits 2129 2126 -3
+ Misses 17 15 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
With PHP's promoted properties, there is little reason to have an abstract class that only provides a constructor and a proxy method. The greater part of the classes that extended Wrapper had their own implementation of evaluate(), hence it made very little sense to keep Wrapper in the codebase. Assisted-by: Claude Code (Opus 4.5)
5122e4f to
b352f17
Compare
With PHP's promoted properties, there is little reason to have an abstract class that only provides a constructor and a proxy method. The greater part of the classes that extended Wrapper had their own implementation of evaluate(), hence it made very little sense to keep Wrapper in the codebase.
Assisted-by: Claude Code (Opus 4.5)