mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 21:53:35 +00:00
Merge "Expand the list of types that can be cast to int"
This commit is contained in:
commit
7ff4b95aec
|
@ -440,7 +440,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