Showing 3,272 of 4,939 total issues

Function createPhanSettingsForComposerSettings has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    public static function createPhanSettingsForComposerSettings(array $composer_settings, ?string $vendor_path, array $opts): InitializedSettings
    {
        $level = $opts['init-level'] ?? 3;
        $level = self::LEVEL_MAP[\strtolower((string)$level)] ?? $level;
        if (\filter_var($level, FILTER_VALIDATE_INT) === false) {
Severity: Minor
Found in src/Phan/Config/Initializer.php - About 5 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Function checkComplexIsset has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkComplexIsset(Node $node): Context
    {
        // Loop to support getting the var name in is_array($x['field'][0])
        $has_prop_access = false;
        $context = $this->context;
Severity: Minor
Found in src/Phan/Analysis/ConditionVisitor.php - About 5 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Function analyzeGenericArrayAssignment has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    private function analyzeGenericArrayAssignment(Node $node): void
    {
        // Figure out the type of elements in the list
        $right_type = $this->right_type;
        if ($right_type->isEmpty()) {
Severity: Minor
Found in src/Phan/Analysis/AssignmentVisitor.php - About 5 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Function findNodeAtOffsetRecursive has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    private static function findNodeAtOffsetRecursive(\Microsoft\PhpParser\Node $parser_node, int $offset)
    {
        foreach ($parser_node->getChildNodesAndTokens() as $key => $node_or_token) {
            if ($node_or_token instanceof Token) {
                // fprintf(

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 analyzeReturnTypesInner has 127 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function analyzeReturnTypesInner(CodeBase $code_base): void
    {
        if ($this->isPHPInternal()) {
            // nothing to do, no known Node
            return;
Severity: Major
Found in src/Phan/Language/Element/FunctionTrait.php - About 5 hrs to fix

    Method warnInvalidArgumentType has 127 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function warnInvalidArgumentType(
            CodeBase $code_base,
            Context $context,
            FunctionInterface $method,
            Parameter $alternate_parameter,
    Severity: Major
    Found in src/Phan/Analysis/ArgumentType.php - About 5 hrs to fix

      Method visitSwitchList has 126 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function visitSwitchList(Node $node): Context
          {
              // Make a copy of the internal context so that we don't
              // leak any changes within the closed context to the
              // outer scope
      Severity: Major
      Found in src/Phan/BlockAnalysisVisitor.php - About 5 hrs to fix

        File Analysis.php has 373 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        declare(strict_types=1);
        
        namespace Phan;
        Severity: Minor
        Found in src/Phan/Analysis.php - About 4 hrs to fix

          Method createNegationCallbackMap has 123 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function createNegationCallbackMap(): array
              {
                  /** @param list<Node|mixed> $unused_args */
                  $remove_null_cb = static function (CodeBase $unused_code_base, Context $unused_context, Variable $variable, array $unused_args): void {
                      $variable->setUnionType($variable->getUnionType()->nonNullableClone());
          Severity: Major
          Found in src/Phan/Analysis/NegatedConditionVisitor.php - About 4 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 updateSignature has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function updateSignature(string $function_like_name, array $arguments_from_phan): array
                {
                    $return_type = $arguments_from_phan[0];
                    $arguments_from_external_stub = $this->parseFunctionLikeSignature($function_like_name);
                    if (is_null($arguments_from_external_stub)) {
            Severity: Minor
            Found in internal/lib/IncompatibleRealStubsSignatureDetector.php - About 4 hrs to fix

            Cognitive Complexity

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

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

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

            Further reading

            Method make has 120 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected static function make(
                    string $namespace,
                    string $type_name,
                    array $template_parameter_type_list,
                    bool $is_nullable,
            Severity: Major
            Found in src/Phan/Language/Type.php - About 4 hrs to fix

              Method getAnalyzeFunctionCallClosuresStatic has 119 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static function getAnalyzeFunctionCallClosuresStatic(): array
                  {
                      $make_order_warner = static function (int $expected_const_pos, int $expected_variable_pos): Closure {
                          $expected_arg_count = 1 + (int)\max($expected_const_pos, $expected_variable_pos);
                          /**
              Severity: Major
              Found in src/Phan/Plugin/Internal/StringFunctionPlugin.php - About 4 hrs to fix

                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 findAlternateReferencedElementDeclaration has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function findAlternateReferencedElementDeclaration(
                        CodeBase $code_base,
                        AddressableElement $element
                    ): ?AddressableElement {
                        $old_fqsen = $element->getFQSEN();
                Severity: Minor
                Found in src/Phan/Analysis/ReferenceCountsAnalyzer.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 analyzePropAssignment has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function analyzePropAssignment(Clazz $clazz, Property $property, Node $node): Context
                    {
                        if ($property->isReadOnly()) {
                            $this->analyzeAssignmentToReadOnlyProperty($property, $node);
                        }
                Severity: Minor
                Found in src/Phan/Analysis/AssignmentVisitor.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 classTypesForNonName has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function classTypesForNonName(Node $node): UnionType
                    {
                        $node_type = UnionTypeVisitor::unionTypeFromNode(
                            $this->code_base,
                            $this->context,
                Severity: Minor
                Found in src/Phan/AST/UnionTypeVisitor.php - About 4 hrs to fix

                Cognitive Complexity

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

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

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

                Further reading

                Method analyzeFunction has 118 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function analyzeFunction(
                        CodeBase $code_base,
                        Func $function
                    ): void {
                        // NOTE: Placeholders can be found in \Phan\Issue::uncolored_format_string_for_replace
                Severity: Major
                Found in .phan/plugins/UnknownElementTypePlugin.php - About 4 hrs to fix

                  File DependentReturnTypeOverridePlugin.php has 362 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  declare(strict_types=1);
                  
                  namespace Phan\Plugin\Internal;
                  Severity: Minor
                  Found in src/Phan/Plugin/Internal/DependentReturnTypeOverridePlugin.php - About 4 hrs to fix

                    Scope has 36 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    abstract class Scope
                    {
                        public const IN_FUNCTION_LIKE_SCOPE = 0x01;
                        // If this is set, and neither IN_TRAIT_SCOPE and IN_INTERFACE_SCOPE are set, this is
                        public const IN_CLASS_SCOPE         = 0x02;
                    Severity: Minor
                    Found in src/Phan/Language/Scope.php - About 4 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language