pixelfederation/swoole-bundle

View on GitHub
src/Bridge/Symfony/Container/ContainerModifier.php

Summary

Maintainability
C
1 day
Test Coverage

File ContainerModifier.php has 320 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace K911\Swoole\Bridge\Symfony\Container;
Severity: Minor
Found in src/Bridge/Symfony/Container/ContainerModifier.php - About 3 hrs to fix

    Method generateOverriddenDoInExtension has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function generateOverriddenDoInExtension(
            Filesystem $fs,
            string $containerDir,
            string $fileToLoad,
            string $class,
    Severity: Major
    Found in src/Bridge/Symfony/Container/ContainerModifier.php - About 2 hrs to fix

      Method overrideGeneratedContainer has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function overrideGeneratedContainer(ReflectionClass $reflContainer, string $cacheDir, bool $isDebug): void
          {
              $fs = new Filesystem();
              $containerFqcn = $reflContainer->getName();
              $overriddenFqcn = $containerFqcn.'_Overridden';
      Severity: Minor
      Found in src/Bridge/Symfony/Container/ContainerModifier.php - About 1 hr to fix

        Method generateLazyGetter has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function generateLazyGetter(string $methodName, array $internals): string
            {
                $sharedCheck = PHP_EOL;
        
                if (!empty($internals)) {
        Severity: Minor
        Found in src/Bridge/Symfony/Container/ContainerModifier.php - About 1 hr to fix

          Method overrideCachedEntrypoint has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private static function overrideCachedEntrypoint(Filesystem $fs, string $cacheDir, string $containerClass, string $overriddenFqcn, bool $isDebug): void
          Severity: Minor
          Found in src/Bridge/Symfony/Container/ContainerModifier.php - About 35 mins to fix

            Method generateOverriddenDoInExtension has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    Filesystem $fs,
                    string $containerDir,
                    string $fileToLoad,
                    string $class,
                    string $namespace
            Severity: Minor
            Found in src/Bridge/Symfony/Container/ContainerModifier.php - About 35 mins to fix

              Function overrideGeneratedContainer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private static function overrideGeneratedContainer(ReflectionClass $reflContainer, string $cacheDir, bool $isDebug): void
                  {
                      $fs = new Filesystem();
                      $containerFqcn = $reflContainer->getName();
                      $overriddenFqcn = $containerFqcn.'_Overridden';
              Severity: Minor
              Found in src/Bridge/Symfony/Container/ContainerModifier.php - About 35 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Missing class import via use statement (line '187', column '23').
              Open

                          throw new \RuntimeException('Generated cached entry point file is missing.');

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

              A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 18 and the first side effect is on line 14.
              Open

              <?php

              Possible parse error: class missing opening or closing brace
              Open

              final class ContainerModifier

              Possible parse error: class missing opening or closing brace
              Open

              final class ContainerModifier

              Line indented incorrectly; expected 0 spaces, found 4
              Open

                  public static function modifyContainer(BlockingContainer $container, string $cacheDir, bool $isDebug): void

              Line indented incorrectly; expected 0 spaces, found 4
              Open

                  private static function overrideGeneratedContainer(ReflectionClass $reflContainer, string $cacheDir, bool $isDebug): void

              Line indented incorrectly; expected 0 spaces, found 4
              Open

                  private static $alreadyOverridden = [];

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      }

              Line indented incorrectly; expected 0 spaces, found 4
              Open

                  }

              Line indented incorrectly; expected 4 spaces, found 12
              Open

                          if (isset($ignoredMethods[$methodName]) || !str_starts_with($methodName, 'get')) {

              Line indented incorrectly; expected 4 spaces, found 8
              Open

                      if (isset(self::$alreadyOverridden[$reflContainer->getName()])) {

              Line indented incorrectly; expected 4 spaces, found 12
              Open

                          }

              Line indented incorrectly; expected 0 spaces, found 8
              Open

                      if (file_exists($overriddenFile)) {

              Line indented incorrectly; expected 0 spaces, found 8
              Open

                      }

              Line indented incorrectly; expected 0 spaces, found 8
              Open

                      }

              Line indented incorrectly; expected 0 spaces, found 8
              Open

                      }

              Line indented incorrectly; expected 0 spaces, found 8
              Open

                      if (!$reflContainer->hasMethod('createProxy')) {

              Line indented incorrectly; expected 0 spaces, found 8
              Open

                      foreach ($methods as $method) {

              There are no issues that match your filters.

              Category
              Status