如何在定义对象时重用对象属性?

How can I use $this in object key's value?

$data = (object) [
   'name'  => 'john',
   'other' => $this->name.' , wellcome',
];

what can I use for $this ?

Create a synthetic local variable, then reuse it:

$data = (object) [
    'name'  => ($name = 'john'),
    'other' => $name.' , wellcome',
 ];

Use at your own risk.

https://3v4l.org/XmVc5