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); }}