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