Your project must not contain invalid function or method calls 3

More information: https://insight.symfony.com/what-we-analyse/php.invalid_call

in src/Container.php, line 191
  1. if ($condition) {
  2. $instance = $condition($instance) ?: $instance;
  3. }
  4. return $this->resolver->handle($instance, $args);
    Parameter #1 $callable of method Projek\Container\Resolver::handle() expects callable(): mixed, (callable(): mixed)|object given.
    Last edited by Fery Wardiyanto
  5. }
  6. /**
  7. * Extending an entry.
  8. *
  1. * @param string $message
  2. * @param \Throwable|null $prev
  3. */
  4. public function __construct(string $message, ?\Throwable $prev = null)
  5. {
  6. parent::__construct($message, $prev?->getCode() ?: 0, $prev);
    Parameter #2 $code of method Exception::__construct() expects int, int|string given.
    Last edited by Fery Wardiyanto
  7. }
  8. }
  1. $this->resolveArgs($ref, $args)
  2. );
  3. }
  4. return $ref->invokeArgs(
  5. $ref->isStatic() && ! \is_object($callable[0]) ? null : $callable[0],
    Parameter #1 $object of method ReflectionMethod::invokeArgs() expects object|null, mixed given.
    Last edited by Fery Wardiyanto
  6. $this->resolveArgs($ref, $args)
  7. );
  8. } catch (UnresolvableArgumentException $err) {
  9. throw new Exception($err->getCaller() . '(): ' . $err->getMessage(), $err->getPrevious());
  10. }

Your project should not use invalid return types 2

More information: https://insight.symfony.com/what-we-analyse/php.invalid_return_typehint

in src/Container.php, line 191
  1. if ($condition) {
  2. $instance = $condition($instance) ?: $instance;
  3. }
  4. return $this->resolver->handle($instance, $args);
    Method Projek\Container::make() should return object but returns mixed.
    Last edited by Fery Wardiyanto
  5. }
  6. /**
  7. * Extending an entry.
  8. *
  1. if (\is_array($entry) && \is_string($entry[0])) {
  2. $entry[0] = $this->resolve($entry[0], $args);
  3. }
  4. return $entry;
    Method Projek\Container\Resolver::resolve() should return (callable(): mixed)|object but returns mixed.
    Last edited by Fery Wardiyanto
  5. }
  6. /**
  7. * Handle callable.
  8. *

Your project must not contain invalid instantiations 4

More information: https://insight.symfony.com/what-we-analyse/php.invalid_instantiation

  1. if (\is_string($callable) && \str_contains($callable, '::')) {
  2. $callable = \explode('::', $callable);
  3. }
  4. if (! \is_array($callable)) {
  5. return new ReflectionFunction($callable);
    Parameter #1 $function of class ReflectionFunction constructor expects Closure|string, (callable(): mixed)|object|string given.
    Last edited by Fery Wardiyanto
  6. }
  7. try {
  8. $ref = new ReflectionMethod($callable[0], $callable[1]);
  9. } catch (ReflectionException $err) {
  1. if (! \is_array($callable)) {
  2. return new ReflectionFunction($callable);
  3. }
  4. try {
  5. $ref = new ReflectionMethod($callable[0], $callable[1]);
    Parameter #2 $method of class ReflectionMethod constructor expects string, mixed given.
    Last edited by Fery Wardiyanto
  6. } catch (ReflectionException $err) {
  7. throw new InvalidArgumentException($err->getMessage(), $err->getCode(), $err);
  8. }
  9. // If trying to statically call a non-static method (at least on PHP 7.x)
  1. if (! \is_array($callable)) {
  2. return new ReflectionFunction($callable);
  3. }
  4. try {
  5. $ref = new ReflectionMethod($callable[0], $callable[1]);
    Parameter #1 $objectOrMethod of class ReflectionMethod constructor expects object|string, mixed given.
    Last edited by Fery Wardiyanto
  6. } catch (ReflectionException $err) {
  7. throw new InvalidArgumentException($err->getMessage(), $err->getCode(), $err);
  8. }
  9. // If trying to statically call a non-static method (at least on PHP 7.x)
  1. if (! $param->isOptional()) {
  2. throw new UnresolvableArgumentException(
  3. ++$position,
  4. $param->getName(),
  5. $err->getName(),
  6. $ref,
    Parameter #4 $ref of class Projek\Container\UnresolvableArgumentException constructor expects ReflectionFunction|ReflectionMethod, ReflectionFunctionAbstract given.
    Last edited by Fery Wardiyanto
  7. $err
  8. );
  9. }
  10. $args[$position] = $param->getDefaultValue();

Your project should not contain unused code 4

More information: https://insight.symfony.com/what-we-analyse/php.unused_local_variable_or_private_member

  1. * @param string $name
  2. * @param string $entry
  3. * @param \Throwable|null $prev
  4. */
  5. public function __construct(
  6. private int $position,
    Property Projek\Container\UnresolvableArgumentException::$position is never read, only written.
    Time to fix: about 15 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. private string $name,
  8. private string $entry,
  9. private ReflectionFunction|ReflectionMethod $ref,
  10. ?\Throwable $prev = null,
  11. ) {
  1. * @param string $entry
  2. * @param \Throwable|null $prev
  3. */
  4. public function __construct(
  5. private int $position,
  6. private string $name,
    Property Projek\Container\UnresolvableArgumentException::$name is never read, only written.
    Time to fix: about 15 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. private string $entry,
  8. private ReflectionFunction|ReflectionMethod $ref,
  9. ?\Throwable $prev = null,
  10. ) {
  11. $this->caller = $ref instanceof ReflectionMethod
  1. * @param \Throwable|null $prev
  2. */
  3. public function __construct(
  4. private int $position,
  5. private string $name,
  6. private string $entry,
    Property Projek\Container\UnresolvableArgumentException::$entry is never read, only written.
    Time to fix: about 15 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. private ReflectionFunction|ReflectionMethod $ref,
  8. ?\Throwable $prev = null,
  9. ) {
  10. $this->caller = $ref instanceof ReflectionMethod
  11. ? $ref->getDeclaringClass()->getName() . '::' . $ref->getName()
  1. */
  2. public function __construct(
  3. private int $position,
  4. private string $name,
  5. private string $entry,
  6. private ReflectionFunction|ReflectionMethod $ref,
    Property Projek\Container\UnresolvableArgumentException::$ref is never read, only written.
    Time to fix: about 15 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. ?\Throwable $prev = null,
  8. ) {
  9. $this->caller = $ref instanceof ReflectionMethod
  10. ? $ref->getDeclaringClass()->getName() . '::' . $ref->getName()
  11. : $ref->getName();