Your project must not contain invalid instantiations 4

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

in src/Container.php, line 317
  1. // Invokable shapes first — the is_object guard is load-bearing: a class-string naming
  2. // an invokable class must fall through to the ClassName arm (build, never invoke).
  3. FactoryEntry::isValid($factory) => new FactoryEntry($id, $factory),
  4. CallableEntry::isValid($factory) => new CallableEntry($id, $factory),
  5. ClassNameEntry::isValid($factory) => new ClassNameEntry($id, $factory),
  6. MethodPairEntry::isValid($factory) => new MethodPairEntry($id, $factory),
    Parameter #2 $factory of class Projek\Container\Entry\MethodPairEntry constructor expects array{class-string<T of object>|T of object, non-empty-string}|non-empty-string, array{class-string<T of object>|T of object, string}|(callable(): mixed)|Projek\Container\EntryFactory|string given.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. // any other string — incl. non-buildable type symbols (interface, trait, abstract
  8. // class, enum): must name a pre-registered entry (the typo catcher).
  9. \is_string($factory) => $this->has($factory)
  10. ? new AliasEntry($id, $factory)
  11. : throw InvalidArgumentException::unresolvableString($id, $factory),
in src/Container.php, line 314
  1. // statement's begin line when a paren group survives to the `;` —
  2. // without them the closing `});` line can never be marked covered.
  3. $this->entries[$id] = (match (true) {
  4. // Invokable shapes first — the is_object guard is load-bearing: a class-string naming
  5. // an invokable class must fall through to the ClassName arm (build, never invoke).
  6. FactoryEntry::isValid($factory) => new FactoryEntry($id, $factory),
    Parameter #2 $factory of class Projek\Container\Entry\FactoryEntry constructor expects Projek\Container\EntryFactory, (callable)|list<string|T of object>|Projek\Container\EntryFactory|string given.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. CallableEntry::isValid($factory) => new CallableEntry($id, $factory),
  8. ClassNameEntry::isValid($factory) => new ClassNameEntry($id, $factory),
  9. MethodPairEntry::isValid($factory) => new MethodPairEntry($id, $factory),
  10. // any other string — incl. non-buildable type symbols (interface, trait, abstract
  11. // class, enum): must name a pre-registered entry (the typo catcher).
in src/Container.php, line 316
  1. $this->entries[$id] = (match (true) {
  2. // Invokable shapes first — the is_object guard is load-bearing: a class-string naming
  3. // an invokable class must fall through to the ClassName arm (build, never invoke).
  4. FactoryEntry::isValid($factory) => new FactoryEntry($id, $factory),
  5. CallableEntry::isValid($factory) => new CallableEntry($id, $factory),
  6. ClassNameEntry::isValid($factory) => new ClassNameEntry($id, $factory),
    Parameter #2 $factory of class Projek\Container\Entry\ClassNameEntry constructor expects class-string, (callable)|list<string|T of object>|Projek\Container\EntryFactory|string given.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. MethodPairEntry::isValid($factory) => new MethodPairEntry($id, $factory),
  8. // any other string — incl. non-buildable type symbols (interface, trait, abstract
  9. // class, enum): must name a pre-registered entry (the typo catcher).
  10. \is_string($factory) => $this->has($factory)
  11. ? new AliasEntry($id, $factory)
in src/Container.php, line 315
  1. // without them the closing `});` line can never be marked covered.
  2. $this->entries[$id] = (match (true) {
  3. // Invokable shapes first — the is_object guard is load-bearing: a class-string naming
  4. // an invokable class must fall through to the ClassName arm (build, never invoke).
  5. FactoryEntry::isValid($factory) => new FactoryEntry($id, $factory),
  6. CallableEntry::isValid($factory) => new CallableEntry($id, $factory),
    Parameter #2 $factory of class Projek\Container\Entry\CallableEntry constructor expects callable-string|object, array{class-string<T of object>|T of object, string}|(callable(): mixed)|Projek\Container\EntryFactory|string given.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. ClassNameEntry::isValid($factory) => new ClassNameEntry($id, $factory),
  8. MethodPairEntry::isValid($factory) => new MethodPairEntry($id, $factory),
  9. // any other string — incl. non-buildable type symbols (interface, trait, abstract
  10. // class, enum): must name a pre-registered entry (the typo catcher).
  11. \is_string($factory) => $this->has($factory)

Your project should not use invalid parameter and return typehints 4

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

  1. /**
  2. * @template T of object
  3. *
  4. * @assert-if-true string|array{class-string<T>|T, string} $factory
  5. */
  6. public static function isValid(mixed $factory): bool
    Template type T of method Projek\Container\Entry\MethodPairEntry::isValid() is not referenced in a parameter.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. {
  8. return (\is_string($factory) && \str_contains($factory, '::'))
  9. || (\is_array($factory) && count($factory) === 2);
  10. }
  1. /**
  2. * @template T of object
  3. *
  4. * @assert-if-true class-string<T> $factory
  5. */
  6. public static function isValid(mixed $factory): bool
    Template type T of method Projek\Container\Entry\ClassNameEntry::isValid() is not referenced in a parameter.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. {
  8. return \is_string($factory) && \class_exists($factory)
  9. && (new ReflectionClass($factory))->isInstantiable();
  10. }
  1. /**
  2. * @template T of object
  3. *
  4. * @assert-if-true EntryFactory $factory
  5. */
  6. public static function isValid(mixed $factory): bool
    Template type T of method Projek\Container\Entry\FactoryEntry::isValid() is not referenced in a parameter.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. {
  8. return $factory instanceof EntryFactory;
  9. }
  10. /**
  1. /**
  2. * @template T of object
  3. *
  4. * @assert-if-true Closure|callable-string|callable $factory
  5. */
  6. public static function isValid(mixed $factory): bool
    Template type T of method Projek\Container\Entry\CallableEntry::isValid() is not referenced in a parameter.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. {
  8. return $factory instanceof Closure
  9. || (\is_object($factory) && \method_exists($factory, '__invoke'))
  10. || (\is_string($factory) && \function_exists($factory));
  11. }