parent
8d3d1febc2
commit
1c16639418
9 changed files with 119 additions and 16 deletions
@ -0,0 +1,7 @@ |
||||
<?php |
||||
|
||||
function main(): void |
||||
{ |
||||
for (; false; $i--) { |
||||
} |
||||
} |
||||
@ -0,0 +1,7 @@ |
||||
<?php |
||||
|
||||
function main(): void |
||||
{ |
||||
for (; false; $i++) { |
||||
} |
||||
} |
||||
@ -0,0 +1,6 @@ |
||||
<?php |
||||
|
||||
function main(): void |
||||
{ |
||||
--$value; |
||||
} |
||||
@ -0,0 +1,6 @@ |
||||
<?php |
||||
|
||||
function main(): void |
||||
{ |
||||
++$value; |
||||
} |
||||
@ -0,0 +1,51 @@ |
||||
--TEST-- |
||||
for post-expression increment and decrement preserve runtime semantics |
||||
--FILE-- |
||||
<?php |
||||
|
||||
final class LoopCounter |
||||
{ |
||||
public int $value = 0; |
||||
public static int $staticValue = 10; |
||||
} |
||||
|
||||
function ascending(mixed $start): void |
||||
{ |
||||
for ($i = $start; $i < 3; $i++) { |
||||
echo $i; |
||||
} |
||||
echo ':', $i, "\n"; |
||||
} |
||||
|
||||
function descending(mixed $start): void |
||||
{ |
||||
for ($i = $start; $i > 0; $i--) { |
||||
echo $i; |
||||
} |
||||
echo ':', $i, "\n"; |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
ascending(0); |
||||
descending(3); |
||||
|
||||
$object = new LoopCounter(); |
||||
$values = [0]; |
||||
for ( |
||||
$i = 0; |
||||
$i < 3; |
||||
$i++, $object->value++, LoopCounter::$staticValue--, $values[0]++ |
||||
) { |
||||
} |
||||
|
||||
var_dump($i, $object->value, LoopCounter::$staticValue, $values[0]); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
012:3 |
||||
321:0 |
||||
int(3) |
||||
int(3) |
||||
int(7) |
||||
int(3) |
||||
Loading…
Reference in new issue