Showing 3,272 of 4,939 total issues

Function shouldWarnAboutImpossibleInArray has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    private static function shouldWarnAboutImpossibleInArray(CodeBase $code_base, Context $context, array $args, ?UnionType $needle_type = null, ?UnionType $haystack_type = null): bool
    {
        $haystack_type = $haystack_type ?? UnionTypeVisitor::unionTypeFromNode($code_base, $context, $args[1]);
        if (!$haystack_type->hasRealTypeSet()) {
            return false;
Severity: Minor
Found in src/Phan/Plugin/Internal/MiscParamPlugin.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 visitCall has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitCall(Node $node): Context
    {
        // If this is a call to a method that indicates that we
        // are treating the method in scope as a varargs method,
        // then set its optional args to something very high so
Severity: Minor
Found in src/Phan/Parse/ParseVisitor.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 checkRedundantOrImpossibleTruthyCondition has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkRedundantOrImpossibleTruthyCondition($node, Context $context, ?UnionType $type, bool $is_negated): void
    {
        if (!$this->loop_body_unconditionally_proceeds && $node === $this->loop_condition_node) {
            // Don't warn about `while (1)` or `while (true)`
            if ($node instanceof Node) {
Severity: Minor
Found in src/Phan/Analysis/LoopConditionVisitor.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 getVarNameOfDimNode has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    private static function getVarNameOfDimNode($node): ?string
    {
        // Loop to support getting the var name in is_array($x['field'][0])
        while (true) {
            if (!($node instanceof Node)) {
Severity: Minor
Found in src/Phan/Analysis/ConditionVisitorUtil.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 combineTypesAfterStrictEqualityCheck has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    protected function combineTypesAfterStrictEqualityCheck(UnionType $old_union_type, UnionType $new_union_type): UnionType
    {
        // TODO: Be more precise about these checks - e.g. forbid anything such as stdClass == false in the new type
        if (!$new_union_type->hasRealTypeSet()) {
            return $new_union_type->withRealTypeSet($old_union_type->getRealTypeSet());
Severity: Minor
Found in src/Phan/Analysis/ConditionVisitorUtil.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 checkIsValidStringOffset has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkIsValidStringOffset(UnionType $union_type, Node $node, UnionType $dim_type): void
    {
        $max_len = -1;
        foreach ($union_type->getRealTypeSet() as $type) {
            if ($type instanceof StringType) {
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.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 updateSignature has a Cognitive Complexity of 18 (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_svn = $this->parseFunctionLikeSignature($function_like_name);
        if (is_null($arguments_from_svn)) {
Severity: Minor
Found in internal/lib/IncompatibleSignatureDetectorBase.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 checkForUndeclaredTypeFunctions has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    private static function checkForUndeclaredTypeFunctions(): void
    {
        foreach (get_defined_functions() as $unused_ext => $group) {
            foreach ($group as $function_name) {
                $reflection_function = new ReflectionFunction($function_name);
Severity: Minor
Found in internal/reflection_completeness_check.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 dump_main has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

function dump_main(): void
{
    $print_help = static function (int $exit_code): void {
        global $argv;
        $help = <<<"EOB"
Severity: Minor
Found in internal/dump_fallback_ast.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 checkIsRedundantReturn has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    private static function checkIsRedundantReturn(CodeBase $code_base, FunctionInterface $method, string $doc_comment): void
    {
        if (strpos($doc_comment, '@return') === false) {
            return;
        }
Severity: Minor
Found in .phan/plugins/PHPDocRedundantPlugin.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 visitArgList has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function visitArgList(Node $node): Context
    {
        $argument_name_set = [];
        $has_unpack = false;

Severity: Major
Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 2 hrs to fix

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

        private function checkMovedArg(FunctionInterface $function, array $args, Node $node, array $arg_names, array $places_set = []): void
        {
            $real_parameters = $function->getRealParameterList();
            $parameters = $function->getParameterList();
            /** @var associative-array<string,?int> maps lowercase param names to their unique index, or null */
    Severity: Major
    Found in .phan/plugins/SuspiciousParamOrderPlugin.php - About 2 hrs to fix

      Method iterableKeyUnionType has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function iterableKeyUnionType(CodeBase $code_base): ?UnionType
          {
              if ($this->namespace === '\\') {
                  $name = strtolower($this->name);
                  if ($name === 'traversable' || $name === 'iterator') {
      Severity: Major
      Found in src/Phan/Language/Type.php - About 2 hrs to fix

        Method iterableValueUnionType has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function iterableValueUnionType(CodeBase $code_base): ?UnionType
            {
                if ($this->namespace === '\\') {
                    $name = strtolower($this->name);
                    if ($name === 'traversable' || $name === 'iterator') {
        Severity: Major
        Found in src/Phan/Language/Type.php - About 2 hrs to fix

          Method run has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function run(CodeBase $code_base, Closure $file_path_lister): ?Request
              {
                  if (Config::getValue('language_server_use_pcntl_fallback')) {
                      self::runWithoutPcntl($code_base, $file_path_lister);
                      // Not reachable
          Severity: Major
          Found in src/Phan/Daemon.php - About 2 hrs to fix

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

                public function finalizeProcess(CodeBase $code_base): void
                {
                    if (empty($this->elements)) {
                        \fwrite(\STDERR, "Nothing to analyze - please run pdep from your top-level project directory" . \PHP_EOL);
                        exit(\EXIT_FAILURE);
            Severity: Major
            Found in src/Phan/Plugin/Internal/DependencyGraphPlugin.php - About 2 hrs to fix

              Method visitCall has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function visitCall(Node $node): Context
                  {
                      // Analyze the call to the node, in case it modifies any variables (e.g. count($x = new_value()), if (preg_match(..., $matches), etc.
                      // TODO: Limit this to nodes which actually contain variables or properties?
                      // TODO: Only call this if the caller is also a ConditionVisitor, since BlockAnalysisVisitor would call this for ternaries and if statements already.
              Severity: Major
              Found in src/Phan/Analysis/ConditionVisitor.php - About 2 hrs to fix

                Method visitCatch has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function visitCatch(Node $node): Context
                    {
                        // @phan-suppress-next-line PhanThrowTypeAbsentForCall
                        $union_type = UnionTypeVisitor::unionTypeFromClassNode(
                            $this->code_base,
                Severity: Major
                Found in src/Phan/Analysis/PreOrderAnalysisVisitor.php - About 2 hrs to fix

                  Method visitIsset has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function visitIsset(Node $node): Context
                      {
                          $argument = $node->children['var'];
                          $variable = $argument;
                  
                  
                  Severity: Major
                  Found in .phan/plugins/InvalidVariableIssetPlugin.php - About 2 hrs to fix

                    AddressableElement has 22 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    abstract class AddressableElement extends TypedElement implements AddressableElementInterface
                    {
                        use Memoize;
                    
                        /**
                    Severity: Minor
                    Found in src/Phan/Language/Element/AddressableElement.php - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language