- Change temporary variable type to Variant for PHP arrays to prevent undefined C++ behavior - Add methodNameToStr helper that treats 'self' and 'static' as ordinary member names - Replace identifierToStr with methodNameToStr for method calls to respect lexical rules - Update nullsafe access trait to use proper method name parsing - Add test case for array element compound arithmetic overflow handling - Add test case for nullsafe chain preserving typed method returnsmaster v0.6.1
parent
70d13a3601
commit
65d3710a61
6 changed files with 82 additions and 9 deletions
@ -0,0 +1,23 @@ |
||||
--TEST-- |
||||
Array element compound arithmetic promotes overflowing integers to float |
||||
--FILE-- |
||||
<?php |
||||
declare(strict_types=1); |
||||
|
||||
function main(): void |
||||
{ |
||||
$maximum = PHP_INT_MAX; |
||||
$large = intdiv(PHP_INT_MAX, 2) + 1; |
||||
$values = ['add' => $maximum, 'multiply' => $large]; |
||||
|
||||
$values['add'] += 1; |
||||
$values['multiply'] *= 2; |
||||
|
||||
var_dump($values['add'], $values['multiply']); |
||||
echo gettype($values['add']), ',', gettype($values['multiply']), "\n"; |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
float(9.223372036854776E+18) |
||||
float(9.223372036854776E+18) |
||||
double,double |
||||
@ -0,0 +1,37 @@ |
||||
--TEST-- |
||||
Nullsafe chain preserves typed method returns and member names |
||||
--FILE-- |
||||
<?php |
||||
declare(strict_types=1); |
||||
|
||||
final class NullsafeTypedReturnLeaf |
||||
{ |
||||
public string $value = 'forward'; |
||||
} |
||||
|
||||
final class NullsafeTypedReturnNode |
||||
{ |
||||
public NullsafeTypedReturnLeaf $leaf; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->leaf = new NullsafeTypedReturnLeaf(); |
||||
} |
||||
|
||||
public function self(): NullsafeTypedReturnNode |
||||
{ |
||||
return $this; |
||||
} |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
$target = new NullsafeTypedReturnNode(); |
||||
$weak = WeakReference::create($target); |
||||
echo $target->self()->leaf->value, "\n"; |
||||
echo $weak->get()?->self()?->leaf->value, "\n"; |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
forward |
||||
forward |
||||
Loading…
Reference in new issue