Your project must not contain invalid function or method calls 6
- 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.
- *
- if ($callback) {
- $instance = $callback($instance) ?: $instance;
- }
- return $this->resolver->handle($instance, $args);
- }
- /**
- * Extending an entry.
- *
- throw new Container\Exception(
- \sprintf('Cannot extending a non-object or a callable entry of "%s"', $id)
- );
- }
- $extended = $this->make($callback, [$entry]);
- if (! \is_a($extended, $class = \get_class($entry))) {
- throw new Container\Exception(
- \sprintf('Argument #2 callback must be returns of type "%s"', $class)
- );
- ? \explode('::', $entry)
- : $this->createInstance($entry, $args);
- }
- if (\is_array($entry) && \is_string($entry[0])) {
- $entry[0] = $this->resolve($entry[0], $args);
- }
- if (\is_object($entry) || \is_callable($entry)) {
- return $entry;
- }
- // 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());
- }
- }
Your project should not use invalid return types 2
- 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.
- *
- $args[$position] = $param->getDefaultValue();
- }
- }
- return $args;
- }
- }
Your project must not contain invalid instantiations
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_instantiation
- 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)
Your project should not use invalid parameter and return typehints 3
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_typehint
- /**
- * Create instance.
- *
- * @param Container $container
- */
- public function __construct(ContainerInterface $container)
- {
- $this->container = $container;
- }
- /**
- * Assign a container to the instance.
- *
- * @param \Projek\Container $container
- * @return static
- */
- public function setContainer(\Projek\Container $container): ContainerAware;
- /**
- * Retrieve container instance or the instance of registered service.
- *
- * If no parameter given, this method should returns instance of `Projek\Container`
- protected $container = null;
- /**
- * @see ContainerAware::setContainer()
- */
- public function setContainer(\Projek\Container $container): ContainerAware
- {
- $this->container = $container;
- return $this;
- }