Your project must not contain invalid function or method calls 7
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_call
- if (\is_object($entry) && ! \is_callable($entry)) {
- return $entry;
- }
- return $this->handledEntries[$id] = $this->resolver->handle($entry);
- }
- /**
- * Determine whether the **entry** is registered.
- *
- $this->factories[$id] = \is_object($factory) && ! ($factory instanceof \Closure)
- ? \get_class($factory)
- : $factory;
- $entry = $this->resolver->resolve($this->factories[$id]);
- if (\is_object($entry) && $this->isInjectable($entry)) {
- $entry->setContainer($this);
- }
- if ($callback) {
- $instance = $callback($instance) ?: $instance;
- }
- return $this->resolver->handle($instance, $args);
- }
- /**
- * Extending an entry.
- *
- public function resolve($entry, array $args = [])
- {
- if (\is_string($entry) && ! \function_exists($entry)) {
- $entry = \str_contains($entry, '::')
- ? \explode('::', $entry)
- : $this->createInstance($entry, $args);
- }
- if (\is_array($entry) && \is_string($entry[0])) {
- $entry[0] = $this->resolve($entry[0], $args);
- }
- // Otherwise convert it to closure.
- $callable = \Closure::fromCallable($callable);
- }
- $ref = $this->createCallableReflection($callable);
- $caller = $ref->getName();
- /** @var array{object|null, TArgs} */
- $params = [];
- }
- try {
- $params[] = $this->resolveArgs($ref, $args);
- return $ref->invokeArgs(...$params);
- } catch (Exception $err) {
- throw new Exception($caller . '(): ' . $err->getMessage(), $err->getPrevious());
- }
- }
- );
- }
- try {
- $args = ($constructor = $ref->getConstructor())
- ? $this->resolveArgs($constructor, $ref->hasMethod('__invoke') ? [] : $args)
- : [];
- return $ref->newInstanceArgs($args);
- } catch (Exception $err) {
- throw new Exception($className . '::__construct(): ' . $err->getMessage(), $err->getPrevious());
Your project should not use invalid return types 3
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_return_typehint
- if ($callback) {
- $instance = $callback($instance) ?: $instance;
- }
- return $this->resolver->handle($instance, $args);
- }
- /**
- * Extending an entry.
- *
- * When $className is not instantiable or its constructor depends on non-exists container entry.
- */
- private function createInstance(string $className, array $args = []): object
- {
- if ($this->container->has($className)) {
- return $this->container->get($className);
- }
- if (! \class_exists($className)) {
- throw new Exception(
- \sprintf('Cannot resolve an entry or class named "%s" of non-exists', $className)
- $args[$position] = $param->getDefaultValue();
- }
- }
- return $args;
- }
- }
Your project must not contain invalid instantiations 3
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_instantiation
- /** @var array{class-string, string} */
- $callable = \explode('::', $callable);
- }
- if (! \is_array($callable)) {
- return new \ReflectionFunction($callable);
- }
- try {
- $ref = new \ReflectionMethod($callable[0], $callable[1]);
- } catch (\ReflectionException $err) {
- if (! \is_array($callable)) {
- return new \ReflectionFunction($callable);
- }
- try {
- $ref = new \ReflectionMethod($callable[0], $callable[1]);
- } catch (\ReflectionException $err) {
- throw new InvalidArgumentException($err->getMessage(), $err->getCode(), $err);
- }
- // If trying to statically call a non-static method (at least on PHP 7.x)
- if (! \is_array($callable)) {
- return new \ReflectionFunction($callable);
- }
- try {
- $ref = new \ReflectionMethod($callable[0], $callable[1]);
- } catch (\ReflectionException $err) {
- throw new InvalidArgumentException($err->getMessage(), $err->getCode(), $err);
- }
- // If trying to statically call a non-static method (at least on PHP 7.x)