src/Phan/Language/Element/Clazz.php

Summary

Maintainability
F
3 wks
Test Coverage

File Clazz.php has 2467 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Phan\Language\Element;
Severity: Major
Found in src/Phan/Language/Element/Clazz.php - About 6 days to fix

    Clazz has 123 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Clazz extends AddressableElement
    {
        use Memoize;
        use ClosedScopeElement;
    
    
    Severity: Major
    Found in src/Phan/Language/Element/Clazz.php - About 2 days to fix

      Method fromReflectionClass has 162 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function fromReflectionClass(
              CodeBase $code_base,
              ReflectionClass $class
          ): Clazz {
              // Build a set of flags based on the constitution
      Severity: Major
      Found in src/Phan/Language/Element/Clazz.php - About 6 hrs to fix

        Method getPropertyByNameInContext has 133 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getPropertyByNameInContext(
                CodeBase $code_base,
                string $name,
                Context $context,
                bool $is_static,
        Severity: Major
        Found in src/Phan/Language/Element/Clazz.php - About 5 hrs to fix

          Function fromReflectionClass has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function fromReflectionClass(
                  CodeBase $code_base,
                  ReflectionClass $class
              ): Clazz {
                  // Build a set of flags based on the constitution
          Severity: Minor
          Found in src/Phan/Language/Element/Clazz.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 getPropertyByNameInContext has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getPropertyByNameInContext(
                  CodeBase $code_base,
                  string $name,
                  Context $context,
                  bool $is_static,
          Severity: Minor
          Found in src/Phan/Language/Element/Clazz.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 addMethod has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              public function addMethod(
                  CodeBase $code_base,
                  Method $method,
                  Option $type_option
              ): void {
          Severity: Minor
          Found in src/Phan/Language/Element/Clazz.php - About 3 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

          The class Clazz has 51 non-getter- and setter-methods. Consider refactoring Clazz to keep number of methods under 25.
          Open

          class Clazz extends AddressableElement
          {
              use Memoize;
              use ClosedScopeElement;
          
          
          Severity: Minor
          Found in src/Phan/Language/Element/Clazz.php by phpmd

          TooManyMethods

          Since: 0.1

          A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

          By default it ignores methods starting with 'get' or 'set'.

          The default was changed from 10 to 25 in PHPMD 2.3.

          Example

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

          The class Clazz has 27 public methods. Consider refactoring Clazz to keep number of public methods under 10.
          Open

          class Clazz extends AddressableElement
          {
              use Memoize;
              use ClosedScopeElement;
          
          
          Severity: Minor
          Found in src/Phan/Language/Element/Clazz.php by phpmd

          TooManyPublicMethods

          Since: 0.1

          A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

          By default it ignores methods starting with 'get' or 'set'.

          Example

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

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

          class Clazz extends AddressableElement
          {
              use Memoize;
              use ClosedScopeElement;
          
          
          Severity: Minor
          Found in src/Phan/Language/Element/Clazz.php by phpmd

          Method addMethod has 78 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function addMethod(
                  CodeBase $code_base,
                  Method $method,
                  Option $type_option
              ): void {
          Severity: Major
          Found in src/Phan/Language/Element/Clazz.php - About 3 hrs to fix

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

                private function importMixin(CodeBase $code_base, Type $type): void
                {
                    $fqsen = FullyQualifiedClassName::fromType($type);
                    if (!$code_base->hasClassWithFQSEN($fqsen) || $fqsen === $this->fqsen) {
                        Issue::maybeEmit(
            Severity: Minor
            Found in src/Phan/Language/Element/Clazz.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 getConstantByNameInContext has 62 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getConstantByNameInContext(
                    CodeBase $code_base,
                    string $name,
                    Context $context
                ): ClassConstant {
            Severity: Major
            Found in src/Phan/Language/Element/Clazz.php - About 2 hrs to fix

              Method importAncestorClass has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function importAncestorClass(
                      CodeBase $code_base,
                      Clazz $class,
                      Option $type_option
                  ): void {
              Severity: Major
              Found in src/Phan/Language/Element/Clazz.php - About 2 hrs to fix

                Function importAncestorClass has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function importAncestorClass(
                        CodeBase $code_base,
                        Clazz $class,
                        Option $type_option
                    ): void {
                Severity: Minor
                Found in src/Phan/Language/Element/Clazz.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

                Function toStubSignature has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function toStubSignature(CodeBase $code_base): string
                    {
                        $string = '';
                
                        if ($this->isFinal()) {
                Severity: Minor
                Found in src/Phan/Language/Element/Clazz.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 adaptInheritedMethodFromTrait has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function adaptInheritedMethodFromTrait(Method $method): Method
                    {
                        $method_flags = $method->getFlags();
                        if (Flags::bitVectorHasState($method_flags, \ast\flags\MODIFIER_PRIVATE)) {
                            $method = $method->createUseAlias($this, $method->getName(), \ast\flags\MODIFIER_PRIVATE);
                Severity: Major
                Found in src/Phan/Language/Element/Clazz.php - About 2 hrs to fix

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

                      private function adaptInheritedMethodFromTrait(Method $method): Method
                      {
                          $method_flags = $method->getFlags();
                          if (Flags::bitVectorHasState($method_flags, \ast\flags\MODIFIER_PRIVATE)) {
                              $method = $method->createUseAlias($this, $method->getName(), \ast\flags\MODIFIER_PRIVATE);
                  Severity: Minor
                  Found in src/Phan/Language/Element/Clazz.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 addProperty has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function addProperty(
                          CodeBase $code_base,
                          Property $property,
                          Option $type_option,
                          bool $from_trait = false
                  Severity: Minor
                  Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                    Function importAncestorClasses has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function importAncestorClasses(CodeBase $code_base): void
                        {
                            if (!$this->isFirstExecution(__METHOD__)) {
                                return;
                            }
                    Severity: Minor
                    Found in src/Phan/Language/Element/Clazz.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 checkPropertyCompatibility has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private static function checkPropertyCompatibility(
                            CodeBase $code_base,
                            Property $inherited_property,
                            Property $overriding_property
                        ): void {
                    Severity: Minor
                    Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                      Method setMagicMethodMap has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function setMagicMethodMap(
                              array $magic_method_map,
                              CodeBase $code_base
                          ): bool {
                              if (count($magic_method_map) === 0) {
                      Severity: Minor
                      Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                        Method toStubSignature has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function toStubSignature(CodeBase $code_base): string
                            {
                                $string = '';
                        
                                if ($this->isFinal()) {
                        Severity: Minor
                        Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

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

                              public function setParentType(Type $parent_type, int $lineno = 0): void
                              {
                                  if ($this->getInternalScope()->hasAnyTemplateType()) {
                                      // Get a reference to the local list of templated
                                      // types. We'll use this to map templated types on the
                          Severity: Minor
                          Found in src/Phan/Language/Element/Clazz.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 checkPropertyCompatibility has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private static function checkPropertyCompatibility(
                                  CodeBase $code_base,
                                  Property $inherited_property,
                                  Property $overriding_property
                              ): void {
                          Severity: Minor
                          Found in src/Phan/Language/Element/Clazz.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 toStubInfo has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function toStubInfo(CodeBase $code_base): array
                              {
                                  $signature = $this->toStubSignature($code_base);
                          
                                  $stub = $signature;
                          Severity: Minor
                          Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

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

                                private function importMixin(CodeBase $code_base, Type $type): void
                                {
                                    $fqsen = FullyQualifiedClassName::fromType($type);
                                    if (!$code_base->hasClassWithFQSEN($fqsen) || $fqsen === $this->fqsen) {
                                        Issue::maybeEmit(
                            Severity: Minor
                            Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

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

                                  public function importAncestorClasses(CodeBase $code_base): void
                                  {
                                      if (!$this->isFirstExecution(__METHOD__)) {
                                          return;
                                      }
                              Severity: Minor
                              Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                                Method inheritConstant has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function inheritConstant(
                                        CodeBase $code_base,
                                        ClassConstant $constant
                                    ): void {
                                        $constant_fqsen = FullyQualifiedClassConstantName::make(
                                Severity: Minor
                                Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                                  Method hydrateConstantsOnce has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      protected function hydrateConstantsOnce(CodeBase $code_base): void
                                      {
                                          foreach ($this->getAncestorFQSENList() as $fqsen) {
                                              if ($code_base->hasClassWithFQSEN($fqsen)) {
                                                  $code_base->getClassByFQSENWithoutHydrating(
                                  Severity: Minor
                                  Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

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

                                        final public function analyze(CodeBase $code_base): void
                                        {
                                            if ($this->isPHPInternal()) {
                                                return;
                                            }
                                    Severity: Minor
                                    Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                                      Function analyzeInheritedMethods has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          private function analyzeInheritedMethods(CodeBase $code_base): void
                                          {
                                              if ($this->isClass() && !$this->isAbstract()) {
                                                  foreach ($this->getMethodMap($code_base) as $method) {
                                                      if ($method->getRealDefiningFQSEN() === $method->getFQSEN()) {
                                      Severity: Minor
                                      Found in src/Phan/Language/Element/Clazz.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 addProperty has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public function addProperty(
                                              CodeBase $code_base,
                                              Property $property,
                                              Option $type_option,
                                              bool $from_trait = false
                                      Severity: Minor
                                      Found in src/Phan/Language/Element/Clazz.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 getGenericConstructorBuilder has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          public function getGenericConstructorBuilder(CodeBase $code_base): array
                                          {
                                              return $this->memoize(
                                                  'template_type_resolvers',
                                                  /**
                                      Severity: Minor
                                      Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

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

                                            public function setMagicPropertyMap(
                                                array $magic_property_map,
                                                CodeBase $code_base
                                            ): bool {
                                                if (count($magic_property_map) === 0) {
                                        Severity: Minor
                                        Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

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

                                              private function getSettersMap(CodeBase $code_base): array
                                              {
                                                  return $this->memoize(
                                                      __METHOD__,
                                                      /**
                                          Severity: Minor
                                          Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                                            The class Clazz has 92 public methods and attributes. Consider reducing the number of public items to less than 45.
                                            Open

                                            class Clazz extends AddressableElement
                                            {
                                                use Memoize;
                                                use ClosedScopeElement;
                                            
                                            
                                            Severity: Minor
                                            Found in src/Phan/Language/Element/Clazz.php by phpmd

                                            ExcessivePublicCount

                                            Since: 0.1

                                            A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

                                            Example

                                            public class Foo {
                                                public $value;
                                                public $something;
                                                public $var;
                                                // [... more more public attributes ...]
                                            
                                                public function doWork() {}
                                                public function doMoreWork() {}
                                                public function doWorkAgain() {}
                                                // [... more more public methods ...]
                                            }

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

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

                                                public function setParentType(Type $parent_type, int $lineno = 0): void
                                                {
                                                    if ($this->getInternalScope()->hasAnyTemplateType()) {
                                                        // Get a reference to the local list of templated
                                                        // types. We'll use this to map templated types on the
                                            Severity: Minor
                                            Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

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

                                                  public function setMagicMethodMap(
                                                      array $magic_method_map,
                                                      CodeBase $code_base
                                                  ): bool {
                                                      if (count($magic_method_map) === 0) {
                                              Severity: Minor
                                              Found in src/Phan/Language/Element/Clazz.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 checkConstantCompatibility has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  private static function checkConstantCompatibility(
                                                      CodeBase $code_base,
                                                      ClassConstant $inherited_constant,
                                                      ClassConstant $overriding_constant
                                                  ): void {
                                              Severity: Minor
                                              Found in src/Phan/Language/Element/Clazz.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 getAncestorElement has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  public static function getAncestorElement(CodeBase $code_base, FullyQualifiedClassName $ancestor_fqsen, ClassElement $element): ?ClassElement
                                                  {
                                                      if (!$code_base->hasClassWithFQSEN($ancestor_fqsen)) {
                                                          return null;
                                                      }
                                              Severity: Minor
                                              Found in src/Phan/Language/Element/Clazz.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 getGettersMap has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                              Open

                                                  public function getGettersMap(CodeBase $code_base): array
                                                  {
                                                      if ($this->isInterface()) {
                                                          return [];
                                                      }
                                              Severity: Minor
                                              Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                                                Method checkConstantCompatibility has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                                Open

                                                    private static function checkConstantCompatibility(
                                                        CodeBase $code_base,
                                                        ClassConstant $inherited_constant,
                                                        ClassConstant $overriding_constant
                                                    ): void {
                                                Severity: Minor
                                                Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                                                  Method importParentClass has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                                  Open

                                                      private function importParentClass(CodeBase $code_base): void
                                                      {
                                                          if (!$this->isFirstExecution(__METHOD__)) {
                                                              return;
                                                          }
                                                  Severity: Minor
                                                  Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                                                    Method importTraitAdaptations has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                                    Open

                                                        private function importTraitAdaptations(
                                                            CodeBase $code_base,
                                                            Clazz $class,
                                                            TraitAdaptations $trait_adaptations,
                                                            Option $type_option
                                                    Severity: Minor
                                                    Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                                                      Method getAncestorElement has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                                      Open

                                                          public static function getAncestorElement(CodeBase $code_base, FullyQualifiedClassName $ancestor_fqsen, ClassElement $element): ?ClassElement
                                                          {
                                                              if (!$code_base->hasClassWithFQSEN($ancestor_fqsen)) {
                                                                  return null;
                                                              }
                                                      Severity: Minor
                                                      Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                                                        Method emitWrongInheritanceCategoryWarning has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                                        Open

                                                            private function emitWrongInheritanceCategoryWarning(
                                                                CodeBase $code_base,
                                                                Clazz $ancestor,
                                                                string $expected_inheritance_category,
                                                                int $lineno
                                                        Severity: Minor
                                                        Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

                                                          Method __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                                          Open

                                                                  Context $context,
                                                                  string $name,
                                                                  UnionType $type,
                                                                  int $flags,
                                                                  FullyQualifiedClassName $fqsen,
                                                          Severity: Major
                                                          Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

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

                                                                public function importConstantsFromAncestorClasses(CodeBase $code_base): void
                                                                {
                                                                    if (!$this->isFirstExecution(__METHOD__)) {
                                                                        return;
                                                                    }
                                                            Severity: Minor
                                                            Found in src/Phan/Language/Element/Clazz.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 getMarkupDescription has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                                public function getMarkupDescription(): string
                                                                {
                                                                    $fqsen = $this->getFQSEN();
                                                                    $string = '';
                                                                    $namespace = \ltrim($fqsen->getNamespace(), '\\');
                                                            Severity: Minor
                                                            Found in src/Phan/Language/Element/Clazz.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 resolveParentTemplateType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                                public function resolveParentTemplateType(array $template_parameter_type_map): UnionType
                                                                {
                                                                    if (\count($template_parameter_type_map) === 0) {
                                                                        return UnionType::empty();
                                                                    }
                                                            Severity: Minor
                                                            Found in src/Phan/Language/Element/Clazz.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 importTraitAdaptations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                                private function importTraitAdaptations(
                                                                    CodeBase $code_base,
                                                                    Clazz $class,
                                                                    TraitAdaptations $trait_adaptations,
                                                                    Option $type_option
                                                            Severity: Minor
                                                            Found in src/Phan/Language/Element/Clazz.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 hasFlagsRecursive has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                                private function hasFlagsRecursive(CodeBase $code_base, int $flags): bool
                                                                {
                                                                    $current = $this;
                                                                    $checked = [];
                                                                    while (true) {
                                                            Severity: Minor
                                                            Found in src/Phan/Language/Element/Clazz.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 addReference has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                                public function addReference(FileRef $file_ref): void
                                                                {
                                                                    if (Config::get_track_references()) {
                                                                        // Currently, we don't need to track references to PHP-internal methods/functions/constants
                                                                        // such as PHP_VERSION, strlen(), Closure::bind(), etc.
                                                            Severity: Minor
                                                            Found in src/Phan/Language/Element/Clazz.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 analyzePropertyOverrides has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                                private static function analyzePropertyOverrides(CodeBase $code_base, array $original_declared_properties): void
                                                                {
                                                                    foreach ($original_declared_properties as $property) {
                                                                        if ($property->isOverrideIntended() && !$property->isOverride()) {
                                                                            if ($property->checkHasSuppressIssueAndIncrementCount(Issue::CommentOverrideOnNonOverrideProperty)) {
                                                            Severity: Minor
                                                            Found in src/Phan/Language/Element/Clazz.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

                                                            Method getPropertyByNameInContext has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                            Open

                                                                    CodeBase $code_base,
                                                                    string $name,
                                                                    Context $context,
                                                                    bool $is_static,
                                                                    Node $node = null,
                                                            Severity: Minor
                                                            Found in src/Phan/Language/Element/Clazz.php - About 45 mins to fix

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

                                                                  private static function analyzeClassConstantOverrides(CodeBase $code_base, array $original_declared_class_constants): void
                                                                  {
                                                                      foreach ($original_declared_class_constants as $constant) {
                                                                          if ($constant->isOverrideIntended() && !$constant->isOverride()) {
                                                                              if ($constant->checkHasSuppressIssueAndIncrementCount(Issue::CommentOverrideOnNonOverrideConstant)) {
                                                              Severity: Minor
                                                              Found in src/Phan/Language/Element/Clazz.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

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                              return false;
                                                              Severity: Major
                                                              Found in src/Phan/Language/Element/Clazz.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                            return true;
                                                                Severity: Major
                                                                Found in src/Phan/Language/Element/Clazz.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                          return null;
                                                                  Severity: Major
                                                                  Found in src/Phan/Language/Element/Clazz.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                                return $ancestor_class->getPropertyByName($code_base, $name);
                                                                    Severity: Major
                                                                    Found in src/Phan/Language/Element/Clazz.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                                  return $prop_name;
                                                                      Severity: Major
                                                                      Found in src/Phan/Language/Element/Clazz.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                        return $method->toStub($is_interface);
                                                                        Severity: Major
                                                                        Found in src/Phan/Language/Element/Clazz.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                      return $code_base->getClassConstantByFQSEN($constant_fqsen);
                                                                          Severity: Major
                                                                          Found in src/Phan/Language/Element/Clazz.php - About 30 mins to fix

                                                                            Avoid too many return statements within this method.
                                                                            Open

                                                                                    return null;
                                                                            Severity: Major
                                                                            Found in src/Phan/Language/Element/Clazz.php - About 30 mins to fix

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                              return null;
                                                                              Severity: Major
                                                                              Found in src/Phan/Language/Element/Clazz.php - About 30 mins to fix

                                                                                Avoid too many return statements within this method.
                                                                                Open

                                                                                        return [$namespace, $stub];
                                                                                Severity: Major
                                                                                Found in src/Phan/Language/Element/Clazz.php - About 30 mins to fix

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

                                                                                          return Type::fromType($this->parent_type, $parent_template_parameter_type_list)->asPHPDocUnionType();
                                                                                  Severity: Major
                                                                                  Found in src/Phan/Language/Element/Clazz.php - About 30 mins to fix

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

                                                                                                            return $mapped_parameter;
                                                                                    Severity: Major
                                                                                    Found in src/Phan/Language/Element/Clazz.php - About 30 mins to fix

                                                                                      Function importParentClass has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                      Open

                                                                                          private function importParentClass(CodeBase $code_base): void
                                                                                          {
                                                                                              if (!$this->isFirstExecution(__METHOD__)) {
                                                                                                  return;
                                                                                              }
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php - About 25 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 computeSetPropertyName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                      Open

                                                                                          private static function computeSetPropertyName(Node $node, string $expected_parameter_name): ?string
                                                                                          {
                                                                                              if (count($node->children) !== 1) {
                                                                                                  return null;
                                                                                              }
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php - About 25 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 getLinenoOfAncestorReference has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                      Open

                                                                                          public function getLinenoOfAncestorReference(FullyQualifiedClassName $fqsen): int
                                                                                          {
                                                                                              $class_line = $this->getFileRef()->getLineNumberStart();
                                                                                              foreach ($this->interface_fqsen_list as $i => $interface_fqsen) {
                                                                                                  if ($interface_fqsen === $fqsen) {
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php - About 25 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 getConstantByNameInContext has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                      Open

                                                                                          public function getConstantByNameInContext(
                                                                                              CodeBase $code_base,
                                                                                              string $name,
                                                                                              Context $context
                                                                                          ): ClassConstant {
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php - About 25 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 emitWrongInheritanceCategoryWarning has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                      Open

                                                                                          private function emitWrongInheritanceCategoryWarning(
                                                                                              CodeBase $code_base,
                                                                                              Clazz $ancestor,
                                                                                              string $expected_inheritance_category,
                                                                                              int $lineno
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php - About 25 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 emitExtendsFinalClassWarning has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                      Open

                                                                                          private function emitExtendsFinalClassWarning(
                                                                                              CodeBase $code_base,
                                                                                              Clazz $ancestor
                                                                                          ): void {
                                                                                              $context = $this->getContext();
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php - About 25 mins to fix

                                                                                      Cognitive Complexity

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

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

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

                                                                                      Further reading

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

                                                                                          public function addMethod(
                                                                                              CodeBase $code_base,
                                                                                              Method $method,
                                                                                              Option $type_option
                                                                                          ): void {
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 getPropertyByNameInContext() has an NPath complexity of 4480. The configured NPath complexity threshold is 200.
                                                                                      Open

                                                                                          public function getPropertyByNameInContext(
                                                                                              CodeBase $code_base,
                                                                                              string $name,
                                                                                              Context $context,
                                                                                              bool $is_static,
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 addMethod() has 122 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                                      Open

                                                                                          public function addMethod(
                                                                                              CodeBase $code_base,
                                                                                              Method $method,
                                                                                              Option $type_option
                                                                                          ): void {
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php by phpmd

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

                                                                                      class Clazz extends AddressableElement
                                                                                      {
                                                                                          use Memoize;
                                                                                          use ClosedScopeElement;
                                                                                      
                                                                                      
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php by phpmd

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

                                                                                          private function importMixin(CodeBase $code_base, Type $type): void
                                                                                          {
                                                                                              $fqsen = FullyQualifiedClassName::fromType($type);
                                                                                              if (!$code_base->hasClassWithFQSEN($fqsen) || $fqsen === $this->fqsen) {
                                                                                                  Issue::maybeEmit(
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 importAncestorClass() has an NPath complexity of 1512. The configured NPath complexity threshold is 200.
                                                                                      Open

                                                                                          public function importAncestorClass(
                                                                                              CodeBase $code_base,
                                                                                              Clazz $class,
                                                                                              Option $type_option
                                                                                          ): void {
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 fromReflectionClass() has an NPath complexity of 96000. The configured NPath complexity threshold is 200.
                                                                                      Open

                                                                                          public static function fromReflectionClass(
                                                                                              CodeBase $code_base,
                                                                                              ReflectionClass $class
                                                                                          ): Clazz {
                                                                                              // Build a set of flags based on the constitution
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 fromReflectionClass() has 226 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                                      Open

                                                                                          public static function fromReflectionClass(
                                                                                              CodeBase $code_base,
                                                                                              ReflectionClass $class
                                                                                          ): Clazz {
                                                                                              // Build a set of flags based on the constitution
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php by phpmd

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

                                                                                          private function toStubSignature(CodeBase $code_base): string
                                                                                          {
                                                                                              $string = '';
                                                                                      
                                                                                              if ($this->isFinal()) {
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 adaptInheritedMethodFromTrait() has an NPath complexity of 300. The configured NPath complexity threshold is 200.
                                                                                      Open

                                                                                          private function adaptInheritedMethodFromTrait(Method $method): Method
                                                                                          {
                                                                                              $method_flags = $method->getFlags();
                                                                                              if (Flags::bitVectorHasState($method_flags, \ast\flags\MODIFIER_PRIVATE)) {
                                                                                                  $method = $method->createUseAlias($this, $method->getName(), \ast\flags\MODIFIER_PRIVATE);
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 getPropertyByNameInContext() has 171 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                                      Open

                                                                                          public function getPropertyByNameInContext(
                                                                                              CodeBase $code_base,
                                                                                              string $name,
                                                                                              Context $context,
                                                                                              bool $is_static,
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php by phpmd

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

                                                                                          public function importAncestorClass(
                                                                                              CodeBase $code_base,
                                                                                              Clazz $class,
                                                                                              Option $type_option
                                                                                          ): void {
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 getPropertyByNameInContext() has a Cyclomatic Complexity of 24. The configured cyclomatic complexity threshold is 10.
                                                                                      Open

                                                                                          public function getPropertyByNameInContext(
                                                                                              CodeBase $code_base,
                                                                                              string $name,
                                                                                              Context $context,
                                                                                              bool $is_static,
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 toStubSignature() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
                                                                                      Open

                                                                                          private function toStubSignature(CodeBase $code_base): string
                                                                                          {
                                                                                              $string = '';
                                                                                      
                                                                                              if ($this->isFinal()) {
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 fromReflectionClass() has a Cyclomatic Complexity of 21. The configured cyclomatic complexity threshold is 10.
                                                                                      Open

                                                                                          public static function fromReflectionClass(
                                                                                              CodeBase $code_base,
                                                                                              ReflectionClass $class
                                                                                          ): Clazz {
                                                                                              // Build a set of flags based on the constitution
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 adaptInheritedMethodFromTrait() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                                                                                      Open

                                                                                          private function adaptInheritedMethodFromTrait(Method $method): Method
                                                                                          {
                                                                                              $method_flags = $method->getFlags();
                                                                                              if (Flags::bitVectorHasState($method_flags, \ast\flags\MODIFIER_PRIVATE)) {
                                                                                                  $method = $method->createUseAlias($this, $method->getName(), \ast\flags\MODIFIER_PRIVATE);
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 checkPropertyCompatibility() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                                                                                      Open

                                                                                          private static function checkPropertyCompatibility(
                                                                                              CodeBase $code_base,
                                                                                              Property $inherited_property,
                                                                                              Property $overriding_property
                                                                                          ): void {
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 addMethod() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10.
                                                                                      Open

                                                                                          public function addMethod(
                                                                                              CodeBase $code_base,
                                                                                              Method $method,
                                                                                              Option $type_option
                                                                                          ): void {
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 importMixin() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
                                                                                      Open

                                                                                          private function importMixin(CodeBase $code_base, Type $type): void
                                                                                          {
                                                                                              $fqsen = FullyQualifiedClassName::fromType($type);
                                                                                              if (!$code_base->hasClassWithFQSEN($fqsen) || $fqsen === $this->fqsen) {
                                                                                                  Issue::maybeEmit(
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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 Clazz has a coupling between objects value of 51. Consider to reduce the number of dependencies under 13.
                                                                                      Open

                                                                                      class Clazz extends AddressableElement
                                                                                      {
                                                                                          use Memoize;
                                                                                          use ClosedScopeElement;
                                                                                      
                                                                                      
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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

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

                                                                                              foreach ($real_parameter_list as $i => $parameter) {
                                                                                                  $old_type = $parameter->getNonVariadicUnionType();
                                                                                                  $type = $old_type->withSelfResolvedInContext($context);
                                                                                                  if ($type->hasStaticType()) {
                                                                                                      $type = $type->withType($this->getFQSEN()->asType());
                                                                                      Severity: Major
                                                                                      Found in src/Phan/Language/Element/Clazz.php and 1 other location - About 1 hr to fix
                                                                                      src/Phan/Language/Element/Clazz.php on lines 2800..2812

                                                                                      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 106.

                                                                                      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

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

                                                                                              foreach ($parameter_list as $i => $parameter) {
                                                                                                  $old_type = $parameter->getNonVariadicUnionType();
                                                                                                  $type = $old_type->withSelfResolvedInContext($context);
                                                                                                  if ($type->hasStaticType()) {
                                                                                                      $type = $type->withType($this->getFQSEN()->asType());
                                                                                      Severity: Major
                                                                                      Found in src/Phan/Language/Element/Clazz.php and 1 other location - About 1 hr to fix
                                                                                      src/Phan/Language/Element/Clazz.php on lines 2819..2831

                                                                                      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 106.

                                                                                      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

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

                                                                                          private static function analyzePropertyOverrides(CodeBase $code_base, array $original_declared_properties): void
                                                                                          {
                                                                                              foreach ($original_declared_properties as $property) {
                                                                                                  if ($property->isOverrideIntended() && !$property->isOverride()) {
                                                                                                      if ($property->checkHasSuppressIssueAndIncrementCount(Issue::CommentOverrideOnNonOverrideProperty)) {
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php and 1 other location - About 45 mins to fix
                                                                                      src/Phan/Language/Element/Clazz.php on lines 3228..3245

                                                                                      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 96.

                                                                                      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

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

                                                                                          private static function analyzeClassConstantOverrides(CodeBase $code_base, array $original_declared_class_constants): void
                                                                                          {
                                                                                              foreach ($original_declared_class_constants as $constant) {
                                                                                                  if ($constant->isOverrideIntended() && !$constant->isOverride()) {
                                                                                                      if ($constant->checkHasSuppressIssueAndIncrementCount(Issue::CommentOverrideOnNonOverrideConstant)) {
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php and 1 other location - About 45 mins to fix
                                                                                      src/Phan/Language/Element/Clazz.php on lines 3250..3267

                                                                                      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 96.

                                                                                      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

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

                                                                                              foreach ($this->interface_fqsen_list as $i => $fqsen) {
                                                                                                  if (!$code_base->hasClassWithFQSEN($fqsen)) {
                                                                                                      continue;
                                                                                                  }
                                                                                      
                                                                                      
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php and 1 other location - About 40 mins to fix
                                                                                      src/Phan/Language/Element/Clazz.php on lines 2392..2407

                                                                                      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 94.

                                                                                      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

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

                                                                                              foreach ($this->trait_fqsen_list as $i => $fqsen) {
                                                                                                  if (!$code_base->hasClassWithFQSEN($fqsen)) {
                                                                                                      continue;
                                                                                                  }
                                                                                      
                                                                                      
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php and 1 other location - About 40 mins to fix
                                                                                      src/Phan/Language/Element/Clazz.php on lines 2374..2390

                                                                                      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 94.

                                                                                      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

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

                                                                                          public function getParentClass(CodeBase $code_base): Clazz
                                                                                          {
                                                                                              if (!$this->parent_type) {
                                                                                                  throw new LogicException("Class $this has no parent");
                                                                                              }
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php and 1 other location - About 30 mins to fix
                                                                                      src/Phan/Language/Element/Clazz.php on lines 580..596

                                                                                      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 90.

                                                                                      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

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

                                                                                          private function getParentClassWithoutHydrating(CodeBase $code_base): Clazz
                                                                                          {
                                                                                              if (!$this->parent_type) {
                                                                                                  throw new LogicException("Class $this has no parent");
                                                                                              }
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.php and 1 other location - About 30 mins to fix
                                                                                      src/Phan/Language/Element/Clazz.php on lines 555..571

                                                                                      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 90.

                                                                                      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 $id. Configured minimum length is 3.
                                                                                      Open

                                                                                          public function setDeclId(int $id): void
                                                                                      Severity: Minor
                                                                                      Found in src/Phan/Language/Element/Clazz.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