Array functions with strict comparison
| From: | Andreas Hennings | Date: | Sat, 11 Nov 2023 18:05:04 +0000 |
| Subject: | Array functions with strict comparison | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-121657@lists.php.net to get a copy of this message | ||
Hello internals,
I noticed that array functions like array_diff(), array_intersect()
etc use weak comparison.
E.g.
array_diff([0, '', false, null], [null])
only leaves [0].
This makes these functions useless for a number of applications.
Also it can lead to unpleasant surprises, if a developer is not aware
of the silent type casting.
For BC reasons. the existing functions have to remain as they are.
Also, most of them don't really have a place for an extra parameter to
tell them to use strict comparison.
So, as a solution, we would have to introduce new functions.
Has anything like this been proposed in the past?
How would we name the new functions?
Should they be functions or static methods like StrictArray::diff(..)?
I could post an RFC but I want to get some feedback first.
Kind regards
Andreas