mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 13:46:48 +00:00
Expand the list of types that can be cast to int
Bug: T237624 Change-Id: I2220cb8a8ec998a433a4469d7e0591ec0b4f2b12
This commit is contained in:
parent
6a1531b7d4
commit
a7b28369ea
|
@ -431,7 +431,13 @@ class AFPData {
|
|||
* @return int|float
|
||||
*/
|
||||
public function toNumber() {
|
||||
return $this->type === self::DINT ? $this->toInt() : $this->toFloat();
|
||||
// Types that can be cast to int
|
||||
$intLikeTypes = [
|
||||
self::DINT,
|
||||
self::DBOOL,
|
||||
self::DNULL
|
||||
];
|
||||
return in_array( $this->type, $intLikeTypes, true ) ? $this->toInt() : $this->toFloat();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,4 +10,8 @@ float( [false] ) === 1.0 &
|
|||
float( [1,2,3,4,5,6] ) === 6.0 &
|
||||
int([]) === 0 &
|
||||
int( [false] ) === 1 &
|
||||
int( [1,2,3,4,5,6] ) === 6
|
||||
int( [1,2,3,4,5,6] ) === 6 &
|
||||
true + true === 2 &
|
||||
null - null === 0 &
|
||||
true * false === 0 &
|
||||
163 % true === 0
|
||||
|
|
Loading…
Reference in a new issue