pug-php/pug-symfony

View on GitHub
src/Pug/Symfony/Traits/HelpersHandler.php

Summary

Maintainability
D
1 day
Test Coverage

Function interpolateTwigFunctions has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    protected function interpolateTwigFunctions(string $code): string
    {
        $tokens = array_slice(token_get_all('<?php '.$code), 1);
        $output = '';
        $count = count($tokens);
Severity: Minor
Found in src/Pug/Symfony/Traits/HelpersHandler.php - About 5 hrs 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

File HelpersHandler.php has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Pug\Symfony\Traits;

use Closure;
Severity: Minor
Found in src/Pug/Symfony/Traits/HelpersHandler.php - About 2 hrs to fix

    Method interpolateTwigFunctions has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function interpolateTwigFunctions(string $code): string
        {
            $tokens = array_slice(token_get_all('<?php '.$code), 1);
            $output = '';
            $count = count($tokens);
    Severity: Major
    Found in src/Pug/Symfony/Traits/HelpersHandler.php - About 2 hrs to fix

      Method getRendererOptions has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getRendererOptions(): array
          {
              if ($this->options === null) {
                  $environment = $this->kernel->getEnvironment();
                  $projectDirectory = $this->kernel->getProjectDir();
      Severity: Minor
      Found in src/Pug/Symfony/Traits/HelpersHandler.php - About 1 hr to fix

        Method copyTwigFunctions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function copyTwigFunctions(): void
            {
                $this->twigHelpers = [];
                $twig = $this->getTwig();
                $twig->env = $twig;
        Severity: Minor
        Found in src/Pug/Symfony/Traits/HelpersHandler.php - About 1 hr to fix

          Function getRendererOptions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function getRendererOptions(): array
              {
                  if ($this->options === null) {
                      $environment = $this->kernel->getEnvironment();
                      $projectDirectory = $this->kernel->getProjectDir();
          Severity: Minor
          Found in src/Pug/Symfony/Traits/HelpersHandler.php - About 55 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

          Avoid deeply nested control flow statements.
          Open

                                  switch ($tokens[$index]) {
                                      case '(':
                                          $opening++;
                                          $argumentNeedInterpolation = true;
                                          $argument .= '(';
          Severity: Major
          Found in src/Pug/Symfony/Traits/HelpersHandler.php - About 45 mins to fix

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

                protected function copyTwigFunctions(): void
                {
                    $this->twigHelpers = [];
                    $twig = $this->getTwig();
                    $twig->env = $twig;
            Severity: Minor
            Found in src/Pug/Symfony/Traits/HelpersHandler.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

            The method getRendererOptions() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
            Open

                protected function getRendererOptions(): array
                {
                    if ($this->options === null) {
                        $environment = $this->kernel->getEnvironment();
                        $projectDirectory = $this->kernel->getProjectDir();

            CyclomaticComplexity

            Since: 0.1

            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

            Example

            // Cyclomatic Complexity = 11
            class Foo {
            1   public function example() {
            2       if ($a == $b) {
            3           if ($a1 == $b1) {
                            fiddle();
            4           } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                            fiddle();
                        }
            5       } elseif ($c == $d) {
            6           while ($c == $d) {
                            fiddle();
                        }
            7        } elseif ($e == $f) {
            8           for ($n = 0; $n < $h; $n++) {
                            fiddle();
                        }
                    } else {
                        switch ($z) {
            9               case 1:
                                fiddle();
                                break;
            10              case 2:
                                fiddle();
                                break;
            11              case 3:
                                fiddle();
                                break;
                            default:
                                fiddle();
                                break;
                        }
                    }
                }
            }

            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

            The method interpolateTwigFunctions() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10.
            Open

                protected function interpolateTwigFunctions(string $code): string
                {
                    $tokens = array_slice(token_get_all('<?php '.$code), 1);
                    $output = '';
                    $count = count($tokens);

            CyclomaticComplexity

            Since: 0.1

            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

            Example

            // Cyclomatic Complexity = 11
            class Foo {
            1   public function example() {
            2       if ($a == $b) {
            3           if ($a1 == $b1) {
                            fiddle();
            4           } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                            fiddle();
                        }
            5       } elseif ($c == $d) {
            6           while ($c == $d) {
                            fiddle();
                        }
            7        } elseif ($e == $f) {
            8           for ($n = 0; $n < $h; $n++) {
                            fiddle();
                        }
                    } else {
                        switch ($z) {
            9               case 1:
                                fiddle();
                                break;
            10              case 2:
                                fiddle();
                                break;
            11              case 3:
                                fiddle();
                                break;
                            default:
                                fiddle();
                                break;
                        }
                    }
                }
            }

            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

            Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed.
            Open

                protected function getRendererOptions(): array

            Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

            See

            Refactor this function to reduce its Cognitive Complexity from 39 to the 15 allowed.
            Open

                protected function interpolateTwigFunctions(string $code): string

            Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

            See

            Avoid using undefined variables such as '$propertyAccessor' which will lead to PHP notices.
            Open

                    $propertyAccessor->setValue($this->container, $services);

            UndefinedVariable

            Since: 2.8.0

            Detects when a variable is used that has not been defined before.

            Example

            class Foo
            {
                private function bar()
                {
                    // $message is undefined
                    echo $message;
                }
            }

            Source https://phpmd.org/rules/cleancode.html#undefinedvariable

            Avoid using undefined variables such as '$propertyAccessor' which will lead to PHP notices.
            Open

                    $services = static::getPrivateProperty($this->container, 'services', $propertyAccessor);

            UndefinedVariable

            Since: 2.8.0

            Detects when a variable is used that has not been defined before.

            Example

            class Foo
            {
                private function bar()
                {
                    // $message is undefined
                    echo $message;
                }
            }

            Source https://phpmd.org/rules/cleancode.html#undefinedvariable

            Avoid assigning values to variables in if clauses and the like (line '103', column '18').
            Open

                protected function getRendererOptions(): array
                {
                    if ($this->options === null) {
                        $environment = $this->kernel->getEnvironment();
                        $projectDirectory = $this->kernel->getProjectDir();

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

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

            Avoid assigning values to variables in if clauses and the like (line '104', column '26').
            Open

                protected function getRendererOptions(): array
                {
                    if ($this->options === null) {
                        $environment = $this->kernel->getEnvironment();
                        $projectDirectory = $this->kernel->getProjectDir();

            IfStatementAssignment

            Since: 2.7.0

            Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($foo = 'bar') { // possible typo
                        // ...
                    }
                    if ($baz = 0) { // always false
                        // ...
                    }
                }
            }

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

            Refactor the code to avoid updating the loop counter "$opening" within the loop body.
            Open

                                            if ((--$opening) !== 0) {

            A for loop stop condition should test the loop counter against an invariant value (i.e. one that is true at both the beginning and ending of every loop iteration). Ideally, this means that the stop condition is set to a local variable just before the loop begins.

            Stop conditions that are not invariant are slightly less efficient, as well as being difficult to understand and maintain, and likely lead to the introduction of errors in the future.

            This rule tracks three types of non-invariant stop conditions:

            • When the loop counters are updated in the body of the for loop
            • When the stop condition depend upon a method call
            • When the stop condition depends on an object property, since such properties could change during the execution of the loop.

            Noncompliant Code Example

            for ($i = 0; $i < 10; $i++) {
              echo $i;
              if(condition) {
                $i = 20;
              }
            }
            

            Compliant Solution

            for ($i = 0; $i < 10; $i++) {
              echo $i;
            }
            
            

            See

            • MISRA C:2004, 13.6 - Numeric variables being used within a for loop for iteration counting shall not be modified in the body of the loop.
            • MISRA C++:2008, 6-5-3 - The loop-counter shall not be modified within condition or statement.

            Define and throw a dedicated exception instead of using a generic one.
            Open

                        throw new RuntimeException('Twig needs to be configured.');

            If you throw a general exception type, such as ErrorException, RuntimeException, or Exception in a library or framework, it forces consumers to catch all exceptions, including unknown exceptions that they do not know how to handle.

            Instead, either throw a subtype that already exists in the Standard PHP Library, or create your own type that derives from Exception.

            Noncompliant Code Example

            throw new Exception();  // Noncompliant
            

            Compliant Solution

            throw new InvalidArgumentException();
            // or
            throw new UnexpectedValueException();
            

            See

            Define a constant instead of duplicating this literal "paths" 5 times.
            Open

                        $this->setOption('paths', array_unique($this->getOptionDefault('paths', [])));

            Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

            On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

            Noncompliant Code Example

            With the default threshold of 3:

            function run() {
              prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
              execute('action1');
              release('action1');
            }
            

            Compliant Solution

            ACTION_1 = 'action1';
            
            function run() {
              prepare(ACTION_1);
              execute(ACTION_1);
              release(ACTION_1);
            }
            

            Exceptions

            To prevent generating some false-positives, literals having less than 5 characters are excluded.

            Refactor the code to avoid updating the loop counter "$opening" within the loop body.
            Open

                                            $opening++;

            A for loop stop condition should test the loop counter against an invariant value (i.e. one that is true at both the beginning and ending of every loop iteration). Ideally, this means that the stop condition is set to a local variable just before the loop begins.

            Stop conditions that are not invariant are slightly less efficient, as well as being difficult to understand and maintain, and likely lead to the introduction of errors in the future.

            This rule tracks three types of non-invariant stop conditions:

            • When the loop counters are updated in the body of the for loop
            • When the stop condition depend upon a method call
            • When the stop condition depends on an object property, since such properties could change during the execution of the loop.

            Noncompliant Code Example

            for ($i = 0; $i < 10; $i++) {
              echo $i;
              if(condition) {
                $i = 20;
              }
            }
            

            Compliant Solution

            for ($i = 0; $i < 10; $i++) {
              echo $i;
            }
            
            

            See

            • MISRA C:2004, 13.6 - Numeric variables being used within a for loop for iteration counting shall not be modified in the body of the loop.
            • MISRA C++:2008, 6-5-3 - The loop-counter shall not be modified within condition or statement.

            Rename "$pug" which has the same name as the field declared at line 55.
            Open

                    $pug = $this->getRenderer();

            Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

            Noncompliant Code Example

            class Foo {
              public $myField;
            
              public function doSomething() {
                $myField = 0;
                ...
              }
            }
            

            See

            Rename "$twig" which has the same name as the field declared at line 45.
            Open

                    $twig = $this->getTwig();

            Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

            Noncompliant Code Example

            class Foo {
              public $myField;
            
              public function doSomething() {
                $myField = 0;
                ...
              }
            }
            

            See

            Define a constant instead of duplicating this literal "patterns" 3 times.
            Open

                    $transformation = $pug->hasOption('patterns')

            Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

            On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

            Noncompliant Code Example

            With the default threshold of 3:

            function run() {
              prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
              execute('action1');
              release('action1');
            }
            

            Compliant Solution

            ACTION_1 = 'action1';
            
            function run() {
              prepare(ACTION_1);
              execute(ACTION_1);
              release(ACTION_1);
            }
            

            Exceptions

            To prevent generating some false-positives, literals having less than 5 characters are excluded.

            Refactor the code to avoid updating the loop counter "$index" within the loop body.
            Open

                                    $index += 3;

            A for loop stop condition should test the loop counter against an invariant value (i.e. one that is true at both the beginning and ending of every loop iteration). Ideally, this means that the stop condition is set to a local variable just before the loop begins.

            Stop conditions that are not invariant are slightly less efficient, as well as being difficult to understand and maintain, and likely lead to the introduction of errors in the future.

            This rule tracks three types of non-invariant stop conditions:

            • When the loop counters are updated in the body of the for loop
            • When the stop condition depend upon a method call
            • When the stop condition depends on an object property, since such properties could change during the execution of the loop.

            Noncompliant Code Example

            for ($i = 0; $i < 10; $i++) {
              echo $i;
              if(condition) {
                $i = 20;
              }
            }
            

            Compliant Solution

            for ($i = 0; $i < 10; $i++) {
              echo $i;
            }
            
            

            See

            • MISRA C:2004, 13.6 - Numeric variables being used within a for loop for iteration counting shall not be modified in the body of the loop.
            • MISRA C++:2008, 6-5-3 - The loop-counter shall not be modified within condition or statement.

            Define a constant instead of duplicating this literal "baseDir" 3 times.
            Open

                        $baseDir = isset($this->userOptions['baseDir'])

            Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

            On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

            Noncompliant Code Example

            With the default threshold of 3:

            function run() {
              prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
              execute('action1');
              release('action1');
            }
            

            Compliant Solution

            ACTION_1 = 'action1';
            
            function run() {
              prepare(ACTION_1);
              execute(ACTION_1);
              release(ACTION_1);
            }
            

            Exceptions

            To prevent generating some false-positives, literals having less than 5 characters are excluded.

            Refactor the code to avoid updating the loop counter "$index" within the loop body.
            Open

                                $index += 2;

            A for loop stop condition should test the loop counter against an invariant value (i.e. one that is true at both the beginning and ending of every loop iteration). Ideally, this means that the stop condition is set to a local variable just before the loop begins.

            Stop conditions that are not invariant are slightly less efficient, as well as being difficult to understand and maintain, and likely lead to the introduction of errors in the future.

            This rule tracks three types of non-invariant stop conditions:

            • When the loop counters are updated in the body of the for loop
            • When the stop condition depend upon a method call
            • When the stop condition depends on an object property, since such properties could change during the execution of the loop.

            Noncompliant Code Example

            for ($i = 0; $i < 10; $i++) {
              echo $i;
              if(condition) {
                $i = 20;
              }
            }
            

            Compliant Solution

            for ($i = 0; $i < 10; $i++) {
              echo $i;
            }
            
            

            See

            • MISRA C:2004, 13.6 - Numeric variables being used within a for loop for iteration counting shall not be modified in the body of the loop.
            • MISRA C++:2008, 6-5-3 - The loop-counter shall not be modified within condition or statement.

            Rename "$pug" which has the same name as the field declared at line 55.
            Open

                    $pug = new Pug($options);

            Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

            Noncompliant Code Example

            class Foo {
              public $myField;
            
              public function doSomething() {
                $myField = 0;
                ...
              }
            }
            

            See

            Refactor the code to avoid updating the loop counter "$index" within the loop body.
            Open

                                for ($opening = 1; $opening !== 0; $index++) {

            A for loop stop condition should test the loop counter against an invariant value (i.e. one that is true at both the beginning and ending of every loop iteration). Ideally, this means that the stop condition is set to a local variable just before the loop begins.

            Stop conditions that are not invariant are slightly less efficient, as well as being difficult to understand and maintain, and likely lead to the introduction of errors in the future.

            This rule tracks three types of non-invariant stop conditions:

            • When the loop counters are updated in the body of the for loop
            • When the stop condition depend upon a method call
            • When the stop condition depends on an object property, since such properties could change during the execution of the loop.

            Noncompliant Code Example

            for ($i = 0; $i < 10; $i++) {
              echo $i;
              if(condition) {
                $i = 20;
              }
            }
            

            Compliant Solution

            for ($i = 0; $i < 10; $i++) {
              echo $i;
            }
            
            

            See

            • MISRA C:2004, 13.6 - Numeric variables being used within a for loop for iteration counting shall not be modified in the body of the loop.
            • MISRA C++:2008, 6-5-3 - The loop-counter shall not be modified within condition or statement.

            Property \Pug\Symfony\Traits\HelpersHandler->container has undeclared type \Symfony\Component\DependencyInjection\ContainerInterface
            Open

                protected $container;

            Call to method __construct from undeclared class \Pug\Pug
            Open

                    $pug = new Pug($options);
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method setOptionsRecursive from undeclared class \Pug\Pug
            Open

                    $pug->setOptionsRecursive([
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method has from undeclared class \Symfony\Component\DependencyInjection\ContainerInterface
            Open

                    $this->twig = $this->container->has('twig') ? $this->container->get('twig') : null;
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Reference to constant class from undeclared class \Symfony\Bridge\Twig\Extension\AssetExtension
            Open

                    $assetExtension = $twig->extensions[AssetExtension::class] ?? null;
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to undeclared method \Pug\Symfony\Traits\HelpersHandler::getOptionDefault
            Open

                        $this->setOption('paths', array_unique($this->getOptionDefault('paths', [])));
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method getCompiler from undeclared class \Pug\Pug
            Open

                        $pug->getCompiler()->setOption('mixin_keyword', $pug->getOption('mixin_keyword'));
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method __construct from undeclared class \Symfony\Bridge\Twig\Extension\HttpFoundationExtension
            Open

                    return new HttpFoundationExtension(new UrlHelper($stack, $context));
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to undeclared method \Pug\Symfony\Traits\HelpersHandler::crawlDirectories
            Open

                            : $this->crawlDirectories($srcDir, $assetsDirectories, $viewDirectories);
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Static call to undeclared method \Pug\Symfony\Traits\HelpersHandler::extractUniquePaths
            Open

                            'viewDirectories' => static::extractUniquePaths($viewDirectories),
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Reference to undeclared property \Pug\Symfony\Traits\HelpersHandler->componentExtension
            Open

                        $this->componentExtension = $pug->getModule(ComponentExtension::class);

            Argument 2 (pugSymfonyEngine) is \Pug\Symfony\Traits\HelpersHandler|\Pug\Symfony\Traits\PrivatePropertyAccessor but \Pug\Twig\Environment::fromTwigEnvironment() takes \Pug\PugSymfonyEngine defined at src/Pug/Twig/Environment.php:82
            Open

                    $this->twig = Environment::fromTwigEnvironment($this->twig, $this, $this->container);

            Possibly zero references to use statement for classlike/namespace RequestContext (\Symfony\Component\Routing\RequestContext)
            Open

            use Symfony\Component\Routing\RequestContext;

            Call to method enable from undeclared class \Phug\Component\ComponentExtension
            Open

                        ComponentExtension::enable($pug);
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method getModule from undeclared class \Pug\Pug
            Open

                        $this->componentExtension = $pug->getModule(ComponentExtension::class);
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Return type of getRenderer() is undeclared type \Pug\Pug
            Open

                public function getRenderer(): Pug

            Checking instanceof against undeclared class \Twig\Loader\FilesystemLoader
            Open

                        if (($loader = $this->getTwig()->getLoader()) instanceof FilesystemLoader &&
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to undeclared method \Pug\Twig\Environment::getLoader
            Open

                        if (($loader = $this->getTwig()->getLoader()) instanceof FilesystemLoader &&
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to undeclared method \Pug\Symfony\Traits\HelpersHandler::getCacheDir
            Open

                            'cache'           => $debug ? false : $this->getCacheDir(),
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Parameter $function has undeclared type \Twig\TwigFunction
            Open

                protected function copyTwigFunction(TwigFunction $function): void

            Call to method __construct from undeclared class \Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy
            Open

                        $assetExtension = new AssetExtension(new Packages(new Package(new EmptyVersionStrategy())));
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Property \Pug\Symfony\Traits\HelpersHandler->kernel has undeclared type \Symfony\Component\HttpKernel\Kernel
            Open

                protected $kernel;

            Static call to undeclared method \Pug\Symfony\Traits\HelpersHandler::extractUniquePaths
            Open

                            'assetDirectory'  => static::extractUniquePaths($assetsDirectories),
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method __construct from undeclared class \Symfony\Component\Filesystem\Filesystem
            Open

                            (new Filesystem())->mkdir($cache);
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Reference to constant class from undeclared class \Symfony\Bridge\Twig\Extension\AssetExtension
            Open

                        $twig->extensions[AssetExtension::class] = $assetExtension;
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method __construct from undeclared class \Symfony\Component\HttpFoundation\UrlHelper
            Open

                    return new HttpFoundationExtension(new UrlHelper($stack, $context));
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Reference to undeclared property \Pug\Symfony\Traits\HelpersHandler->defaultTemplateDirectory
            Open

                        $this->defaultTemplateDirectory = $baseDir;

            Call to method getOption from undeclared class \Pug\Pug
            Open

                        ? ($pug->getOption('patterns')['transform_expression'] ?? null)
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method __construct from undeclared class \Pug\Assets
            Open

                        $this->assets = new Assets($pug);
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Reference to constant class from undeclared class \Phug\Component\ComponentExtension
            Open

                        $this->componentExtension = $pug->getModule(ComponentExtension::class);
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Reference to undeclared property \Pug\Symfony\Traits\HelpersHandler->options
            Open

                    if ($this->options === null) {

            Call to method isDebug from undeclared class \Symfony\Component\HttpKernel\Kernel
            Open

                        $debug = $this->kernel->isDebug();
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Reference to undeclared property \Pug\Symfony\Traits\HelpersHandler->options (Did you mean $options)
            Open

                        $this->options = $options;

            Return type of createEngine() is undeclared type \Pug\Pug
            Open

                protected function createEngine(array $options): Pug

            Call to undeclared method \Pug\Twig\Environment::getExtensions
            Open

                    $twig->extensions = $twig->getExtensions();
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to undeclared method \Pug\Twig\Environment::addExtension
            Open

                            $twig->addExtension($helper);
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to undeclared method \Pug\Twig\Environment::getGlobals
            Open

                        $this->share($this->getTwig()->getGlobals());
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to undeclared method \Pug\Symfony\Traits\HelpersHandler::setOption
            Open

                        $this->setOption('paths', array_unique($this->getOptionDefault('paths', [])));
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Return type of getHttpFoundationExtension() is undeclared type \Symfony\Bridge\Twig\Extension\HttpFoundationExtension
            Open

                protected function getHttpFoundationExtension(): HttpFoundationExtension

            Possibly zero references to use statement for classlike/namespace ExtensionInterface (\Twig\Extension\ExtensionInterface)
            Open

            use Twig\Extension\ExtensionInterface;

            Call to method getEnvironment from undeclared class \Symfony\Component\HttpKernel\Kernel
            Open

                        $environment = $this->kernel->getEnvironment();
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method getName from undeclared class \Twig\TwigFunction
            Open

                    $name = $function->getName();
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to undeclared method \Pug\Twig\Environment::addExtension
            Open

                        $twig->addExtension($assetExtension);
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method get from undeclared class \Symfony\Component\DependencyInjection\ContainerInterface
            Open

                        : $this->container->get('router')->getContext();
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Property \Pug\Symfony\Traits\HelpersHandler->pug has undeclared type \Pug\Pug
            Open

                protected $pug;

            Call to undeclared method \Pug\Symfony\Traits\HelpersHandler::share
            Open

                        $this->share($this->getTwig()->getGlobals());
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method mkdir from undeclared class \Symfony\Component\Filesystem\Filesystem
            Open

                            (new Filesystem())->mkdir($cache);
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to undeclared method \Pug\Twig\Environment::setLoader
            Open

                    $twig->setLoader($loader);
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method getFunctions from undeclared class \Symfony\Bridge\Twig\Extension\AssetExtension
            Open

                        foreach ($extension->getFunctions() as $function) {
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method getProjectDir from undeclared class \Symfony\Component\HttpKernel\Kernel
            Open

                        $projectDirectory = $this->kernel->getProjectDir();
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Reference to undeclared property \Pug\Symfony\Traits\HelpersHandler->options (Did you mean $options)
            Open

                    return $this->options;

            Call to undeclared method \Pug\Symfony\Traits\HelpersHandler::share
            Open

                    $this->share('twig', $twig);
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method get from undeclared class \Symfony\Component\DependencyInjection\ContainerInterface
            Open

                    $stack = $this->container->get('request_stack');
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Reference to undeclared property \Pug\Twig\Environment->env (Did you mean $_ENV)
            Open

                    $twig->env = $twig;

            Call to method has from undeclared class \Symfony\Component\DependencyInjection\ContainerInterface
            Open

                    $context = $this->container->has('router.request_context')
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method hasOption from undeclared class \Pug\Pug
            Open

                    $transformation = $pug->hasOption('patterns')
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method getOption from undeclared class \Pug\Pug
            Open

                        $pug->getCompiler()->setOption('mixin_keyword', $pug->getOption('mixin_keyword'));
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to undeclared method \Pug\Twig\Environment::getLoader
            Open

                    $loader = new MixedLoader($twig->getLoader());
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method __construct from undeclared class \Symfony\Bridge\Twig\Extension\AssetExtension
            Open

                        $assetExtension = new AssetExtension(new Packages(new Package(new EmptyVersionStrategy())));
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Possibly zero references to use statement for classlike/namespace RequestStack (\Symfony\Component\HttpFoundation\RequestStack)
            Open

            use Symfony\Component\HttpFoundation\RequestStack;

            Property \Pug\Symfony\Traits\HelpersHandler->kernel has undeclared type \Symfony\Component\HttpKernel\KernelInterface
            Open

                protected $kernel;

            Reference to undeclared property \Pug\Symfony\Traits\HelpersHandler->assets
            Open

                        $this->assets = new Assets($pug);

            Call to method get from undeclared class \Symfony\Component\DependencyInjection\ContainerInterface
            Open

                    $this->twig = $this->container->has('twig') ? $this->container->get('twig') : null;
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method __construct from undeclared class \Symfony\Component\Asset\Packages
            Open

                        $assetExtension = new AssetExtension(new Packages(new Package(new EmptyVersionStrategy())));
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Checking instanceof against undeclared class \Twig\Environment (Did you mean class \Pug\Twig\Environment)
            Open

                    if (!($this->twig instanceof TwigEnvironment)) {
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method __construct from undeclared class \Symfony\Component\Asset\Package
            Open

                        $assetExtension = new AssetExtension(new Packages(new Package(new EmptyVersionStrategy())));
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Call to method get from undeclared class \Symfony\Component\DependencyInjection\ContainerInterface
            Open

                        ? $this->container->get('router.request_context')
            Severity: Critical
            Found in src/Pug/Symfony/Traits/HelpersHandler.php by phan

            Avoid excessively long variable names like $argumentNeedInterpolation. Keep variable name length under 20.
            Open

                                $argumentNeedInterpolation = false;

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid excessively long variable names like $argumentNeedInterpolation. Keep variable name length under 20.
            Open

                protected function pushArgument(array &$arguments, string &$argument, bool &$argumentNeedInterpolation)

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            There are no issues that match your filters.

            Category
            Status