PHP 8.1 made me delete these 30 lines of code

The less code you write, the less you have to maintain

Read-only properties

// This is allowed
$handler->user->name = 'John Doe';
// This is NOT allowed
$handler->user = new User;

Initializing with “new"

// This is allowed
public function __construct(
public User $user = new User('John')
)
// This is NOT allowed
public function __construct(
public User $user = User::make('John')
}

Graphic Designer graduate. Full Stack Web Developer. Retired Tech & Gaming Editor.