Showing 3,272 of 4,939 total issues

Consider simplifying this complex logical expression.
Open

        if ($left_is_array_like
            && !$right->hasArrayLike()
            && !$right_can_cast_to_array
            && !$right->isEmpty()
            && !$right->containsNullable()
Severity: Critical
Found in src/Phan/Analysis/BinaryOperatorFlagVisitor.php - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

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

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

          public static function addParamsToScopeOfFunctionOrMethod(
              Context $context,
              CodeBase $code_base,
              FunctionInterface $function,
              Comment $comment
      Severity: Major
      Found in src/Phan/Language/Element/FunctionTrait.php - About 2 hrs to fix

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

            public function asExpandedTypes(
                CodeBase $code_base,
                int $recursion_depth = 0
            ): UnionType {
                // We're going to assume that if the type hierarchy
        Severity: Major
        Found in src/Phan/Language/Type/GenericIterableType.php - About 2 hrs to fix

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

              public function canCastToUnionTypeHandlingTemplates(
                  UnionType $target,
                  CodeBase $code_base
              ): bool {
                  // Fast-track most common cases first
          Severity: Major
          Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

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

                public function asExpandedTypesPreservingTemplate(
                    CodeBase $code_base,
                    int $recursion_depth = 0
                ): UnionType {
                    // We're going to assume that if the type hierarchy
            Severity: Major
            Found in src/Phan/Language/Type/GenericIterableType.php - About 2 hrs to fix

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

                  private static function addEntriesForClass(
                      CtagsEntrySet $entries,
                      CodeBase $code_base,
                      FullyQualifiedClassName $class_fqsen,
                      Clazz $class
              Severity: Major
              Found in src/Phan/Plugin/Internal/CtagsPlugin.php - About 2 hrs to fix

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

                    public function analyzeCallableWithArgumentTypes(
                        array $argument_types,
                        FunctionInterface $method,
                        array $arguments = [],
                        bool $erase_old_return_type = false
                Severity: Major
                Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 2 hrs to fix

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

                      private function analyzeMethodWithArgumentTypes(
                          Node $argument_list_node,
                          FunctionInterface $method
                      ): void {
                          $method = $this->findDefiningMethod($method);
                  Severity: Major
                  Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 2 hrs to fix

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

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

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

                          public static function parseFile(CodeBase $code_base, string $file_path, bool $suppress_parse_errors = false, string $override_contents = null, bool $is_php_internal_stub = false, ?Request $request = null): Context
                          {
                              $original_file_path = $file_path;
                              $code_base->setCurrentParsedFile($file_path);
                              if ($is_php_internal_stub) {
                      Severity: Major
                      Found in src/Phan/Analysis.php - About 2 hrs to fix

                        File DuplicateArrayKeyPlugin.php has 262 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        <?php
                        
                        declare(strict_types=1);
                        
                        use ast\Node;
                        Severity: Minor
                        Found in .phan/plugins/DuplicateArrayKeyPlugin.php - About 2 hrs to fix

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

                              private function magicMethodFromCommentLine(
                                  string $line,
                                  int $comment_line_offset
                              ): ?Method {
                                  // https://phpdoc.org/docs/latest/references/phpdoc/tags/method.html
                          Severity: Major
                          Found in src/Phan/Language/Element/Comment/Builder.php - About 2 hrs to fix

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

                                private function dumpClassDot(string $title, array $graph = null): void
                                {
                                    if (!$graph) {
                                        $graph = $this->cgraph;
                                    }
                            Severity: Major
                            Found in src/Phan/Plugin/Internal/DependencyGraphPlugin.php - About 2 hrs to fix

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

                                  public function finalizeProcess(CodeBase $code_base): void
                                  {
                                      if (!self::$use_dynamic) {
                                          return;
                                      }
                              Severity: Major
                              Found in src/Phan/Plugin/Internal/UseReturnValuePlugin.php - About 2 hrs to fix

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

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

                                  Function canCastToNonNullableTypeWithoutConfig has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function canCastToNonNullableTypeWithoutConfig(Type $type): bool
                                      {
                                          if ($type instanceof ArrayType) {
                                              if ($type instanceof GenericArrayType) {
                                                  if (!$this->element_type->canCastToTypeWithoutConfig($type->element_type)) {
                                  Severity: Minor
                                  Found in src/Phan/Language/Type/GenericArrayType.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 canCastToUnionTypeWithoutConfig has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function canCastToUnionTypeWithoutConfig(
                                          UnionType $target
                                      ): bool {
                                          // Fast-track most common cases first
                                          $type_set = $this->type_set;
                                  Severity: Minor
                                  Found in src/Phan/Language/UnionType.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 internalFunctionSignatureMap has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public static function internalFunctionSignatureMap(int $target_php_version): array
                                      {
                                          static $php73_map = [];
                                  
                                          if (!$php73_map) {
                                  Severity: Minor
                                  Found in src/Phan/Language/UnionType.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 genericArrayElementTypes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function genericArrayElementTypes(bool $add_real_types = false): UnionType
                                      {
                                          // This is frequently called, and has been optimized
                                          $result = [];
                                          $type_set = $this->type_set;
                                  Severity: Minor
                                  Found in src/Phan/Language/UnionType.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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language