Conversation
Extract shared view data into the component scope so that variables
registered via View::share() are accessible without manually calling
$__env->shared('key').
Shared data is extracted after component data (EXTR_SKIP) so that
props and slots always take priority over shared variables, matching
Blade's array_merge($shared, $data) behavior.
|
/benchmark attributes |
|
/benchmark no-attributes |
|
/benchmark class |
|
/benchmark forwarding |
|
/benchmark aware |
|
/benchmark slot, |
Benchmark Result: Attributes
Median of 10 attempts, 5000 iterations x 10 rounds, 23.39s total To run a specific benchmark, comment |
Benchmark Result: No Attributes
Median of 10 attempts, 5000 iterations x 10 rounds, 18.98s total To run a specific benchmark, comment |
Benchmark Result: Class
Median of 10 attempts, 5000 iterations x 10 rounds, 32.47s total To run a specific benchmark, comment |
Benchmark Result: Default
Median of 10 attempts (* = outlier, excluded from result), 5000 iterations x 10 rounds, 45.67s total To run a specific benchmark, comment |
Benchmark Result: Forwarding
Median of 10 attempts (* = outlier, excluded from result), 5000 iterations x 10 rounds, 93.14s total To run a specific benchmark, comment |
Benchmark Result: Aware
Median of 10 attempts, 5000 iterations x 10 rounds, 100.99s total To run a specific benchmark, comment |
Removes the "Auto-injecting
View::share()variables is not supported" limitation.After all the recent performance improvements, I figured we could add this support with minor impact.
Before
Shared variables required manual access:
After
Shared variables are available directly, matching Blade:
How it works
One line added to the generated function body:
This runs after slots and component data have already been extracted, so the priority order is: slots > props > shared, matching Blade's
array_merge($shared, $data)semantics. A prop passed to a component always wins over a shared variable with the same name.