Rector instantly upgrades and refactors the PHP code of your application. This package is a Rector extension developed by the Laravel community.

class: RectorLaravel\Rector\ClassMethod\AddArgumentDefaultValueRector use Rector\Config\RectorConfig; use RectorLaravel\Rector\ClassMethod\AddArgumentDefaultValueRector; use RectorLaravel\ValueObject\AddArgumentDefaultValue; return static function (RectorConfig $rectorConfig): void { $rectorConfig->ruleWithConfiguration(AddArgumentDefaultValueRector::class, [ AddArgumentDefaultValueRector::ADDED_ARGUMENTS => [ new AddArgumentDefaultValue('SomeClass', 'someMethod', 0, false), ], ]); }; class SomeClass { - public function someMethod($value) + public function someMethod($value = false) { }} Add generic return type to relations in child of Illuminate\Database\Eloquent\Model class: RectorLaravel\Rector\ClassMethod\AddGenericReturnTypeToRelationsRector use App\Account; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; class User extends Model { + /** @return HasMany */ public function accounts(): HasMany { return $this->hasMany(Account::class); }} Add new $guard argument to Illuminate\Auth\Events\Login class: RectorLaravel\Rector\New_\AddGuardToLoginEventRector use Illuminate\Auth\Events\Login; final class SomeClass { public function run(): void { - $loginEvent = new Login('user', false); + $guard = config('auth.defaults.guard'); + $loginEvent = new Login($guard, 'user', false); }}
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners