3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Container// implements \ArrayAccess { protected $values; public function __construct (array $values = array()) { $this->values = $values; } /* ... */ } class ServiceContainer extends Container { protected static $instance; protected $storage; protected function __construct($storage) { $this->storage = $storage; } public static function init(ServiceStorageInterface $storage) { return static::$instance = new static($storage); } public static function getInstance() { if ( ! isset(static::$instance)) { throw new Exception('ServiceContainer is not initialized'); } return static::$instance; } }
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.33, 7.4.3 - 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.6
Output for 5.3.0 - 5.3.14, 5.4.0 - 5.4.4
Fatal error: Access level to ServiceContainer::__construct() must be public (as in class Container) in /in/pB1mb on line 35
Process exited with code 255.

preferences:
114.51 ms | 402 KiB | 160 Q