Skip to content

Do not use array_unique() in the Unique rule#1540

Merged
henriquemoody merged 1 commit into
Respect:2.4from
henriquemoody:pr/1534
May 14, 2025
Merged

Do not use array_unique() in the Unique rule#1540
henriquemoody merged 1 commit into
Respect:2.4from
henriquemoody:pr/1534

Conversation

@henriquemoody

@henriquemoody henriquemoody commented May 14, 2025

Copy link
Copy Markdown
Member

The default value of the second argument of array_unique() is SORT_STRING. This means that it converts all values to strings. That was the reason we were using SORT_REGULAR, but when using SORT_REGULAR, the strings 14.1 and 14.10 are considered the same, even though they're different.

This commit will change the Unique rule to implement its own way of detecting uniqueness. This was necessary because `array_unique() 's limitation is handling different types in the same array.

Closes #1534 & #1533

@henriquemoody henriquemoody force-pushed the pr/1534 branch 4 times, most recently from e485eff to 59be2e6 Compare May 14, 2025 12:13
The default value of the second argument of `array_unique()` is
`SORT_STRING`. This means that it converts all values to strings. That
was the reason we were using `SORT_REGULAR`, but when using `SORT_REGULAR`,
the strings `14.1` and `14.10` are considered the same, even though
they're different.

This commit will change the `Unique` rule to implement its own way of
detecting uniqueness. This was necessary because `array_unique() 's
limitation is handling different types in the same array.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
@henriquemoody henriquemoody merged commit 7f4b3b3 into Respect:2.4 May 14, 2025
6 checks passed
@henriquemoody henriquemoody deleted the pr/1534 branch May 14, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants