- Added nativeBoolLiteral method to convert PHP boolean literals to C++ bool - Updated parseCompareExpr to use native boolean literals for bool type - Ensured strict comparisons between booleans use true/false instead of php::true_/php::false_ - Added test case for boolean literal identical comparisons - Created compiler test to verify native boolean operand usage - Added test file with boolean literal comparison examplespull/43/head
parent
9a7de8ee31
commit
8f2e63b9f7
4 changed files with 88 additions and 0 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,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) |
||||||
Loading…
Reference in new issue