- Fixed private method accessibility check to properly return empty string when method is private and inaccessible - Updated property signature resolution to preserve method metadata for nullable object properties - Modified final class check to require non-nullability for typed property receiver optimization - Added test case for nullable typed property preserving by-reference arguments when non-null - Added test case for typed property following runtime protected override or __call targetmaster
parent
137a584dc5
commit
7623d367ed
4 changed files with 121 additions and 8 deletions
@ -0,0 +1,39 @@ |
||||
--TEST-- |
||||
Nullable typed property receiver preserves by-reference arguments when non-null |
||||
--FILE-- |
||||
<?php |
||||
|
||||
final class TypedPropertyNullableTarget |
||||
{ |
||||
public function record(array &$events): void |
||||
{ |
||||
$events[] = 'recorded'; |
||||
} |
||||
} |
||||
|
||||
final class TypedPropertyNullableHolder |
||||
{ |
||||
public ?TypedPropertyNullableTarget $target; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->target = new TypedPropertyNullableTarget(); |
||||
} |
||||
|
||||
public function run(array &$events): void |
||||
{ |
||||
$this->target->record($events); |
||||
} |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
$events = []; |
||||
$holder = new TypedPropertyNullableHolder(); |
||||
$holder->run($events); |
||||
echo json_encode($events, JSON_THROW_ON_ERROR), "\n"; |
||||
} |
||||
|
||||
?> |
||||
--EXPECT-- |
||||
["recorded"] |
||||
@ -0,0 +1,54 @@ |
||||
--TEST-- |
||||
Typed property reference arguments follow the runtime protected override or __call target |
||||
--FILE-- |
||||
<?php |
||||
|
||||
class TypedPropertyProtectedBase |
||||
{ |
||||
protected function record(array &$events): void |
||||
{ |
||||
} |
||||
|
||||
public function __call(string $name, array $arguments): void |
||||
{ |
||||
$arguments[0][] = 'magic'; |
||||
} |
||||
} |
||||
|
||||
final class TypedPropertyProtectedChild extends TypedPropertyProtectedBase |
||||
{ |
||||
public function record(array &$events): void |
||||
{ |
||||
$events[] = 'child'; |
||||
} |
||||
} |
||||
|
||||
final class TypedPropertyProtectedHolder |
||||
{ |
||||
public TypedPropertyProtectedBase $target; |
||||
|
||||
public function run(array &$events): void |
||||
{ |
||||
$this->target->record($events); |
||||
} |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
$holder = new TypedPropertyProtectedHolder(); |
||||
|
||||
$magicEvents = []; |
||||
$holder->target = new TypedPropertyProtectedBase(); |
||||
$holder->run($magicEvents); |
||||
echo json_encode($magicEvents, JSON_THROW_ON_ERROR), "\n"; |
||||
|
||||
$childEvents = []; |
||||
$holder->target = new TypedPropertyProtectedChild(); |
||||
$holder->run($childEvents); |
||||
echo json_encode($childEvents, JSON_THROW_ON_ERROR), "\n"; |
||||
} |
||||
|
||||
?> |
||||
--EXPECT-- |
||||
[] |
||||
["child"] |
||||
Loading…
Reference in new issue