diff options
-rw-r--r-- | lib/cast_to_int.php | 2 | ||||
-rw-r--r-- | psalm.xml | 1 | ||||
-rw-r--r-- | tests/unit/RandomIntTest.php | 4 |
3 files changed, 4 insertions, 3 deletions
diff --git a/lib/cast_to_int.php b/lib/cast_to_int.php index 138a025..5a57a55 100644 --- a/lib/cast_to_int.php +++ b/lib/cast_to_int.php @@ -49,7 +49,7 @@ if (!is_callable('RandomCompat_intval')) { if (is_int($number) || is_float($number)) { $number += 0; } elseif (is_numeric($number)) { - $number = (int) $number; + $number += 0; } if ( @@ -8,6 +8,7 @@ <directory name="lib" /> </projectFiles> <issueHandlers> + <InvalidOperand errorLevel="info" /> <UndefinedConstant errorLevel="info" /> <MissingReturnType errorLevel="info" /> </issueHandlers> diff --git a/tests/unit/RandomIntTest.php b/tests/unit/RandomIntTest.php index dd96e81..c8cbb0d 100644 --- a/tests/unit/RandomIntTest.php +++ b/tests/unit/RandomIntTest.php @@ -33,8 +33,8 @@ class RandomIntTest extends PHPUnit_Framework_TestCase $this->assertTrue($integers[6] === 0); $this->assertTrue($integers[7] >= $half_neg_max && $integers[7] <= PHP_INT_MAX); $this->assertTrue($integers[8] >= 0 && $integers[8] <= 255); - $this->assertTrue($integers[9] === -4); - $this->assertTrue($integers[10] === 1337000); + $this->assertSame($integers[9], -4); + $this->assertSame($integers[10], 1337000); try { $h = random_int("2147483648", "2147483647"); |