Configure Laravel Pint to collapse empty constructor bodies with promoted properties onto a single line for compact PHP 8 class declarations.
PHP 8 constructor property promotion eliminates explicit property declarations and assignments. However, empty constructor body braces {} can still take up 3 vertical lines.
Laravel Pint formats empty promoted constructors into clean single-line declarations:
class DatabaseNotificationSent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
- public function __construct(public DatabaseNotification $notification)
- {
- }
+ public function __construct(public DatabaseNotification $notification) {}
}
- Compacts class definitions without losing readability
- Enforced automatically across your project via
./vendor/bin/pint - Keeps event, job, and DTO constructor signatures minimal
Related Tips
View all tips →Refresh and Pessimistically Lock Models with refreshForUpdate() in Laravel 13.27
Laravel 13.27 adds refreshForUpdate(), reloading an existing model instance in-place with fresh database attributes while acquiring an exclusive FOR UPDATE row lock.
Scope Pivot Table Queries with Closures in wherePivot() in Laravel 13.26
Laravel 13.26 allows wherePivot() and orWherePivot() to accept closures, enabling direct reuse of local scopes defined on custom Pivot models.