TomasVotruba / bladestan

PHPStan analysis for Blade templates
https://tomasvotruba.com/blog/introducing-bladestan-phpstan-analysis-of-blade-templates/
MIT License
279 stars 13 forks source link

Add Livewire support #65

Open jamesRUS52 opened 1 year ago

jamesRUS52 commented 1 year ago

the blade can access the public property of the livewire component without having to specify it as a parameter for "view" helper in the "render" method? like so

public $foo = 'bar';
public function render()
{
    return view('custom-livewire');
}

in blade {{ $foo }}

Too many like this for each livewire component

Line app/Http/Requests/Requests/Livewire/View/ActionsLivewire.php


29 Variable $foo might not be defined.
29 Variable $foo might not be defined.
29 Variable $foo might not be defined.
29 Variable $foo might not be defined.
29 Variable $foo might not be defined.
29 Variable $foo might not be defined.


AJenbo commented 1 year ago

This also holds true for components, but you can workaround it by explicitly providing the variables.

public $foo = 'bar';
public function render()
{
    return view('custom-livewire', [
        'foo' => $this->foo,
    ]);
}

On that note I would also suggest that you use $this->view() rather then view() or the context will be unclear since it will be using reflection to detect and copy the properties.

johnbacon commented 6 months ago

Any news on whether this could be solved more elegantly with Livewire v3? 🤞

AJenbo commented 6 months ago

Is there some change that makes you think it would?