Regex segment local evaluation with int trait#72
Merged
matthewelwell merged 4 commits intoFlagsmith:mainfrom May 24, 2024
Merged
Regex segment local evaluation with int trait#72matthewelwell merged 4 commits intoFlagsmith:mainfrom
matthewelwell merged 4 commits intoFlagsmith:mainfrom
Conversation
953ff33 to
1843720
Compare
floranpagliai
commented
May 21, 2024
| switch ($this->operator) { | ||
| case (SegmentConditions::EQUAL): | ||
| $condition = $traitValue == $castedValue; | ||
| $condition = $traitValue === $castedValue; |
Contributor
Author
There was a problem hiding this comment.
As value are cast on line 91, might as well make a strict comparison
floranpagliai
commented
May 21, 2024
| break; | ||
| case (SegmentConditions::NOT_EQUAL): | ||
| $condition = $traitValue != $castedValue; | ||
| $condition = $traitValue !== $castedValue; |
floranpagliai
commented
May 21, 2024
| 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); |
floranpagliai
commented
May 21, 2024
| [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], |
Contributor
Author
There was a problem hiding this comment.
I added a test that check that an Integer trait value can be compared against a regex
matthewelwell
approved these changes
May 24, 2024
Contributor
matthewelwell
left a comment
There was a problem hiding this comment.
Thanks @floranpagliai !
Contributor
|
@floranpagliai I have just released this fix in v4.3.1 . |
Contributor
Author
|
Thank you so much @matthewelwell for the quick review and release! |
VincentLanglet
pushed a commit
to VincentLanglet/flagsmith-php-client
that referenced
this pull request
Jan 23, 2026
feat: add segment `IN` operator
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.
#71