Strict type comparison

Bug: T248806
Change-Id: I039ab7f103bb37052987b815412b71f70643a6d2
This commit is contained in:
proc 2020-06-27 15:11:21 +01:00
parent 6274a6b657
commit a31f4e46af
No known key found for this signature in database
GPG key ID: EC6A757378AD117F
2 changed files with 11 additions and 6 deletions

View file

@ -1529,12 +1529,8 @@ class AbuseFilterParser extends AFPTransitionBase {
* @return bool
*/
protected static function equalsToAny( $string, $values ) {
$string = $string->toString();
foreach ( $values as $needle ) {
$needle = $needle->toString();
if ( $string === $needle ) {
if ( $string->equals( $needle, true ) ) {
return true;
}
}

View file

@ -1,4 +1,13 @@
equals_to_any( "foo", "bar", "foo", "pizza" ) &
equals_to_any( 15, 3, 77, 18, 15 ) &
equals_to_any( "", 3, 77, 18, 15, "duh" ) === false &
equals_to_any( "", 3, 77, 18, 15, "duh", "" )
equals_to_any( "", 3, 77, 18, 15, "duh", "" ) &
equals_to_any( true, 1, "true" ) === false &
equals_to_any( "1", 1, [ 1 ], true ) === false &
equals_to_any( [ 1, "1" ], 1, "1" ) === false &
equals_to_any( [ 1, 2, 3 ], [ 1, 2, 3 ] ) &
equals_to_any( [ 1, 2, 3 ], [ 3, 2, 1 ] ) === false &
equals_to_any( [ "foo", "bar" ], [ ] ) === false &
equals_to_any( [ "foo", "bar" ], [ "foo", "bar" ] ) &
equals_to_any( [], [] ) &
equals_to_any( [ 0 ], [] ) === false