3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace Entity { use Entity\FileInbox\File; 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; use Entity\FileInbox\File; $fileInbox = new FileInbox(); $fileInbox->setFile(new File()); var_dump($fileInbox->file->foo); }
based on 2IZFM
Output for 5.3.18 - 5.6.28, 7.0.20 - 7.2.0
Fatal error: Cannot declare class Entity\File because the name is already in use in /in/DkEXp on line 6
Process exited with code 255.
Output for 7.0.0 - 7.0.6
Fatal error: Uncaught Error: Cannot access private property Entity\FileInbox\File::$foo in /in/DkEXp:31 Stack trace: #0 {main} thrown in /in/DkEXp on line 31
Process exited with code 255.