commit
6ecc447735
14 changed files with 213 additions and 3 deletions
@ -0,0 +1,16 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
function bool_literal_identical(bool $pjax): array |
||||||
|
{ |
||||||
|
return [ |
||||||
|
true === $pjax, |
||||||
|
$pjax === true, |
||||||
|
false !== $pjax, |
||||||
|
$pjax !== false, |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
function dynamic_bool_literal_identical(mixed $value): bool |
||||||
|
{ |
||||||
|
return true === $value; |
||||||
|
} |
||||||
@ -0,0 +1,53 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use native_types; |
||||||
|
|
||||||
|
function switch_continue_in_for(): void |
||||||
|
{ |
||||||
|
for ($i = 0; $i < 2; $i++) { |
||||||
|
switch ($i) { |
||||||
|
case 0: |
||||||
|
continue; |
||||||
|
default: |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function switch_continue_in_foreach(array $values): void |
||||||
|
{ |
||||||
|
foreach ($values as $value) { |
||||||
|
switch ($value) { |
||||||
|
case 0: |
||||||
|
continue; |
||||||
|
default: |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function switch_continue_in_while(): void |
||||||
|
{ |
||||||
|
$i = 0; |
||||||
|
while ($i++ < 2) { |
||||||
|
switch ($i) { |
||||||
|
case 1: |
||||||
|
continue; |
||||||
|
default: |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function switch_continue_in_do_while(): void |
||||||
|
{ |
||||||
|
$i = 0; |
||||||
|
do { |
||||||
|
switch ($i++) { |
||||||
|
case 0: |
||||||
|
continue; |
||||||
|
default: |
||||||
|
break; |
||||||
|
} |
||||||
|
} while ($i < 2); |
||||||
|
} |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
function standalone_dynamic_switch_continue(mixed $value): void |
||||||
|
{ |
||||||
|
switch ($value) { |
||||||
|
case 1: |
||||||
|
continue; |
||||||
|
default: |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use native_types; |
||||||
|
|
||||||
|
function standalone_switch_continue(int $value): void |
||||||
|
{ |
||||||
|
switch ($value) { |
||||||
|
case 1: |
||||||
|
continue; |
||||||
|
default: |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class LoopControlTest extends \BaseTest |
||||||
|
{ |
||||||
|
public function testContinueInStandaloneSwitchIsRejected(): void |
||||||
|
{ |
||||||
|
$this->exec( |
||||||
|
'Cannot continue outside loop', |
||||||
|
'control-flow/standalone-switch-continue.php', |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public function testContinueInStandaloneDynamicSwitchIsRejected(): void |
||||||
|
{ |
||||||
|
$this->exec( |
||||||
|
'Cannot continue outside loop', |
||||||
|
'control-flow/standalone-dynamic-switch-continue.php', |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public function testContinueInSwitchNestedInLoopsIsAllowed(): void |
||||||
|
{ |
||||||
|
$this->compile('control-flow/loop-switch-continue.php'); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,34 @@ |
|||||||
|
--TEST-- |
||||||
|
Boolean literals on either side of strict comparisons |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
function compare_bool_literal(bool $pjax): void |
||||||
|
{ |
||||||
|
var_dump(true === $pjax); |
||||||
|
var_dump($pjax === true); |
||||||
|
var_dump(false === $pjax); |
||||||
|
var_dump($pjax === false); |
||||||
|
var_dump(true !== $pjax); |
||||||
|
var_dump($pjax !== true); |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
compare_bool_literal(true); |
||||||
|
compare_bool_literal(false); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
|
bool(false) |
||||||
|
bool(false) |
||||||
|
bool(false) |
||||||
|
bool(false) |
||||||
|
bool(false) |
||||||
|
bool(false) |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
@ -1 +1 @@ |
|||||||
1096 |
1096 |
||||||
|
|||||||
Loading…
Reference in new issue