public function service($name, $callable) { $this[$name] = function ($c) use($callable) { static $object; if (null === $object) { $object = $callable($c); } return $object; }; }