Converts the computed methods of a Livewire component to use the Computed Attribute
use Livewire\Component;
class MyComponent extends Component
{
- public function getFooBarProperty()
+ #[\Livewire\Attributes\Computed]
+ public function fooBar()
{
}
}
Configure your rector.php
:
<?php
use RectorLaravel\Rector\Class_\LivewireComponentComputedMethodToComputedAttributeRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
LivewireComponentComputedMethodToComputedAttributeRector::class,
]);