Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MahmoudAdelAli's avatar

Deprecated assign method in php 8.2

I reading the php 8.2 features and i found this part ''' class User { public $name; }

$user = new User(); $user->last_name = 'Doe'; // Deprecated notice

$user = new stdClass(); $user->last_name = 'Doe'; // Still allowed

'''

So we in laravel use this dynamic properties to assign the values , how we 'll use it now ?

0 likes
2 replies
jlrdw's avatar

I don't understand this:

$user = new stdClass(); $user->last_name = 'Doe';

Normally you get it from request. Can you give a reference where

$user = new User(); $user->last_name = 'Doe';

is deprecated

From Docs:

    public function store(Request $request)
    {
        // Validate the request...
 
        $flight = new Flight;
 
        $flight->name = $request->name;
 
        $flight->save();
    }

Leave off the ().

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

It is only deprecated if you don't use __set(), which laravel does. It's a magic method to properly handle these. So there isn't a problem with models

2 likes

Please or to participate in this conversation.