Your project must not contain invalid function or method calls 5
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_call
- // Recreate the factory closure against the clone; rebinding
- // keeps any captured value (the ctor-provided dispatcher)
- // while re-pointing the captured container.
- $this->entries[$id] = new CallableEntry(
- $id,
- Closure::bind($entry->factory, $this, self::class),
- auto: true,
- );
- }
- }
- }
- default => false,
- });
- if ($shape) {
- return $this->injectContainer(
- $this->getHandler()->handle($instance, $args)
- );
- }
- // Thrown from inside the boundary: the InvalidArgumentException
- // passes it untouched — the boundary never wraps a user-facing InvalidArgumentException.
- if ($name === 'self' || $name === 'static') {
- return $scope?->getName() ?? $name;
- }
- if ($name === 'parent') {
- return $scope?->getParentClass()?->getName() ?? $name;
- }
- return $name;
- };
- * @throws UnresolvableCallableException When the class is not instantiable (defensive).
- */
- private function instantiate(string $class, array $args): object
- {
- if ($args === []) {
- return $this->resolver->resolveInstance($class);
- }
- $reflection = new ReflectionClass($class);
- if (! $reflection->isInstantiable()) {
- * @throws UnresolvableCallableException When the class is not instantiable (defensive).
- */
- private function instantiate(string $class, array $args): object
- {
- if ($args === []) {
- return $this->resolver->resolveInstance($class);
- }
- $reflection = new ReflectionClass($class);
- if (! $reflection->isInstantiable()) {
Your project must not contain invalid instantiations 2
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_instantiation
- // trait, abstract class, enum): must name a pre-registered entry
- // (the typo catcher).
- \is_string($factory) => $this->has($factory)
- ? new AliasEntry($id, $factory)
- : throw InvalidArgumentException::unresolvableString($id, $factory),
- \is_array($factory) => new MethodPairEntry($id, $factory), // pair validation in its ctor
- // Plain objects only; invokables matched the arm above.
- // (\is_object, not `instanceof object` — the latter always
- // evaluates false: `object` is parsed as a class name.)
- \is_object($factory) => throw InvalidArgumentException::plainObjectNotAFactory($id, $factory),
- // Invalid factory of type %s.
- {
- if ($args === []) {
- return $this->resolver->resolveInstance($class);
- }
- $reflection = new ReflectionClass($class);
- if (! $reflection->isInstantiable()) {
- throw UnresolvableCallableException::notInstantiable($class);
- }