try{ if(!$r = $this->container->getReflectionClass($class)){ if(null === $class){ thrownewRuntimeException(sprintf('Invalid service "%s": the class is not set.', $this->currentId)); }
thrownewRuntimeException(sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class)); } }catch(\ReflectionException $e){ thrownewRuntimeException(sprintf('Invalid service "%s": ', $this->currentId).lcfirst($e->getMessage())); } if(!$r = $r->getConstructor()){ if($required){ thrownewRuntimeException(sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, sprintf($class !== $this->currentId ? ' "%s"' : '', $class))); } }elseif(!$r->isPublic()){ thrownewRuntimeException(sprintf('Invalid service "%s": ', $this->currentId).sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class).' must be public.'); }
/**
* Returns the method to use to construct an object. This method must be either
* the object constructor or static.
*/ protectedfunctiongetConstructor(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes): ?\ReflectionMethod { return$reflectionClass->getConstructor(); }
/**
* Instantiates an object using constructor parameters when needed.
*
* This method also allows to denormalize data into an existing object if
* it is present in the context with the object_to_populate. This object
* is removed from the context before being returned to avoid side effects
* when recursively normalizing an object graph.
*
* @return object
*
* @throws RuntimeException
* @throws MissingConstructorArgumentsException
*/
'missing temporary directory' => [\UPLOAD_ERR_NO_TMP_DIR, '/The file could not be uploaded\./'], 'write failure' => [\UPLOAD_ERR_CANT_WRITE, '/The file could not be uploaded\./'], 'stopped by extension' => [\UPLOAD_ERR_EXTENSION, '/The file could not be uploaded\./'], ]; }
return$value; } if(!$reflectionClass = $this->container->getReflectionClass($value->getClass(), false)){ $this->container->log($this, sprintf('Skipping service "%s": Class or interface "%s" cannot be loaded.', $this->currentId, $value->getClass()));