- Introduce $allowLocalClassEntryHoisting flag to control class entry hoisting behavior - Add withoutLocalClassEntryHoisting method to temporarily disable hoisting during callback execution - Modify getLocalClassEntryPtr to respect hoisting allowance when checking process stable class - Wrap parameter default parsing in withoutLocalClassEntryHoisting to prevent unwanted hoisting - Update array initialization in Preprocessor to use hoisting control for literal arrays - Add support for new expressions in array parameter defaults with proper class resolution - Include tests for array parameter defaults containing new expressions - Add tests for runtime array property defaults with copy-on-write behavior - Rename generated request array default symbols with 'typephp_' prefix for consistency - Update documentation to reflect implemented optimizations and remaining costsmaster
parent
cb1e12f11f
commit
4713a58b06
7 changed files with 147 additions and 41 deletions
@ -0,0 +1,22 @@ |
|||||||
|
--TEST-- |
||||||
|
Array parameter defaults containing new expressions resolve classes inside the helper |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
class ArrayDefaultObject |
||||||
|
{ |
||||||
|
public int $value = 42; |
||||||
|
} |
||||||
|
|
||||||
|
function readArrayDefault(array $values = [new ArrayDefaultObject()]): void |
||||||
|
{ |
||||||
|
var_dump($values[0]->value); |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
readArrayDefault(); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
int(42) |
||||||
@ -0,0 +1,48 @@ |
|||||||
|
--TEST-- |
||||||
|
Runtime array property defaults share request templates and separate on write |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
class RuntimeArrayCowDefaults |
||||||
|
{ |
||||||
|
public array $options = [ |
||||||
|
'timeout' => 10, |
||||||
|
'headers' => ['Accept' => 'application/json'], |
||||||
|
'list' => [1, 2], |
||||||
|
]; |
||||||
|
public array $tags = ['default']; |
||||||
|
} |
||||||
|
|
||||||
|
function mutateDynamicObject(object $object): void |
||||||
|
{ |
||||||
|
$object->options['headers']['Accept'] = 'text/plain'; |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
$first = new RuntimeArrayCowDefaults(); |
||||||
|
$second = new RuntimeArrayCowDefaults(); |
||||||
|
$third = new RuntimeArrayCowDefaults(); |
||||||
|
|
||||||
|
$first->options['timeout'] = 30; |
||||||
|
$first->options['headers']['X-Test'] = 'one'; |
||||||
|
$first->tags[] = 'first'; |
||||||
|
|
||||||
|
$timeout =& $second->options['timeout']; |
||||||
|
$timeout = 20; |
||||||
|
unset($second->options['list'][0]); |
||||||
|
|
||||||
|
mutateDynamicObject($third); |
||||||
|
|
||||||
|
$fresh = new RuntimeArrayCowDefaults(); |
||||||
|
echo json_encode([$first->options, $first->tags], JSON_UNESCAPED_SLASHES), "\n"; |
||||||
|
echo json_encode([$second->options, $second->tags], JSON_UNESCAPED_SLASHES), "\n"; |
||||||
|
echo json_encode([$third->options, $third->tags], JSON_UNESCAPED_SLASHES), "\n"; |
||||||
|
echo json_encode([$fresh->options, $fresh->tags], JSON_UNESCAPED_SLASHES), "\n"; |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
[{"timeout":30,"headers":{"Accept":"application/json","X-Test":"one"},"list":[1,2]},["default","first"]] |
||||||
|
[{"timeout":20,"headers":{"Accept":"application/json"},"list":{"1":2}},["default"]] |
||||||
|
[{"timeout":10,"headers":{"Accept":"text/plain"},"list":[1,2]},["default"]] |
||||||
|
[{"timeout":10,"headers":{"Accept":"application/json"},"list":[1,2]},["default"]] |
||||||
Loading…
Reference in new issue