3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Error { private $_errors; private function _init(){ $this->_errors = (object) [ 'small' => 'Small mistake' ]; } public function getError(){ var_dump($this->_errors); } } class Test { use Error; public function __construct(){ $this->_errors = $this->_init(); } } $obj = new Test(); $obj->getError();

preferences:
56.05 ms | 402 KiB | 5 Q