-
Notifications
You must be signed in to change notification settings - Fork 11
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
Regex segment local evaluation with int trait #72
Conversation
953ff33
to
1843720
Compare
@@ -101,7 +101,7 @@ public function matchesTraitValue($traitValue): bool | |||
|
|||
switch ($this->operator) { | |||
case (SegmentConditions::EQUAL): | |||
$condition = $traitValue == $castedValue; | |||
$condition = $traitValue === $castedValue; |
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.
As value are cast on line 91, might as well make a strict comparison
@@ -116,7 +116,7 @@ public function matchesTraitValue($traitValue): bool | |||
$condition = $traitValue <= $castedValue; | |||
break; | |||
case (SegmentConditions::NOT_EQUAL): | |||
$condition = $traitValue != $castedValue; | |||
$condition = $traitValue !== $castedValue; |
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.
Same here
@@ -130,7 +130,7 @@ public function matchesTraitValue($traitValue): bool | |||
break; | |||
case (SegmentConditions::IN): | |||
if (in_array($traitValueType, ['string', 'integer'])) { | |||
$condition = in_array((string) $traitValue, explode(',', (string) $this->value)); | |||
$condition = in_array((string) $traitValue, explode(',', (string) $this->value), true); |
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.
Same
@@ -74,6 +74,7 @@ public function conditionParametersTraitValues() | |||
[SegmentConditions::REGEX, 'foo', '[a-z]+', true], | |||
[SegmentConditions::REGEX, 'FOO', '[a-z]+', false], | |||
[SegmentConditions::REGEX, '1.2.3', '\\d', true], | |||
[SegmentConditions::REGEX, 123, '^\\d*[13579]$', true], |
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 added a test that check that an Integer trait value can be compared against a regex
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.
Thanks @floranpagliai !
@floranpagliai I have just released this fix in v4.3.1 . |
Thank you so much @matthewelwell for the quick review and release! |
#71