3v4l.org

run code in 300+ PHP versions simultaneously
<?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 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
completed
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 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.

preferences:
128.28 ms | 402 KiB | 179 Q