3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X{ public $real = []; public function __construct(){ $this->real ['qty']= 15; } public function &setData(){ return $this->real; } } $x = new X(); $x->setData()['qty'] = 22; $x->setData()['qty2'] = 'haha yeah, we should not use refs :)'; var_dump($x->real);

preferences:
54.51 ms | 402 KiB | 5 Q