src/Phan/AST/ContextNode.php

Summary

Maintainability
F
3 wks
Test Coverage

File ContextNode.php has 1912 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Phan\AST;
Severity: Major
Found in src/Phan/AST/ContextNode.php - About 5 days to fix

    Function getProperty has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getProperty(
            bool $is_static,
            bool $is_known_assignment = false
        ): Property {
            $node = $this->node;
    Severity: Minor
    Found in src/Phan/AST/ContextNode.php - About 1 day 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

    Method getProperty has 213 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getProperty(
            bool $is_static,
            bool $is_known_assignment = false
        ): Property {
            $node = $this->node;
    Severity: Major
    Found in src/Phan/AST/ContextNode.php - About 1 day to fix

      ContextNode has 47 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class ContextNode
      {
      
          /** @var CodeBase The code base within which we're operating */
          private $code_base;
      Severity: Minor
      Found in src/Phan/AST/ContextNode.php - About 6 hrs to fix

        Function getMethod has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getMethod(
                $method_name,
                bool $is_static,
                bool $is_direct = false,
                bool $is_new_expression = false
        Severity: Minor
        Found in src/Phan/AST/ContextNode.php - About 6 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

        Function getClassList has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getClassList(
                bool $ignore_missing_classes = false,
                int $expected_type_categories = self::CLASS_LIST_ACCEPT_ANY,
                string $custom_issue_type = null,
                bool $warn_if_wrong_type = true
        Severity: Minor
        Found in src/Phan/AST/ContextNode.php - About 6 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

        Method getMethod has 156 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getMethod(
                $method_name,
                bool $is_static,
                bool $is_direct = false,
                bool $is_new_expression = false
        Severity: Major
        Found in src/Phan/AST/ContextNode.php - About 6 hrs to fix

          Function getConst has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getConst(): GlobalConstant
              {
                  $node = $this->node;
                  if (!$node instanceof Node) {
                      throw new AssertionError('$node must be a node');
          Severity: Minor
          Found in src/Phan/AST/ContextNode.php - About 4 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

          Function analyzeBackwardCompatibility has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

              public function analyzeBackwardCompatibility(): void
              {
                  if (!Config::get_backward_compatibility_checks()) {
                      return;
                  }
          Severity: Minor
          Found in src/Phan/AST/ContextNode.php - About 4 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

          Function getEquivalentPHPValueForNode has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getEquivalentPHPValueForNode($node, int $flags)
              {
                  if (!($node instanceof Node)) {
                      return $node;
                  }
          Severity: Minor
          Found in src/Phan/AST/ContextNode.php - About 4 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

          Method getEquivalentPHPValueForNode has 109 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getEquivalentPHPValueForNode($node, int $flags)
              {
                  if (!($node instanceof Node)) {
                      return $node;
                  }
          Severity: Major
          Found in src/Phan/AST/ContextNode.php - About 4 hrs to fix

            Function getFunction has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getFunction(
                    string $function_name,
                    bool $is_function_declaration = false,
                    bool $return_placeholder_for_undefined = false
                ): FunctionInterface {
            Severity: Minor
            Found in src/Phan/AST/ContextNode.php - About 4 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

            Method analyzeBackwardCompatibility has 103 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function analyzeBackwardCompatibility(): void
                {
                    if (!Config::get_backward_compatibility_checks()) {
                        return;
                    }
            Severity: Major
            Found in src/Phan/AST/ContextNode.php - About 4 hrs to fix

              Method getClassConst has 90 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getClassConst(): ClassConstant
                  {
                      $node = $this->node;
                      if (!($node instanceof Node)) {
                          throw new AssertionError('$this->node must be a node');
              Severity: Major
              Found in src/Phan/AST/ContextNode.php - About 3 hrs to fix

                Method getConst has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getConst(): GlobalConstant
                    {
                        $node = $this->node;
                        if (!$node instanceof Node) {
                            throw new AssertionError('$node must be a node');
                Severity: Major
                Found in src/Phan/AST/ContextNode.php - About 3 hrs to fix

                  The class ContextNode has an overall complexity of 396 which is very high. The configured complexity threshold is 50.
                  Open

                  class ContextNode
                  {
                  
                      /** @var CodeBase The code base within which we're operating */
                      private $code_base;
                  Severity: Minor
                  Found in src/Phan/AST/ContextNode.php by phpmd

                  Method handleTraitPrecedence has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function handleTraitPrecedence(array $adaptations_map, Node $adaptation_node): void
                      {
                          // TODO: Should also verify that the original method exists, in a future PR?
                          $trait_method_node = $adaptation_node->children['method'];
                          if (!$trait_method_node instanceof Node) {
                  Severity: Major
                  Found in src/Phan/AST/ContextNode.php - About 2 hrs to fix

                    Function getEquivalentPHPArrayElements has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function getEquivalentPHPArrayElements(Node $node, int $flags): ?array
                        {
                            $elements = [];
                            foreach ($node->children as $child_node) {
                                if (!($child_node instanceof Node)) {
                    Severity: Minor
                    Found in src/Phan/AST/ContextNode.php - About 2 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

                    Method handleTraitAlias has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function handleTraitAlias(array $adaptations_map, Node $adaptation_node): void
                        {
                            $trait_method_node = $adaptation_node->children['method'];
                            if (!$trait_method_node instanceof Node) {
                                throw new AssertionError("Expected node for trait alias");
                    Severity: Major
                    Found in src/Phan/AST/ContextNode.php - About 2 hrs to fix

                      Consider simplifying this complex logical expression.
                      Open

                                  if ($union_type->isDefinitelyUndefined()
                                      || (!$union_type->isEmpty()
                                          && $union_type->isNativeType()
                                          && !$union_type->hasTypeMatchingCallback(static function (Type $type): bool {
                                              return !$type->isNullableLabeled() && ($type instanceof MixedType || $type instanceof ObjectType);
                      Severity: Critical
                      Found in src/Phan/AST/ContextNode.php - About 2 hrs to fix

                        Method getClassList has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getClassList(
                                bool $ignore_missing_classes = false,
                                int $expected_type_categories = self::CLASS_LIST_ACCEPT_ANY,
                                string $custom_issue_type = null,
                                bool $warn_if_wrong_type = true
                        Severity: Major
                        Found in src/Phan/AST/ContextNode.php - About 2 hrs to fix

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

                              public function getOrCreateProperty(
                                  string $property_name,
                                  bool $is_static
                              ): Property {
                          
                          
                          Severity: Major
                          Found in src/Phan/AST/ContextNode.php - About 2 hrs to fix

                            Method getFunction has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function getFunction(
                                    string $function_name,
                                    bool $is_function_declaration = false,
                                    bool $return_placeholder_for_undefined = false
                                ): FunctionInterface {
                            Severity: Major
                            Found in src/Phan/AST/ContextNode.php - About 2 hrs to fix

                              Method getClassListInner has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function getClassListInner(bool $ignore_missing_classes): array
                                  {
                                      $node = $this->node;
                                      if (!($node instanceof Node)) {
                                          if (\is_string($node)) {
                              Severity: Minor
                              Found in src/Phan/AST/ContextNode.php - About 2 hrs to fix

                                Consider simplifying this complex logical expression.
                                Open

                                        if ((
                                                (
                                                    $lnode->children['prop'] instanceof Node
                                                    && $lnode->children['prop']->kind === ast\AST_VAR
                                                )
                                Severity: Critical
                                Found in src/Phan/AST/ContextNode.php - About 2 hrs to fix

                                  Function getClassConst has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function getClassConst(): ClassConstant
                                      {
                                          $node = $this->node;
                                          if (!($node instanceof Node)) {
                                              throw new AssertionError('$this->node must be a node');
                                  Severity: Minor
                                  Found in src/Phan/AST/ContextNode.php - About 1 hr 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

                                  Function handleTraitPrecedence has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private function handleTraitPrecedence(array $adaptations_map, Node $adaptation_node): void
                                      {
                                          // TODO: Should also verify that the original method exists, in a future PR?
                                          $trait_method_node = $adaptation_node->children['method'];
                                          if (!$trait_method_node instanceof Node) {
                                  Severity: Minor
                                  Found in src/Phan/AST/ContextNode.php - About 1 hr 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

                                  Method getVariableName has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function getVariableName(): string
                                      {
                                          if (!($this->node instanceof Node)) {
                                              return (string)$this->node;
                                          }
                                  Severity: Minor
                                  Found in src/Phan/AST/ContextNode.php - About 1 hr to fix

                                    Method getFunctionFromNode has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function getFunctionFromNode(bool $return_placeholder_for_undefined = false): iterable
                                        {
                                            $expression = $this->node;
                                            if (!($expression instanceof Node)) {
                                                if (!\is_string($expression)) {
                                    Severity: Minor
                                    Found in src/Phan/AST/ContextNode.php - About 1 hr to fix

                                      Method getFunctionLikeFromDynamicExpression has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          private function getFunctionLikeFromDynamicExpression(): \Generator
                                          {
                                              $code_base = $this->code_base;
                                              $context = $this->context;
                                              $expression = $this->node;
                                      Severity: Minor
                                      Found in src/Phan/AST/ContextNode.php - About 1 hr to fix

                                        Method getVariableStrict has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            public function getVariableStrict(): Variable
                                            {
                                                $node = $this->node;
                                                if (!($node instanceof Node)) {
                                                    throw new AssertionError('$this->node must be a node');
                                        Severity: Minor
                                        Found in src/Phan/AST/ContextNode.php - About 1 hr to fix

                                          Function getVariableName has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              public function getVariableName(): string
                                              {
                                                  if (!($this->node instanceof Node)) {
                                                      return (string)$this->node;
                                                  }
                                          Severity: Minor
                                          Found in src/Phan/AST/ContextNode.php - About 1 hr 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

                                          Method getVariable has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              public function getVariable(): Variable
                                              {
                                                  $node = $this->node;
                                                  if (!($node instanceof Node)) {
                                                      throw new AssertionError('$this->node must be a node');
                                          Severity: Minor
                                          Found in src/Phan/AST/ContextNode.php - About 1 hr to fix

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

                                                public function resolveClassNameInContext(): ?FullyQualifiedClassName
                                                {
                                                    // A function argument to resolve into an FQSEN
                                                    $arg = $this->node;
                                            
                                            
                                            Severity: Minor
                                            Found in src/Phan/AST/ContextNode.php - About 1 hr to fix

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

                                                  private function getEquivalentPHPArrayElements(Node $node, int $flags): ?array
                                                  {
                                                      $elements = [];
                                                      foreach ($node->children as $child_node) {
                                                          if (!($child_node instanceof Node)) {
                                              Severity: Minor
                                              Found in src/Phan/AST/ContextNode.php - About 1 hr to fix

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

                                                    public function getOrCreateVariableForReferenceParameter(Parameter $parameter, ?Parameter $real_parameter): Variable
                                                    {
                                                        // Return the original variable if it existed
                                                        try {
                                                            $variable = $this->getVariable();
                                                Severity: Minor
                                                Found in src/Phan/AST/ContextNode.php - About 1 hr to fix

                                                  Function getOrCreateProperty has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      public function getOrCreateProperty(
                                                          string $property_name,
                                                          bool $is_static
                                                      ): Property {
                                                  
                                                  
                                                  Severity: Minor
                                                  Found in src/Phan/AST/ContextNode.php - About 1 hr 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

                                                  Function getClassListInner has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      public function getClassListInner(bool $ignore_missing_classes): array
                                                      {
                                                          $node = $this->node;
                                                          if (!($node instanceof Node)) {
                                                              if (\is_string($node)) {
                                                  Severity: Minor
                                                  Found in src/Phan/AST/ContextNode.php - About 1 hr 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

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

                                                      public function getTraitAdaptationsMap(array $trait_fqsen_list): array
                                                      {
                                                          if (!($this->node instanceof Node)) {
                                                              return [];
                                                          }
                                                  Severity: Minor
                                                  Found in src/Phan/AST/ContextNode.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

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

                                                      public function getVariableStrict(): Variable
                                                      {
                                                          $node = $this->node;
                                                          if (!($node instanceof Node)) {
                                                              throw new AssertionError('$this->node must be a node');
                                                  Severity: Minor
                                                  Found in src/Phan/AST/ContextNode.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

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

                                                      private function getFunctionLikeFromDynamicExpression(): \Generator
                                                      {
                                                          $code_base = $this->code_base;
                                                          $context = $this->context;
                                                          $expression = $this->node;
                                                  Severity: Minor
                                                  Found in src/Phan/AST/ContextNode.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

                                                                          if ($union_type->isType(NullType::instance(false))) {
                                                                              $custom_issue_type = Issue::TypeExpectedObjectPropAccessButGotNull;
                                                                          }
                                                  Severity: Major
                                                  Found in src/Phan/AST/ContextNode.php - About 45 mins to fix

                                                    Function getOrCreateVariableForReferenceParameter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function getOrCreateVariableForReferenceParameter(Parameter $parameter, ?Parameter $real_parameter): Variable
                                                        {
                                                            // Return the original variable if it existed
                                                            try {
                                                                $variable = $this->getVariable();
                                                    Severity: Minor
                                                    Found in src/Phan/AST/ContextNode.php - About 45 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

                                                    Function getFunctionFromNode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function getFunctionFromNode(bool $return_placeholder_for_undefined = false): iterable
                                                        {
                                                            $expression = $this->node;
                                                            if (!($expression instanceof Node)) {
                                                                if (!\is_string($expression)) {
                                                    Severity: Minor
                                                    Found in src/Phan/AST/ContextNode.php - About 45 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

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

                                                        public function resolveClassNameInContext(): ?FullyQualifiedClassName
                                                        {
                                                            // A function argument to resolve into an FQSEN
                                                            $arg = $this->node;
                                                    
                                                    
                                                    Severity: Minor
                                                    Found in src/Phan/AST/ContextNode.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

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

                                                        private function handleTraitAlias(array $adaptations_map, Node $adaptation_node): void
                                                        {
                                                            $trait_method_node = $adaptation_node->children['method'];
                                                            if (!$trait_method_node instanceof Node) {
                                                                throw new AssertionError("Expected node for trait alias");
                                                    Severity: Minor
                                                    Found in src/Phan/AST/ContextNode.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

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                    return $new_node;
                                                    Severity: Major
                                                    Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                          return UnionTypeVisitor::unionTypeFromNode($this->code_base, $this->context, $node, false)->asSingleScalarValueOrNull() ?? $node;
                                                      Severity: Major
                                                      Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                            return $node;
                                                        Severity: Major
                                                        Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                  return $raw_function_name($arg_value);
                                                          Severity: Major
                                                          Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                        return;
                                                            Severity: Major
                                                            Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                                  return $node;
                                                              Severity: Major
                                                              Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                                    return $this->getValueForCall($node, $flags);
                                                                Severity: Major
                                                                Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                              return;
                                                                  Severity: Major
                                                                  Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                                    return $this->getValueForMagicConstByNode($node);
                                                                    Severity: Major
                                                                    Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                              return (string)$name_node;
                                                                      Severity: Major
                                                                      Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                        return;
                                                                        Severity: Major
                                                                        Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                              return $node;
                                                                          Severity: Major
                                                                          Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                            Avoid too many return statements within this method.
                                                                            Open

                                                                                        return $this->returnStubOrThrowUndeclaredFunctionIssueException(
                                                                                            $function_fqsen,
                                                                                            $not_fully_qualified,
                                                                                            $not_fully_qualified ? FullyQualifiedFunctionName::make($namespace, $function_name) : $function_fqsen,
                                                                                            $return_placeholder_for_undefined
                                                                            Severity: Major
                                                                            Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                          return;
                                                                              Severity: Major
                                                                              Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                Avoid too many return statements within this method.
                                                                                Open

                                                                                                return [$union_type, $class_list];
                                                                                Severity: Major
                                                                                Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

                                                                                                      return $code_base->getFunctionByFQSEN($function_fqsen);
                                                                                  Severity: Major
                                                                                  Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

                                                                                                        return $node;
                                                                                    Severity: Major
                                                                                    Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

                                                                                                          return $node;
                                                                                      Severity: Major
                                                                                      Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                        Avoid too many return statements within this method.
                                                                                        Open

                                                                                                return $value;
                                                                                        Severity: Major
                                                                                        Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                          Avoid too many return statements within this method.
                                                                                          Open

                                                                                                      return;
                                                                                          Severity: Major
                                                                                          Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                            Avoid too many return statements within this method.
                                                                                            Open

                                                                                                    return $class_list;
                                                                                            Severity: Major
                                                                                            Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                              Avoid too many return statements within this method.
                                                                                              Open

                                                                                                                  return $this->getValueForEmptyCheck($node, $flags);
                                                                                              Severity: Major
                                                                                              Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                Avoid too many return statements within this method.
                                                                                                Open

                                                                                                            return $node;
                                                                                                Severity: Major
                                                                                                Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                  Avoid too many return statements within this method.
                                                                                                  Open

                                                                                                                              return null;
                                                                                                  Severity: Major
                                                                                                  Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                    Avoid too many return statements within this method.
                                                                                                    Open

                                                                                                                        return $this->getValueForIssetCheck($node, $flags);
                                                                                                    Severity: Major
                                                                                                    Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                      Avoid too many return statements within this method.
                                                                                                      Open

                                                                                                                  return;
                                                                                                      Severity: Major
                                                                                                      Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                        Avoid too many return statements within this method.
                                                                                                        Open

                                                                                                                return $code_base->getFunctionByFQSEN($function_fqsen);
                                                                                                        Severity: Major
                                                                                                        Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                          Avoid too many return statements within this method.
                                                                                                          Open

                                                                                                                      return;
                                                                                                          Severity: Major
                                                                                                          Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                            Avoid too many return statements within this method.
                                                                                                            Open

                                                                                                                                return $this->getValueForUnaryOp($node, $flags);
                                                                                                            Severity: Major
                                                                                                            Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                              Avoid too many return statements within this method.
                                                                                                              Open

                                                                                                                              return $new_node;
                                                                                                              Severity: Major
                                                                                                              Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                                Avoid too many return statements within this method.
                                                                                                                Open

                                                                                                                                            return true;
                                                                                                                Severity: Major
                                                                                                                Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                                  Avoid too many return statements within this method.
                                                                                                                  Open

                                                                                                                              return (string)$name_node_type->asSingleScalarValueOrNull();
                                                                                                                  Severity: Major
                                                                                                                  Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                                    Avoid too many return statements within this method.
                                                                                                                    Open

                                                                                                                                return $result;
                                                                                                                    Severity: Major
                                                                                                                    Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                                      Avoid too many return statements within this method.
                                                                                                                      Open

                                                                                                                                          return $code_base->getFunctionByFQSEN($function_fqsen);
                                                                                                                      Severity: Major
                                                                                                                      Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                                        Avoid too many return statements within this method.
                                                                                                                        Open

                                                                                                                                            return $this->returnStubOrThrowUndeclaredFunctionIssueException($function_fqsen, false, null, $return_placeholder_for_undefined);
                                                                                                                        Severity: Major
                                                                                                                        Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                                          Avoid too many return statements within this method.
                                                                                                                          Open

                                                                                                                                      return;
                                                                                                                          Severity: Major
                                                                                                                          Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                                            Avoid too many return statements within this method.
                                                                                                                            Open

                                                                                                                                                        return false;
                                                                                                                            Severity: Major
                                                                                                                            Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                                              Avoid too many return statements within this method.
                                                                                                                              Open

                                                                                                                                                  return $node;
                                                                                                                              Severity: Major
                                                                                                                              Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                Open

                                                                                                                                                    return $this->getValueForBinaryOp($node, $flags);
                                                                                                                                Severity: Major
                                                                                                                                Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                  Open

                                                                                                                                                          return $node;
                                                                                                                                  Severity: Major
                                                                                                                                  Found in src/Phan/AST/ContextNode.php - About 30 mins to fix

                                                                                                                                    The method getConst() has 107 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                                                                                    Open

                                                                                                                                        public function getConst(): GlobalConstant
                                                                                                                                        {
                                                                                                                                            $node = $this->node;
                                                                                                                                            if (!$node instanceof Node) {
                                                                                                                                                throw new AssertionError('$node must be a node');
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    The method getFunction() has an NPath complexity of 210. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        public function getFunction(
                                                                                                                                            string $function_name,
                                                                                                                                            bool $is_function_declaration = false,
                                                                                                                                            bool $return_placeholder_for_undefined = false
                                                                                                                                        ): FunctionInterface {
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    NPathComplexity

                                                                                                                                    Since: 0.1

                                                                                                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                    Example

                                                                                                                                    class Foo {
                                                                                                                                        function bar() {
                                                                                                                                            // lots of complicated code
                                                                                                                                        }
                                                                                                                                    }

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

                                                                                                                                    The method handleTraitPrecedence() has an NPath complexity of 288. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        private function handleTraitPrecedence(array $adaptations_map, Node $adaptation_node): void
                                                                                                                                        {
                                                                                                                                            // TODO: Should also verify that the original method exists, in a future PR?
                                                                                                                                            $trait_method_node = $adaptation_node->children['method'];
                                                                                                                                            if (!$trait_method_node instanceof Node) {
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    NPathComplexity

                                                                                                                                    Since: 0.1

                                                                                                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                    Example

                                                                                                                                    class Foo {
                                                                                                                                        function bar() {
                                                                                                                                            // lots of complicated code
                                                                                                                                        }
                                                                                                                                    }

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

                                                                                                                                    The method getVariableName() has an NPath complexity of 360. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        public function getVariableName(): string
                                                                                                                                        {
                                                                                                                                            if (!($this->node instanceof Node)) {
                                                                                                                                                return (string)$this->node;
                                                                                                                                            }
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    NPathComplexity

                                                                                                                                    Since: 0.1

                                                                                                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                    Example

                                                                                                                                    class Foo {
                                                                                                                                        function bar() {
                                                                                                                                            // lots of complicated code
                                                                                                                                        }
                                                                                                                                    }

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

                                                                                                                                    The method getProperty() has an NPath complexity of 83187500. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        public function getProperty(
                                                                                                                                            bool $is_static,
                                                                                                                                            bool $is_known_assignment = false
                                                                                                                                        ): Property {
                                                                                                                                            $node = $this->node;
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    NPathComplexity

                                                                                                                                    Since: 0.1

                                                                                                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                    Example

                                                                                                                                    class Foo {
                                                                                                                                        function bar() {
                                                                                                                                            // lots of complicated code
                                                                                                                                        }
                                                                                                                                    }

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

                                                                                                                                    The method getClassConst() has 106 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                                                                                    Open

                                                                                                                                        public function getClassConst(): ClassConstant
                                                                                                                                        {
                                                                                                                                            $node = $this->node;
                                                                                                                                            if (!($node instanceof Node)) {
                                                                                                                                                throw new AssertionError('$this->node must be a node');
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    The method getEquivalentPHPValueForNode() has an NPath complexity of 248. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        public function getEquivalentPHPValueForNode($node, int $flags)
                                                                                                                                        {
                                                                                                                                            if (!($node instanceof Node)) {
                                                                                                                                                return $node;
                                                                                                                                            }
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    NPathComplexity

                                                                                                                                    Since: 0.1

                                                                                                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                    Example

                                                                                                                                    class Foo {
                                                                                                                                        function bar() {
                                                                                                                                            // lots of complicated code
                                                                                                                                        }
                                                                                                                                    }

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

                                                                                                                                    The method getConst() has an NPath complexity of 6720. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        public function getConst(): GlobalConstant
                                                                                                                                        {
                                                                                                                                            $node = $this->node;
                                                                                                                                            if (!$node instanceof Node) {
                                                                                                                                                throw new AssertionError('$node must be a node');
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    NPathComplexity

                                                                                                                                    Since: 0.1

                                                                                                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                    Example

                                                                                                                                    class Foo {
                                                                                                                                        function bar() {
                                                                                                                                            // lots of complicated code
                                                                                                                                        }
                                                                                                                                    }

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

                                                                                                                                    The method analyzeBackwardCompatibility() has an NPath complexity of 483840. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        public function analyzeBackwardCompatibility(): void
                                                                                                                                        {
                                                                                                                                            if (!Config::get_backward_compatibility_checks()) {
                                                                                                                                                return;
                                                                                                                                            }
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    NPathComplexity

                                                                                                                                    Since: 0.1

                                                                                                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                    Example

                                                                                                                                    class Foo {
                                                                                                                                        function bar() {
                                                                                                                                            // lots of complicated code
                                                                                                                                        }
                                                                                                                                    }

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

                                                                                                                                    The method analyzeBackwardCompatibility() has 127 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                                                                                    Open

                                                                                                                                        public function analyzeBackwardCompatibility(): void
                                                                                                                                        {
                                                                                                                                            if (!Config::get_backward_compatibility_checks()) {
                                                                                                                                                return;
                                                                                                                                            }
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    The method getEquivalentPHPValueForNode() has 123 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                                                                                    Open

                                                                                                                                        public function getEquivalentPHPValueForNode($node, int $flags)
                                                                                                                                        {
                                                                                                                                            if (!($node instanceof Node)) {
                                                                                                                                                return $node;
                                                                                                                                            }
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    The method getOrCreateProperty() has an NPath complexity of 200. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        public function getOrCreateProperty(
                                                                                                                                            string $property_name,
                                                                                                                                            bool $is_static
                                                                                                                                        ): Property {
                                                                                                                                    
                                                                                                                                    
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    NPathComplexity

                                                                                                                                    Since: 0.1

                                                                                                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                    Example

                                                                                                                                    class Foo {
                                                                                                                                        function bar() {
                                                                                                                                            // lots of complicated code
                                                                                                                                        }
                                                                                                                                    }

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

                                                                                                                                    The method getProperty() has 267 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                                                                                    Open

                                                                                                                                        public function getProperty(
                                                                                                                                            bool $is_static,
                                                                                                                                            bool $is_known_assignment = false
                                                                                                                                        ): Property {
                                                                                                                                            $node = $this->node;
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    The method getClassConst() has an NPath complexity of 312. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        public function getClassConst(): ClassConstant
                                                                                                                                        {
                                                                                                                                            $node = $this->node;
                                                                                                                                            if (!($node instanceof Node)) {
                                                                                                                                                throw new AssertionError('$this->node must be a node');
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    NPathComplexity

                                                                                                                                    Since: 0.1

                                                                                                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                    Example

                                                                                                                                    class Foo {
                                                                                                                                        function bar() {
                                                                                                                                            // lots of complicated code
                                                                                                                                        }
                                                                                                                                    }

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

                                                                                                                                    The class ContextNode has 2615 lines of code. Current threshold is 1000. Avoid really long classes.
                                                                                                                                    Open

                                                                                                                                    class ContextNode
                                                                                                                                    {
                                                                                                                                    
                                                                                                                                        /** @var CodeBase The code base within which we're operating */
                                                                                                                                        private $code_base;
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    The method getMethod() has an NPath complexity of 909312. The configured NPath complexity threshold is 200.
                                                                                                                                    Open

                                                                                                                                        public function getMethod(
                                                                                                                                            $method_name,
                                                                                                                                            bool $is_static,
                                                                                                                                            bool $is_direct = false,
                                                                                                                                            bool $is_new_expression = false
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    NPathComplexity

                                                                                                                                    Since: 0.1

                                                                                                                                    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                    Example

                                                                                                                                    class Foo {
                                                                                                                                        function bar() {
                                                                                                                                            // lots of complicated code
                                                                                                                                        }
                                                                                                                                    }

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

                                                                                                                                    The method getMethod() has 189 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                                                                                    Open

                                                                                                                                        public function getMethod(
                                                                                                                                            $method_name,
                                                                                                                                            bool $is_static,
                                                                                                                                            bool $is_direct = false,
                                                                                                                                            bool $is_new_expression = false
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

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

                                                                                                                                        public function getEquivalentPHPValueForNode($node, int $flags)
                                                                                                                                        {
                                                                                                                                            if (!($node instanceof Node)) {
                                                                                                                                                return $node;
                                                                                                                                            }
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    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 getFunction() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10.
                                                                                                                                    Open

                                                                                                                                        public function getFunction(
                                                                                                                                            string $function_name,
                                                                                                                                            bool $is_function_declaration = false,
                                                                                                                                            bool $return_placeholder_for_undefined = false
                                                                                                                                        ): FunctionInterface {
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    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 handleTraitPrecedence() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                                                                                                                                    Open

                                                                                                                                        private function handleTraitPrecedence(array $adaptations_map, Node $adaptation_node): void
                                                                                                                                        {
                                                                                                                                            // TODO: Should also verify that the original method exists, in a future PR?
                                                                                                                                            $trait_method_node = $adaptation_node->children['method'];
                                                                                                                                            if (!$trait_method_node instanceof Node) {
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    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 getOrCreateProperty() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                                                                                                                                    Open

                                                                                                                                        public function getOrCreateProperty(
                                                                                                                                            string $property_name,
                                                                                                                                            bool $is_static
                                                                                                                                        ): Property {
                                                                                                                                    
                                                                                                                                    
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    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 analyzeBackwardCompatibility() has a Cyclomatic Complexity of 33. The configured cyclomatic complexity threshold is 10.
                                                                                                                                    Open

                                                                                                                                        public function analyzeBackwardCompatibility(): void
                                                                                                                                        {
                                                                                                                                            if (!Config::get_backward_compatibility_checks()) {
                                                                                                                                                return;
                                                                                                                                            }
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    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 getMethod() has a Cyclomatic Complexity of 40. The configured cyclomatic complexity threshold is 10.
                                                                                                                                    Open

                                                                                                                                        public function getMethod(
                                                                                                                                            $method_name,
                                                                                                                                            bool $is_static,
                                                                                                                                            bool $is_direct = false,
                                                                                                                                            bool $is_new_expression = false
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    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 getProperty() has a Cyclomatic Complexity of 45. The configured cyclomatic complexity threshold is 10.
                                                                                                                                    Open

                                                                                                                                        public function getProperty(
                                                                                                                                            bool $is_static,
                                                                                                                                            bool $is_known_assignment = false
                                                                                                                                        ): Property {
                                                                                                                                            $node = $this->node;
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    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 getClassConst() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                                                                                                                                    Open

                                                                                                                                        public function getClassConst(): ClassConstant
                                                                                                                                        {
                                                                                                                                            $node = $this->node;
                                                                                                                                            if (!($node instanceof Node)) {
                                                                                                                                                throw new AssertionError('$this->node must be a node');
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    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 getClassList() has a Cyclomatic Complexity of 22. The configured cyclomatic complexity threshold is 10.
                                                                                                                                    Open

                                                                                                                                        public function getClassList(
                                                                                                                                            bool $ignore_missing_classes = false,
                                                                                                                                            int $expected_type_categories = self::CLASS_LIST_ACCEPT_ANY,
                                                                                                                                            string $custom_issue_type = null,
                                                                                                                                            bool $warn_if_wrong_type = true
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    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 getClassListInner() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                                                                                                                                    Open

                                                                                                                                        public function getClassListInner(bool $ignore_missing_classes): array
                                                                                                                                        {
                                                                                                                                            $node = $this->node;
                                                                                                                                            if (!($node instanceof Node)) {
                                                                                                                                                if (\is_string($node)) {
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    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 getConst() has a Cyclomatic Complexity of 23. The configured cyclomatic complexity threshold is 10.
                                                                                                                                    Open

                                                                                                                                        public function getConst(): GlobalConstant
                                                                                                                                        {
                                                                                                                                            $node = $this->node;
                                                                                                                                            if (!$node instanceof Node) {
                                                                                                                                                throw new AssertionError('$node must be a node');
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    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 getVariableName() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
                                                                                                                                    Open

                                                                                                                                        public function getVariableName(): string
                                                                                                                                        {
                                                                                                                                            if (!($this->node instanceof Node)) {
                                                                                                                                                return (string)$this->node;
                                                                                                                                            }
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    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 class ContextNode has a coupling between objects value of 51. Consider to reduce the number of dependencies under 13.
                                                                                                                                    Open

                                                                                                                                    class ContextNode
                                                                                                                                    {
                                                                                                                                    
                                                                                                                                        /** @var CodeBase The code base within which we're operating */
                                                                                                                                        private $code_base;
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    CouplingBetweenObjects

                                                                                                                                    Since: 1.1.0

                                                                                                                                    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

                                                                                                                                    Example

                                                                                                                                    class Foo {
                                                                                                                                        /**
                                                                                                                                         * @var \foo\bar\X
                                                                                                                                         */
                                                                                                                                        private $x = null;
                                                                                                                                    
                                                                                                                                        /**
                                                                                                                                         * @var \foo\bar\Y
                                                                                                                                         */
                                                                                                                                        private $y = null;
                                                                                                                                    
                                                                                                                                        /**
                                                                                                                                         * @var \foo\bar\Z
                                                                                                                                         */
                                                                                                                                        private $z = null;
                                                                                                                                    
                                                                                                                                        public function setFoo(\Foo $foo) {}
                                                                                                                                        public function setBar(\Bar $bar) {}
                                                                                                                                        public function setBaz(\Baz $baz) {}
                                                                                                                                    
                                                                                                                                        /**
                                                                                                                                         * @return \SplObjectStorage
                                                                                                                                         * @throws \OutOfRangeException
                                                                                                                                         * @throws \InvalidArgumentException
                                                                                                                                         * @throws \ErrorException
                                                                                                                                         */
                                                                                                                                        public function process(\Iterator $it) {}
                                                                                                                                    
                                                                                                                                        // ...
                                                                                                                                    }

                                                                                                                                    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

                                                                                                                                    Avoid using empty try-catch blocks in getMethod.
                                                                                                                                    Open

                                                                                                                                                        } catch (RecursionDepthException $_) {
                                                                                                                                                        }
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    EmptyCatchBlock

                                                                                                                                    Since: 2.7.0

                                                                                                                                    Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

                                                                                                                                    Example

                                                                                                                                    class Foo {
                                                                                                                                    
                                                                                                                                      public function bar()
                                                                                                                                      {
                                                                                                                                          try {
                                                                                                                                              // ...
                                                                                                                                          } catch (Exception $e) {} // empty catch block
                                                                                                                                      }
                                                                                                                                    }

                                                                                                                                    Source https://phpmd.org/rules/design.html#emptycatchblock

                                                                                                                                    Identical blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                    Open

                                                                                                                                            if (!$this->context->getScope()->hasVariableWithName($variable_name)) {
                                                                                                                                                if (Variable::isHardcodedVariableInScopeWithName($variable_name, $this->context->isInGlobalScope())) {
                                                                                                                                                    // We return a clone of the global or superglobal variable
                                                                                                                                                    // that can't be used to influence the type of that superglobal in other files.
                                                                                                                                                    return new Variable(
                                                                                                                                    Severity: Major
                                                                                                                                    Found in src/Phan/AST/ContextNode.php and 1 other location - About 2 hrs to fix
                                                                                                                                    src/Phan/AST/ContextNode.php on lines 1174..1195

                                                                                                                                    Duplicated Code

                                                                                                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                    Tuning

                                                                                                                                    This issue has a mass of 121.

                                                                                                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                    Refactorings

                                                                                                                                    Further Reading

                                                                                                                                    Identical blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                    Open

                                                                                                                                                if (!$scope->hasVariableWithName($variable_name)) {
                                                                                                                                                    if (Variable::isHardcodedVariableInScopeWithName($variable_name, $this->context->isInGlobalScope())) {
                                                                                                                                                        // We return a clone of the global or superglobal variable
                                                                                                                                                        // that can't be used to influence the type of that superglobal in other files.
                                                                                                                                                        return new Variable(
                                                                                                                                    Severity: Major
                                                                                                                                    Found in src/Phan/AST/ContextNode.php and 1 other location - About 2 hrs to fix
                                                                                                                                    src/Phan/AST/ContextNode.php on lines 1116..1137

                                                                                                                                    Duplicated Code

                                                                                                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                    Tuning

                                                                                                                                    This issue has a mass of 121.

                                                                                                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                    Refactorings

                                                                                                                                    Further Reading

                                                                                                                                    Avoid variables with short names like $e. Configured minimum length is 3.
                                                                                                                                    Open

                                                                                                                                        private function handleErrorInOperation(Node $node, Error $e): void
                                                                                                                                    Severity: Minor
                                                                                                                                    Found in src/Phan/AST/ContextNode.php by phpmd

                                                                                                                                    ShortVariable

                                                                                                                                    Since: 0.2

                                                                                                                                    Detects when a field, local, or parameter has a very short name.

                                                                                                                                    Example

                                                                                                                                    class Something {
                                                                                                                                        private $q = 15; // VIOLATION - Field
                                                                                                                                        public static function main( array $as ) { // VIOLATION - Formal
                                                                                                                                            $r = 20 + $this->q; // VIOLATION - Local
                                                                                                                                            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                                                                                                                                $r += $this->q;
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }

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

                                                                                                                                    There are no issues that match your filters.

                                                                                                                                    Category
                                                                                                                                    Status