protected function getScopedFooService() { if (!isset($this->scopedServices['foo'])) { throw new \RuntimeException('invalid call'); } return $this->services['scoped_foo'] = $this->scopedServices['foo']['scoped_foo'] = new \stdClass(); }