Expand the list of types that can be cast to int

Bug: T237624
Change-Id: I2220cb8a8ec998a433a4469d7e0591ec0b4f2b12
This commit is contained in:
Daimona Eaytoy 2019-11-07 15:14:17 +01:00
parent 6a1531b7d4
commit a7b28369ea
2 changed files with 12 additions and 2 deletions

View file

@ -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();
}
/**

View file

@ -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