3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php <?php class DependencyContainer { /** * * @var array */ private $dependencies; /** * * @param string $key * @param string $value */ public function __set($key, $value) { $this->setDependency($key, $value); } /** * * @param string $name * @return mixed */ public function __get($name) { return $this->getDependency($name); } /** * * @param string $dependency_name * @param mixed $implementation * @throws InvalidArgumentException */ public function setDependency($dependency_name, $implementation) { if(!is_string($dependency_name)) throw new InvalidArgumentException( '$dependency_name must be a string! '.gettype($dependency_name).' given!' ); $this->dependencies[$dependency_name] = $implementation; } /** * * @param string $dependency_name * @throws InvalidArgumentException Wird geworfen wenn der erste Parameter kein String ist. * @throws OutOfRangeException Wird geworfen wenn für die Dependency keine Implementierung gesetzt wurde. * @return string */ public function getDependency($dependency_name) { if(!is_string($dependency_name)) throw new InvalidArgumentException( '$dependency_name must be a string! '.gettype($dependency_name).' given!' ); if(!isset($this->dependencies[$dependency_name])) throw new OutOfRangeException('No dependency set for '.$dependency_name.'!'); if(is_callable($this->dependencies[$dependency_name])) return $this->dependencies[$dependency_name]($this); else return $this->dependencies[$dependency_name]; } } ?> ?>
Output for 5.3.0 - 5.4.5
Parse error: syntax error, unexpected '<' in /in/nIFEI on line 3
Process exited with code 255.