3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace WFPKSYS\Traits; { 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( string $dbName ) {$this->setDb_Name( $dbName );} public function getDb_Name() : string { return $this->_db_Name; } public function setDb_Name( string $db_Name ) : void { $this->_db_Name = $db_Name; } } } namespace WFPKSYS\Set1; { class Foo { use \WFPKSYS\Traits\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\Traits\SupportSystemConfiguration; public function __construct(\WFPKSYS\SupportSystemConfiguration $supportSystemConfig ) { $this->setSupportSystemConfiguration( $supportSystemConfig ); } public function performCheck() : string { $objFoo = new \WFPKSYS\Set1\Foo( $this->getSupportSystemConfiguration() ); $objFoo->displayCheck(); return "completed"; } } } $objSupportSystemConfiguration = new \WFPKSYS\SupportSystemConfiguration( "MyTestDb" ); $objFuzz = new \WFPKSYS\Set3\Fuzz( $objSupportSystemConfiguration ); echo $objFuzz->performCheck();
Output for hhvm-3.21.3 - 3.22.0, 7.1.0 - 7.3.0rc3
completed
Output for 7.0.0 - 7.0.24
Fatal error: Uncaught TypeError: Return value of WFPKSYS\SupportSystemConfiguration::setDb_Name() must be an instance of WFPKSYS\void, none returned in /in/CGJZt:23 Stack trace: #0 /in/CGJZt(19): WFPKSYS\SupportSystemConfiguration->setDb_Name('MyTestDb') #1 /in/CGJZt(62): WFPKSYS\SupportSystemConfiguration->__construct('MyTestDb') #2 {main} thrown in /in/CGJZt on line 23
Process exited with code 255.
Output for hhvm-3.18.5
Fatal error: Uncaught TypeError: Value returned from method WFPKSYS\SupportSystemConfiguration::setDb_Name() must be of type WFPKSYS\void, null given in /in/CGJZt:23 Stack trace: #0 /in/CGJZt(19): WFPKSYS\SupportSystemConfiguration->setDb_Name() #1 /in/CGJZt(62): WFPKSYS\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/CGJZt on line 7
Process exited with code 255.