3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace WFPKSYS; { trait SupportSystemConfiguration { protected $_supportSystemConfiguration; public function getSupportSystemConfiguration() : \WFPKSYS\SupportSystemConfiguration { return $this->_supportSystemConfiguration; } public function setSupportSystemConfiguration( \WFPKSYS\SupportSystemConfiguration $supportSystemConfiguration ) : void { $this->_supportSystemConfiguration = $supportSystemConfiguration; } } } namespace WFPKSYS; { class SupportSystemConfiguration { private $_db_Name; public function __construct() {$this->setDb_Name( "MyTestDb" );} public function getDb_Name() : string { return $this->_db_Name; } public function setDb_Name( string $db_Name ) : void { $this->_db_Name = $db_Name; } } } namespace WFPKSYS\Set2; { class Foo { use \WFPKSYS\SupportSystemConfiguration; public function __construct(\WFPKSYS\SupportSystemConfiguration $supportSystemConfig) { $this->setSupportSystemConfiguration( $supportSystemConfig ); } public function displayCheck() : void { #do something that doesnt return anything } } } namespace WFPKSYS\Set2; { class Bar { use \WFPKSYS\SupportSystemConfiguration; public function __construct(\WFPKSYS\SupportSystemConfiguration $supportSystemConfig) {$this->setSupportSystemConfiguration( $supportSystemConfig );} public function displayCheck() : void { #do something that doesnt return anything } } } namespace WFPKSYS\Set3; { class Fuzz { use \WFPKSYS\SupportSystemConfiguration; public function __construct(\WFPKSYS\SupportSystemConfiguration $supportSystemConfig ) { $this->setSupportSystemConfiguration( $supportSystemConfig ); } public function performCheck() : string { $objFoo = new \WFPKSYS\Set1\Foo( $this->getSupportSystemConfiguration() ); $objBar = new \WFPKSYS\Set2\Bar( $this->getSupportSystemConfiguration() ); $objFoo->displayCheck(); $objBar->displayCheck(); return "completed"; } } } $objSupportSystemConfiguration = new \WFPKSYS\SupportSystemConfiguration(); $objFuzz = new \WFPKSYS\Set3\Fuzz( $objSupportSystemConfiguration ); echo $objFuzz->performCheck();
Output for 7.0.0 - 7.3.0beta1
Fatal error: Cannot declare class WFPKSYS\SupportSystemConfiguration, because the name is already in use in /in/4Q511 on line 20
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Class already declared: WFPKSYS\SupportSystemConfiguration in /in/4Q511:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: Class already declared: WFPKSYS\SupportSystemConfiguration in /in/4Q511:20 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/4Q511 on line 10
Process exited with code 255.