3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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; use Entity\FileInbox\File; $fileInbox = new FileInbox(); $fileInbox->setFile(new File()); var_dump($fileInbox->file->foo); }
based on JLLVB
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Argument 1 passed to Entity\FileInbox::setFile() must be an instance of Entity\File, instance of Entity\FileInbox\File given, called in /in/iLbni on line 28 and defined in /in/iLbni:11 Stack trace: #0 /in/iLbni(28): Entity\FileInbox->setFile(Object(Entity\FileInbox\File)) #1 {main} thrown in /in/iLbni on line 11
Process exited with code 255.
Output for 5.3.18 - 5.6.28
Catchable fatal error: Argument 1 passed to Entity\FileInbox::setFile() must be an instance of Entity\File, instance of Entity\FileInbox\File given, called in /in/iLbni on line 28 and defined in /in/iLbni on line 11
Process exited with code 255.