Showing 4,939 of 4,939 total issues

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

    public function visitClosure(Node $node): Context
    {
        $code_base = $this->code_base;
        $context = $this->context->withoutLoops();
        $closure_fqsen = FullyQualifiedFunctionName::fromClosureInContext(

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

    public function visitCatch(Node $node): Context
    {
        // @phan-suppress-next-line PhanThrowTypeAbsentForCall
        $union_type = UnionTypeVisitor::unionTypeFromClassNode(
            $this->code_base,

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 visitIf() has an NPath complexity of 972. The configured NPath complexity threshold is 200.
Open

    public function visitIf(Node $node): Context
    {
        $context = $this->context->withLineNumberStart(
            $node->lineno
        );
Severity: Minor
Found in src/Phan/BlockAnalysisVisitor.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 function phan_error_handler() contains an exit expression.
Open

    exit(EXIT_FAILURE);
Severity: Minor
Found in src/Phan/Bootstrap.php by phpmd

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

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

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

class PostOrderAnalysisVisitor extends AnalysisVisitor
{
    /**
     * @var list<Node> a list of parent nodes of the currently analyzed node,
     * within the current global or function-like scope

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

    public function visitStaticCall(Node $node): Context
    {
        // Get the name of the method being called
        $method_name = $node->children['method'];

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 visitMethod() has an NPath complexity of 216. The configured NPath complexity threshold is 200.
Open

    public function visitMethod(Node $node): Context
    {
        if (!$this->context->isInFunctionLikeScope()) {
            throw new AssertionError("Must be in function-like scope to get method");
        }

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

Avoid using empty try-catch blocks in compareYieldAgainstDeclaredType.
Open

        } catch (RecursionDepthException $_) {
        }

EmptyCatchBlock

Since: 2.7.0

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

Example

class Foo {

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

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

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

    private static function analyzeElementReferenceCounts(
        CodeBase $code_base,
        AddressableElement $element,
        string $issue_type
    ): void {

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

Avoid using empty try-catch blocks in analyzeThrowsTypes.
Open

        } catch (RecursionDepthException $_) {
        }

EmptyCatchBlock

Since: 2.7.0

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

Example

class Foo {

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

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

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

    private function updateParameterTypeByArgument(
        FunctionInterface $method,
        Parameter $parameter,
        $argument,
        array $argument_types,

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

    public function visitFor(Node $node): Context
    {
        $context = $this->context->withLineNumberStart(
            $node->lineno
        );
Severity: Minor
Found in src/Phan/BlockAnalysisVisitor.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 visitSwitchList() has an NPath complexity of 337740. The configured NPath complexity threshold is 200.
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: Minor
Found in src/Phan/BlockAnalysisVisitor.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 visitFuncDecl() has an NPath complexity of 324. The configured NPath complexity threshold is 200.
Open

    public function visitFuncDecl(Node $node): Context
    {
        $function_name = (string)$node->children['name'];
        $code_base = $this->code_base;
        $original_context = $this->context;

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 analyzeSingleThrowType() has an NPath complexity of 1280. The configured NPath complexity threshold is 200.
Open

    private static function analyzeSingleThrowType(
        CodeBase $code_base,
        FunctionInterface $method,
        Type $type
    ): bool {

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 ensureASTParserExists() contains an exit expression.
Open

            exit(EXIT_FAILURE);
Severity: Minor
Found in src/Phan/CLI.php by phpmd

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

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

The 'getForbidUndeclaredMagicMethods()' method which returns a boolean should be named 'is...()' or 'has...()'
Open

    public function getForbidUndeclaredMagicMethods(): bool
    {
        return ($this->comment_flags & Flags::CLASS_FORBID_UNDECLARED_MAGIC_METHODS) !== 0;
    }
Severity: Minor
Found in src/Phan/Language/Element/Comment.php by phpmd

BooleanGetMethodName

Since: 0.2

Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

Example

class Foo {
    /**
     * @return boolean
     */
    public function getFoo() {} // bad
    /**
     * @return bool
     */
    public function isFoo(); // ok
    /**
     * @return boolean
     */
    public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}

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

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

    public static function addParamsToScopeOfFunctionOrMethod(
        Context $context,
        CodeBase $code_base,
        FunctionInterface $function,
        Comment $comment

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 usage() contains an exit expression.
Open

            exit($exit_code);
Severity: Minor
Found in src/Phan/CLI.php by phpmd

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

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

The method __construct has 15 parameters. Consider reducing the number of parameters to less than 10.
Open

    public function __construct(
        int $comment_flags,
        array $variable_list,
        array $parameter_list,
        array $template_type_list,
Severity: Minor
Found in src/Phan/Language/Element/Comment.php by phpmd
Severity
Category
Status
Source
Language