Your project should not use invalid return types 2

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

  1. $args[$position] = $param->getDefaultValue();
  2. }
  3. }
  4. return $args;
    Method Projek\Container\Resolver::resolveArgs() should return list<mixed> but returns array<int, mixed>.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  5. }
  6. /**
  7. * @param \ReflectionParameter $param
  8. * @return string
  1. * When $className is not instantiable or its constructor depends on non-exists container entry.
  2. */
  3. private function createInstance(string $className, array $args = []): object
  4. {
  5. if ($this->container->has($className)) {
  6. return $this->container->get($className);
    Method Projek\Container\Resolver::createInstance() should return object but returns mixed.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. }
  8. if (! \class_exists($className)) {
  9. throw new Exception(
  10. \sprintf('Cannot resolve an entry or class named "%s" of non-exists', $className)

Your project must not contain invalid instantiations 3

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

  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.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    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. /** @var array<string> */
  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 given.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    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.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    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)

Your project must not contain invalid function or method calls 6

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

  1. }
  2. try {
  3. $params[] = $this->resolveArgs($ref, $args);
  4. return $ref->invokeArgs(...$params);
    Parameter #1 $args|object of method ReflectionFunction::invokeArgs() expects array|object|null, mixed given.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  5. } catch (Exception $err) {
  6. throw new Exception($caller . '(): ' . $err->getMessage(), $err->getPrevious());
  7. }
  8. }
in src/Container.php, line 125
  1. : $factory;
  2. $entry = $this->resolver->resolve($this->factories[$id]);
  3. if (\is_object($entry) && $this->isInjectable($entry)) {
  4. $entry->setContainer($this);
    Call to an undefined method object::setContainer().
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  5. }
  6. $this->entries[$id] = $entry;
  7. if (isset($this->handledEntries[$id])) {
in src/Container.php, line 194
  1. if ($callback) {
  2. $instance = $callback($instance) ?: $instance;
  3. }
  4. return $this->resolver->handle($instance, $args);
    Parameter #1 $entry of method Projek\Container\Resolver::handle() expects callable(): mixed, mixed given.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  5. }
  6. /**
  7. * Extending an entry.
  8. *
in src/Container.php, line 88
  1. if (\is_object($entry) && ! \is_callable($entry)) {
  2. return $entry;
  3. }
  4. return $this->handledEntries[$id] = $this->resolver->handle($entry);
    Parameter #1 $entry of method Projek\Container\Resolver::handle() expects callable(): mixed, mixed given.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  5. }
  6. /**
  7. * Determine whether the **entry** is registered.
  8. *
in src/Container.php, line 51
  1. self::class => $this,
  2. ContainerInterface::class => $this,
  3. ];
  4. foreach ($entries as $id => $instance) {
  5. $this->set($id, $instance);
    Parameter #2 $factory of method Projek\Container::set() expects callable(): mixed, mixed given.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  6. }
  7. }
  8. /**
  9. * Create new resolver instance when get cloned.
in src/Container.php, line 221
  1. );
  2. }
  3. $extended = $this->make($callback, [$entry]);
  4. if (! \is_a($extended, $class = \get_class($entry))) {
    Parameter #1 $object_or_string of function is_a expects object, mixed given.
    Time to fix: about 9 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  5. throw new Container\Exception(
  6. \sprintf('Argument #2 callback must be returns of type "%s"', $class)
  7. );
  8. }

Your project gitignore file should not contain user-specific files 3

More information: https://insight.symfony.com/what-we-analyse/git.user_specific_ignored_file

in .gitignore, line 6
  1. # Generic
  2. # --------------------------
  3. Thumbs.db
  4. Desktop.ini
  5. .directory
  6. .DS_Store
    .DS_Store is user-specific and should not appear in a project .gitignore. Consider adding it to the user global .gitignore instead.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. ._*
  8. *.cache
  9. *.crt
  10. *.log
  11. *.old
in .gitignore, line 33
  1. vendor
  2. yarn.lock
  3. # IDE Project Configurations
  4. # --------------------------
  5. .idea
    .idea is user-specific and should not appear in a project .gitignore. Consider adding it to the user global .gitignore instead.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  6. .settings
  7. .vscode
  8. .project
  9. *.sublime-*
  • feryardiant

    Ignored on Tue, 22 Oct 2024 15:49:28 GMT
in .gitignore, line 3
  1. # Generic
  2. # --------------------------
  3. Thumbs.db
    Thumbs.db is user-specific and should not appear in a project .gitignore. Consider adding it to the user global .gitignore instead.
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  4. Desktop.ini
  5. .directory
  6. .DS_Store
  7. ._*
  8. *.cache
  • feryardiant

    Ignored on Tue, 22 Oct 2024 15:49:25 GMT

Interfaces names should end with "Interface"

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

  1. * Any class implements this interface could have instance of ContainerInterface
  2. * injected automtically.
  3. *
  4. * @package Projek\Container
  5. */
  6. interface ContainerAware
    Interface {{ name }} should be named {{ name }}Interface for better clarity.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. {
  8. /**
  9. * Assign a container to the instance.
  10. *
  11. * @param \Projek\Container $container
  • feryardiant

    Ignored on Tue, 22 Oct 2024 15:49:18 GMT

Your project should use dedicated PHP string functions 2

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

  1. * @throws \Projek\Container\InvalidArgumentException
  2. */
  3. public function resolve($entry, array $args = [])
  4. {
  5. if (\is_string($entry) && ! \function_exists($entry)) {
  6. $entry = false === \strpos($entry, '::')
    Consider replacing strpos() with str_contains() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. ? $this->createInstance($entry, $args)
  8. : \explode('::', $entry);
  9. }
  10. if (\is_array($entry) && \is_string($entry[0])) {
  1. * @throws \Projek\Container\Exception
  2. * @throws \Projek\Container\InvalidArgumentException
  3. */
  4. private function createCallableReflection($callable)
  5. {
  6. if (\is_string($callable) && false !== \strpos($callable, '::')) {
    Consider replacing strpos() with str_contains() for improved readability.
    Time to fix: about 1 hour
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  7. /** @var array<string> */
  8. $callable = \explode('::', $callable);
  9. }
  10. if (! \is_array($callable)) {

Your project uses legacy callable syntax instead of first-class callable syntax

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

  1. if (! \is_callable($entry)) {
  2. return $entry;
  3. }
  4. // Otherwise convert it to closure.
  5. $entry = \Closure::fromCallable($entry);
    Use the first-class callable syntax ($this->method(...))
    Time to fix: about 15 minutes
    Read doc Permalink Copy Prompt
    Last edited by Fery Wardiyanto
  6. }
  7. $ref = $this->createCallableReflection($entry);
  8. $caller = $ref->getName();
  9. $params = [];