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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners