-
Notifications
You must be signed in to change notification settings - Fork 775
Rename logical validators #1601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The name `AllOf` was ambiguous and could be confused with iteration semantics. The new name `LogicAnd` clearly indicates this is a logical `AND` operation where all provided rules must pass for the same input value. This rename is part of a broader effort to improve the naming of composite rules in version 3.0, making them more intuitive and reducing potential confusion when implementing validation logic.
The name `AnyOf` was ambiguous and could be confused with iteration semantics (e.g., "any item of an array must pass"). The new name `LogicOr` clearly indicates this is a logical OR operation where at least one of the provided rules must pass for the same input value. This rename is part of a broader effort to improve the naming of composite rules in version 3.0, making them more intuitive and reducing potential confusion when implementing validation logic.
The name `NoneOf` was ambiguous and could be confused with iteration semantics (e.g., "none of the items in an array must pass"). The new name `LogicNor` clearly indicates this is a logical NOR operation where none of the provided rules must pass for the same input value. This rename is part of a broader effort to improve the naming of composite rules in version 3.0, making them more intuitive and reducing potential confusion when implementing validation logic.
The name `OneOf` was ambiguous and could be confused with iteration semantics (e.g., "one item of an array must pass"). The new name `LogicXor` clearly indicates this is a logical XOR operation where exactly one of the provided rules must pass for the same input value. This rename is part of a broader effort to improve the naming of composite rules in version 3.0, making them more intuitive and reducing potential confusion when implementing validation logic.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1601 +/- ##
=========================================
Coverage 97.43% 97.43%
Complexity 981 981
=========================================
Files 211 211
Lines 2259 2259
=========================================
Hits 2201 2201
Misses 58 58 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The name `When` was ambiguous and didn't clearly convey its purpose as a conditional validator. The new name `LogicCond` clearly indicates this is a logical conditional operation (if-then-else) where validation follows different paths based on whether a condition passes or fails. This rename is part of a broader effort to improve the naming of composite rules in version 3.0, making them more intuitive and reducing potential confusion when implementing validation logic.
1d6e75e to
c3b7d49
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request renames logical validators to use more descriptive names with a "Logic" prefix, improving code clarity by explicitly indicating their logical operation semantics.
Changes:
- Renamed validators: AllOf → LogicAnd, AnyOf → LogicOr, OneOf → LogicXor, NoneOf → LogicNor, When → LogicCond
- Updated parameter name in LogicCond from
$whento$iffor clarity - Updated all tests, feature tests, documentation, and mixin interfaces to reflect the new naming
Reviewed changes
Copilot reviewed 62 out of 62 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/Validators/OneOfTest.php | Deleted old OneOf test file |
| tests/unit/Validators/NoneOfTest.php | Deleted old NoneOf test file |
| tests/unit/Validators/LogicXorTest.php | Added new LogicXor test file |
| tests/unit/Validators/LogicOrTest.php | Added new LogicOr test file |
| tests/unit/Validators/LogicNorTest.php | Added new LogicNor test file |
| tests/unit/Validators/LogicCondTest.php | Renamed from WhenTest and updated class references |
| tests/unit/Validators/LogicAndTest.php | Added new LogicAnd test file |
| tests/unit/Validators/Core/ReducerTest.php | Updated AllOf reference to LogicAnd |
| tests/unit/Validators/AnyOfTest.php | Deleted old AnyOf test file |
| tests/unit/Validators/AllOfTest.php | Deleted old AllOf test file |
| tests/library/Stubs/WithAttributes.php | Updated AnyOf attribute to LogicOr |
| tests/feature/Validators/LogicXorTest.php | Updated oneOf calls to logicXor |
| tests/feature/Validators/LogicOrTest.php | Updated anyOf calls to logicOr |
| tests/feature/Validators/LogicNorTest.php | Updated noneOf calls to logicNor |
| tests/feature/Validators/LogicCondTest.php | Updated when calls to logicCond |
| tests/feature/Validators/LogicAndTest.php | Updated allOf calls to logicAnd |
| tests/feature/Validators/AttributesTest.php | Updated expected message key from anyOf to logicOr |
| tests/feature/Issues/Issue739Test.php | Updated when call to logicCond |
| tests/feature/Issues/Issue425Test.php | Updated noneOf call to logicNor |
| tests/feature/Issues/Issue1289Test.php | Updated OneOf import to LogicXor |
| src-dev/Commands/UpdateDocLinksCommand.php | Fixed doc link pattern matching |
| library/Validators/LogicXor.php | Renamed class from OneOf to LogicXor |
| library/Validators/LogicOr.php | Renamed class from AnyOf to LogicOr |
| library/Validators/LogicNor.php | Renamed class from NoneOf to LogicNor |
| library/Validators/LogicCond.php | Renamed class from When to LogicCond and parameter from $when to $if |
| library/Validators/LogicAnd.php | Renamed class from AllOf to LogicAnd |
| library/Validators/Domain.php | Updated AnyOf reference to LogicOr |
| library/Validators/Core/Reducer.php | Updated AllOf import and usage to LogicAnd |
| library/Validators/ContainsAny.php | Updated AnyOf reference to LogicOr |
| library/Validators/BetweenExclusive.php | Updated AllOf reference to LogicAnd |
| library/Validators/Between.php | Updated AllOf reference to LogicAnd |
| library/ValidatorBuilder.php | Updated AllOf import and usage to LogicAnd |
| library/Transformers/Prefix.php | Updated allOf to logicAnd in skip list |
| library/Mixins/UndefOrChain.php | Removed old methods and added new logic methods |
| library/Mixins/UndefOrBuilder.php | Removed old methods and added new logic methods |
| library/Mixins/PropertyChain.php | Removed old methods and added new logic methods |
| library/Mixins/PropertyBuilder.php | Removed old methods and added new logic methods |
| library/Mixins/NullOrChain.php | Removed old methods and added new logic methods |
| library/Mixins/NullOrBuilder.php | Removed old methods and added new logic methods |
| library/Mixins/NotChain.php | Removed old methods and added new logic methods |
| library/Mixins/NotBuilder.php | Removed old methods and added new logic methods |
| library/Mixins/KeyChain.php | Removed old methods and added new logic methods |
| library/Mixins/KeyBuilder.php | Removed old methods and added new logic methods |
| library/Mixins/Chain.php | Removed old methods and added new logic methods |
| library/Mixins/Builder.php | Removed old methods and added new logic methods |
| library/Mixins/AllChain.php | Removed old methods and added new logic methods |
| library/Mixins/AllBuilder.php | Removed old methods and added new logic methods |
| docs/validators/When.md | Deleted old When documentation |
| docs/validators/PublicDomainSuffix.md | Updated oneOf reference to logicXor |
| docs/validators/Not.md | Updated NoneOf reference to LogicNor |
| docs/validators/LogicXor.md | Added new documentation for LogicXor |
| docs/validators/LogicOr.md | Added new documentation for LogicOr |
| docs/validators/LogicNor.md | Added new documentation for LogicNor |
| docs/validators/LogicCond.md | Added new documentation for LogicCond |
| docs/validators/LogicAnd.md | Added new documentation for LogicAnd |
| docs/validators/ContainsAny.md | Updated AnyOf reference to LogicOr |
| docs/validators/Circuit.md | Updated When reference to LogicCond and other logic validators |
| docs/validators/Attributes.md | Updated AnyOf reference to LogicOr |
| docs/validators/AlwaysInvalid.md | Updated When reference to LogicCond |
| docs/list-of-validators-by-category.md | Updated all validator categories and alphabetical list |
| docs/feature-guide.md | Updated conditional/grouped validation references |
| docs/concrete-api.md | Updated AllOf reference to LogicAnd |
Comments suppressed due to low confidence (1)
tests/unit/Validators/LogicCondTest.php:27
- The test description says "fail, then pass" but the first parameter uses
Stub::pass(1), which means the condition passes, not fails. The description should be "pass, then pass" to accurately describe the test case.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| public function allLogicAnd(Validator $validator1, Validator $validator2, Validator ...$validators): Chain; | ||
|
|
||
| public function allLogicCond(Validator $logicCond, Validator $then, Validator|null $else = null): Chain; |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name $logicCond is inconsistent with the actual LogicCond constructor which uses $if as the first parameter name. This should be renamed to $if to match the validator class signature and documentation.
| public function allLogicCond(Validator $logicCond, Validator $then, Validator|null $else = null): Chain; | |
| public function allLogicCond(Validator $if, Validator $then, Validator|null $else = null): Chain; |
| Validator ...$validators, | ||
| ): Chain; | ||
|
|
||
| public static function allLogicCond(Validator $logicCond, Validator $then, Validator|null $else = null): Chain; |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name $logicCond is inconsistent with the actual LogicCond constructor which uses $if as the first parameter name. This should be renamed to $if to match the validator class signature and documentation.
| public static function allLogicCond(Validator $logicCond, Validator $then, Validator|null $else = null): Chain; | |
| public static function allLogicCond(Validator $if, Validator $then, Validator|null $else = null): Chain; |
|
|
||
| public static function propertyLogicCond( | ||
| string $propertyName, | ||
| Validator $logicCond, |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name $logicCond is inconsistent with the actual LogicCond constructor which uses $if as the first parameter name. This should be renamed to $if to match the validator class signature and documentation.
| Validator $logicCond, | |
| Validator $if, |
|
|
||
| public static function keyLogicCond( | ||
| int|string $key, | ||
| Validator $logicCond, |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name $logicCond is inconsistent with the actual LogicCond constructor which uses $if as the first parameter name. This should be renamed to $if to match the validator class signature and documentation.
| Validator $logicCond, | |
| Validator $if, |
|
|
||
| public function undefOrLogicAnd(Validator $validator1, Validator $validator2, Validator ...$validators): Chain; | ||
|
|
||
| public function undefOrLogicCond(Validator $logicCond, Validator $then, Validator|null $else = null): Chain; |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name $logicCond is inconsistent with the actual LogicCond constructor which uses $if as the first parameter name. This should be renamed to $if to match the validator class signature and documentation.
| public function undefOrLogicCond(Validator $logicCond, Validator $then, Validator|null $else = null): Chain; | |
| public function undefOrLogicCond(Validator $if, Validator $then, Validator|null $else = null): Chain; |
|
|
||
| public static function logicAnd(Validator $validator1, Validator $validator2, Validator ...$validators): Chain; | ||
|
|
||
| public static function logicCond(Validator $logicCond, Validator $then, Validator|null $else = null): Chain; |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name $logicCond is inconsistent with the actual LogicCond constructor which uses $if as the first parameter name. This should be renamed to $if to match the validator class signature and documentation.
| public static function logicCond(Validator $logicCond, Validator $then, Validator|null $else = null): Chain; | |
| public static function logicCond(Validator $if, Validator $then, Validator|null $else = null): Chain; |
|
|
||
| public function propertyLogicCond( | ||
| string $propertyName, | ||
| Validator $logicCond, |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name $logicCond is inconsistent with the actual LogicCond constructor which uses $if as the first parameter name. This should be renamed to $if to match the validator class signature and documentation.
| Validator $logicCond, | |
| Validator $if, |
|
|
||
| public function keyLogicCond( | ||
| int|string $key, | ||
| Validator $logicCond, |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name $logicCond is inconsistent with the actual LogicCond constructor which uses $if as the first parameter name. This should be renamed to $if to match the validator class signature and documentation.
| Validator $logicCond, | |
| Validator $if, |
| Validator ...$validators, | ||
| ): Chain; | ||
|
|
||
| public static function nullOrLogicCond(Validator $logicCond, Validator $then, Validator|null $else = null): Chain; |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name $logicCond is inconsistent with the actual LogicCond constructor which uses $if as the first parameter name. This should be renamed to $if to match the validator class signature and documentation.
| public static function nullOrLogicCond(Validator $logicCond, Validator $then, Validator|null $else = null): Chain; | |
| public static function nullOrLogicCond(Validator $if, Validator $then, Validator|null $else = null): Chain; |
|
|
||
| public function notLogicAnd(Validator $validator1, Validator $validator2, Validator ...$validators): Chain; | ||
|
|
||
| public function notLogicCond(Validator $logicCond, Validator $then, Validator|null $else = null): Chain; |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name $logicCond is inconsistent with the actual LogicCond constructor which uses $if as the first parameter name. This should be renamed to $if to match the validator class signature and documentation.
| public function notLogicCond(Validator $logicCond, Validator $then, Validator|null $else = null): Chain; | |
| public function notLogicCond(Validator $if, Validator $then, Validator|null $else = null): Chain; |
You can find more information in each commit, I'm renaming as the table below describes.
This closed #1589.