-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Implement logical or expression #387
base: main
Are you sure you want to change the base?
Conversation
|
||
public function evaluate(ClassDescription $theClass, Violations $violations, string $because): void | ||
{ | ||
foreach ($this->expressions as $expression) { |
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.
question: Could we throw a logicalException or violation if none or only one expression is used? And if so, add a test method 🙏
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.
okay 🖖
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.
added with tests
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.
I'm actually not sure this is a good idea.
If we want to build automations on top of this, we will want to instantiate this with a list of expressions that are somehow inferred.
This list might have something or might be empty, in which case I think it should be irrelevant and therefore should not fail, essentially being ignored.
WDYT?
/** @var Expression[] */ | ||
private $expressions; | ||
|
||
public function __construct(array $expressions) |
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.
Could we do public function __construct(Expression ...$expressions)
?
Motivation
Allow to define logical expressions which will help with more advanced or complex expressions. Class name is not perfect but
Or
is keyword hence can't be used directly as class name.Orx
was inspired by doctrine project.If we are fine with that approach then I can implement more (like
and
).