TypePHP 编译器 https://swoole.com/aot/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

35 lines
520 B

--TEST--
Unary minus applies to the whole operand expression
--FILE--
<?php
declare(strict_types=1);
function pick(int $a, int $b, int $c): int
{
return -($a ? $b : $c);
}
function doubleNegate(int $a): int
{
return - -$a;
}
function main(): void
{
var_dump(pick(1, 2, 3));
var_dump(pick(0, 2, 3));
var_dump(doubleNegate(5));
var_dump(doubleNegate(-5));
$x = 4;
var_dump(-($x ?: 7));
$y = 0;
var_dump(-($y ?: 7));
}
?>
--EXPECT--
int(-2)
int(-3)
int(5)
int(-5)
int(-4)
int(-7)