3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace WFPKSYS\System\Traits\Configuration; { trait SupportSystemConfiguration { protected $_supportSystemConfiguration; public function getSupportSystemConfiguration() : \WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration { return $this->_supportSystemConfiguration; } public function setSupportSystemConfiguration( \WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration $supportSystemConfiguration ) : void { $this->_supportSystemConfiguration = $supportSystemConfiguration; } } } namespace WFPKSYS\SupportSystem\Models\Configuration; { 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\SupportSystem\Models; { class Foo { use \WFPKSYS\System\Traits\Configuration\SupportSystemConfiguration; public function __construct(\WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration $supportSystemConfig) { $this->setSupportSystemConfiguration( $supportSystemConfig ); } public function displayCheck() : void { #do something that doesnt return anything } } } namespace WFPKSYS\SupportSystem\Models; { class Bar { use \WFPKSYS\System\Traits\Configuration\SupportSystemConfiguration; public function __construct(\WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration $supportSystemConfig) {$this->setSupportSystemConfiguration( $supportSystemConfig );} public function displayCheck() : void { #do something that doesnt return anything } } } namespace WFPKSYS\SupportSystem\Models; { class Fuzz { use \WFPKSYS\System\Traits\Configuration\SupportSystemConfiguration; public function __construct(\WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration $supportSystemConfig ) { $this->setSupportSystemConfiguration( $supportSystemConfig ); } public function performCheck() : string { $objFoo = new \WFPKSYS\SupportSystem\Models\Foo( $this->getSupportSystemConfiguration() ); $objBar = new \WFPKSYS\SupportSystem\Models\Bar( $this->getSupportSystemConfiguration() ); $objFoo->displayCheck(); $objBar->displayCheck(); return "completed"; } } } $objSupportSystemConfiguration = new \WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration(); $objFuzz = new \WFPKSYS\SupportSystem\Models\Fuzz( $objSupportSystemConfiguration ); echo $objFuzz->performCheck();
Output for hhvm-3.21.3 - 3.22.0, 7.1.0 - 7.3.0beta1
completed
Output for 7.0.0 - 7.0.24
Fatal error: Uncaught TypeError: Return value of WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration::setDb_Name() must be an instance of WFPKSYS\SupportSystem\Models\Configuration\void, none returned in /in/5AcD7:30 Stack trace: #0 /in/5AcD7(25): WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration->setDb_Name('MyTestDb') #1 /in/5AcD7(95): WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration->__construct() #2 {main} thrown in /in/5AcD7 on line 30
Process exited with code 255.
Output for hhvm-3.18.5
Fatal error: Uncaught TypeError: Value returned from method WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration::setDb_Name() must be of type WFPKSYS\SupportSystem\Models\Configuration\void, null given in /in/5AcD7:30 Stack trace: #0 /in/5AcD7(25): WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration->setDb_Name() #1 /in/5AcD7(95): WFPKSYS\SupportSystem\Models\Configuration\SupportSystemConfiguration->__construct() #2 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/5AcD7 on line 10
Process exited with code 255.