1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Files
archived-php-src/ext/standard/tests/math/fmod_basic.phpt
Nikita Popov b10416a652 Deprecate passing null to non-nullable arg of internal function
This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.

This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)

RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

Closes GH-6475.
2021-02-11 21:46:13 +01:00

182 lines
2.2 KiB
PHP

--TEST--
Test fmod() - basic function test fmod()
--INI--
precision=14
--FILE--
<?php
$values1 = array(234,
-234,
23.45e1,
-23.45e1,
0xEA,
0352,
"234",
"234.5",
"23.45e1",
true,
false);
$values2 = array(2,
-2,
2.3e1,
-2.3e1,
0x2,
02,
"2",
"2.3",
"2.3e1",
true,
false);
for ($i = 0; $i < count($values1); $i++) {
echo "\niteration ", $i, "\n";
for ($j = 0; $j < count($values2); $j++) {
$res = fmod($values1[$i], $values2[$j]);
var_dump($res);
}
}
?>
--EXPECT--
iteration 0
float(0)
float(0)
float(4)
float(4)
float(0)
float(0)
float(0)
float(1.700000000000018)
float(4)
float(0)
float(NAN)
iteration 1
float(-0)
float(-0)
float(-4)
float(-4)
float(-0)
float(-0)
float(-0)
float(-1.700000000000018)
float(-4)
float(-0)
float(NAN)
iteration 2
float(0.5)
float(0.5)
float(4.5)
float(4.5)
float(0.5)
float(0.5)
float(0.5)
float(2.200000000000018)
float(4.5)
float(0.5)
float(NAN)
iteration 3
float(-0.5)
float(-0.5)
float(-4.5)
float(-4.5)
float(-0.5)
float(-0.5)
float(-0.5)
float(-2.200000000000018)
float(-4.5)
float(-0.5)
float(NAN)
iteration 4
float(0)
float(0)
float(4)
float(4)
float(0)
float(0)
float(0)
float(1.700000000000018)
float(4)
float(0)
float(NAN)
iteration 5
float(0)
float(0)
float(4)
float(4)
float(0)
float(0)
float(0)
float(1.700000000000018)
float(4)
float(0)
float(NAN)
iteration 6
float(0)
float(0)
float(4)
float(4)
float(0)
float(0)
float(0)
float(1.700000000000018)
float(4)
float(0)
float(NAN)
iteration 7
float(0.5)
float(0.5)
float(4.5)
float(4.5)
float(0.5)
float(0.5)
float(0.5)
float(2.200000000000018)
float(4.5)
float(0.5)
float(NAN)
iteration 8
float(0.5)
float(0.5)
float(4.5)
float(4.5)
float(0.5)
float(0.5)
float(0.5)
float(2.200000000000018)
float(4.5)
float(0.5)
float(NAN)
iteration 9
float(1)
float(1)
float(1)
float(1)
float(1)
float(1)
float(1)
float(1)
float(1)
float(0)
float(NAN)
iteration 10
float(0)
float(0)
float(0)
float(0)
float(0)
float(0)
float(0)
float(0)
float(0)
float(0)
float(NAN)