3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Entity { class File { private $foo = 'top'; } class FileInbox { public $file; public function setFile(File $file) { $this->file = $file; } } } namespace Entity\FileInbox { class File { private $foo = 'nested'; } } namespace Test { use Entity\FileInbox; $fileInbox = new FileInbox(); $fileInbox->setFile(new File()); var_dump($fileInbox->file->foo); }

preferences:
52.16 ms | 402 KiB | 5 Q