Validation issue refactoring (5961) - #4151
Merged
stracker-phil merged 16 commits intoMar 26, 2026
Merged
Conversation
stracker-phil
requested review from
AlexP11223,
Dinamiko,
Narek13,
danieldudzic,
hmouhtar and
mmaymo
as code owners
March 6, 2026 17:18
Narek13
reviewed
Mar 9, 2026
Narek13
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for working on this @stracker-phil.
A question: did you consider adding a factory instead of these many classes?
class BusinessRuleFactory {
public function create_rule( string $type ): BusinessRuleErrorIssue
{
return new BusinessRuleErrorIssue( $type );
}
}
////consuming
$business_rule_factory = new BusinessRuleFactory();
$business_rule_factory->create_rule( ContextBusinessRuleIssue::CUSTOMER_ACCOUNT_SUSPENDED );Or can you please explain why can't we group them under some enum or interface?
Collaborator
Author
|
@Narek13 great question, and the decision to use classes instead of a property is intentional at the time of creating the PR, my thoughts were: Downside of enum passed via constructor
Benefits of classes:
But honestly, the number of extra files does not really provide real benefits. I will remove those classes again and replace them with an enum, or specific create methods, like This would be good case for an ADR or internal follow-up discussion. |
stracker-phil
merged commit Mar 26, 2026
99683e5
into
dev/PCP-4891-agentic-commerce
10 of 20 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refactors the validation layer for the Store Sync module around three base classes:
ValidationIssue,IssueContext, andResolutionOption:Builder Pattern
All three classes use a fluent builder pattern instead of constructor arguments:
New IssueContext
Introduces a typed
IssueContexthierarchy replacing previously untyped dynamic arrays. Six concrete category classes (ShippingErrorContext,CouponErrorContext, etc.) each expose named factory methods for their specific issue variants:ResolutionOptionmoved and refactoredResolutionOptionmoved fromSchema/intoValidation/Resolution/. It also has the fluent builder pattern and simplified factory methods:ValidationIssuerefactoredValidationIssueis now a single concrete class. Named factory methods replace the previous abstract/child class pattern, with documented "When to use" guidance per variant: