parent
9ad213ea64
commit
312a796498
8 changed files with 180 additions and 28 deletions
@ -0,0 +1,39 @@ |
|||||||
|
--TEST-- |
||||||
|
Closure calls preserve strict builtin argument validation on dynamic fallback |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
declare(strict_types=1); |
||||||
|
|
||||||
|
function mixedInt(): mixed |
||||||
|
{ |
||||||
|
return 1; |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
$calls = [ |
||||||
|
'arrow' => static fn() => in_array('1', [1], mixedInt()), |
||||||
|
'closure' => static function (): float { |
||||||
|
return sin('1'); |
||||||
|
}, |
||||||
|
'round' => static fn() => round('1.25'), |
||||||
|
'floor' => static function (): float { |
||||||
|
return floor('1.5'); |
||||||
|
}, |
||||||
|
]; |
||||||
|
|
||||||
|
foreach ($calls as $name => $call) { |
||||||
|
try { |
||||||
|
$call(); |
||||||
|
echo $name, "=missing TypeError\n"; |
||||||
|
} catch (TypeError $error) { |
||||||
|
echo $name, "=TypeError\n"; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
arrow=TypeError |
||||||
|
closure=TypeError |
||||||
|
round=TypeError |
||||||
|
floor=TypeError |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
--TEST-- |
||||||
|
Optimized numeric builtins preserve strict union parameter validation |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
declare(strict_types=1); |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
var_dump(abs(-3)); |
||||||
|
var_dump(sqrt(9)); |
||||||
|
var_dump(floor(1.75)); |
||||||
|
var_dump(ceil(1.25)); |
||||||
|
var_dump(round(1.25, 1)); |
||||||
|
|
||||||
|
try { |
||||||
|
abs('3'); |
||||||
|
echo "abs=missing TypeError\n"; |
||||||
|
} catch (TypeError $error) { |
||||||
|
echo "abs=TypeError\n"; |
||||||
|
} |
||||||
|
try { |
||||||
|
sqrt('9'); |
||||||
|
echo "sqrt=missing TypeError\n"; |
||||||
|
} catch (TypeError $error) { |
||||||
|
echo "sqrt=TypeError\n"; |
||||||
|
} |
||||||
|
try { |
||||||
|
floor('1.75'); |
||||||
|
echo "floor=missing TypeError\n"; |
||||||
|
} catch (TypeError $error) { |
||||||
|
echo "floor=TypeError\n"; |
||||||
|
} |
||||||
|
try { |
||||||
|
ceil('1.25'); |
||||||
|
echo "ceil=missing TypeError\n"; |
||||||
|
} catch (TypeError $error) { |
||||||
|
echo "ceil=TypeError\n"; |
||||||
|
} |
||||||
|
try { |
||||||
|
round('1.25'); |
||||||
|
echo "round=missing TypeError\n"; |
||||||
|
} catch (TypeError $error) { |
||||||
|
echo "round=TypeError\n"; |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
int(3) |
||||||
|
float(3) |
||||||
|
float(1) |
||||||
|
float(2) |
||||||
|
float(1.3) |
||||||
|
abs=TypeError |
||||||
|
sqrt=TypeError |
||||||
|
floor=TypeError |
||||||
|
ceil=TypeError |
||||||
|
round=TypeError |
||||||
Loading…
Reference in new issue