File ArgumentType.php
has 1165 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Phan\Analysis;
Function analyzeParameterList
has a Cognitive Complexity of 88 (exceeds 5 allowed). Consider refactoring. Open
private static function analyzeParameterList(
CodeBase $code_base,
FunctionInterface $method,
Node $node,
Context $context
- Read upRead up
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 analyzeParameterListForCallback
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring. Open
private static function analyzeParameterListForCallback(
CodeBase $code_base,
FunctionInterface $method,
array $arg_nodes,
Context $context,
- Read upRead up
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 analyzeParameter
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
public static function analyzeParameter(CodeBase $code_base, Context $context, FunctionInterface $method, UnionType $argument_type, int $lineno, int $i, $argument_node, ?Node $node): void
{
// Expand it to include all parent types up the chain
try {
$argument_type_expanded_resolved =
- Read upRead up
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 analyzeParameterList
has 144 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function analyzeParameterList(
CodeBase $code_base,
FunctionInterface $method,
Node $node,
Context $context
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,
Function warnInvalidArgumentType
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
private static function warnInvalidArgumentType(
CodeBase $code_base,
Context $context,
FunctionInterface $method,
Parameter $alternate_parameter,
- Read upRead up
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 isExpressionReturningReference
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public static function isExpressionReturningReference(CodeBase $code_base, Context $context, $node): bool
{
if (!($node instanceof Node)) {
return false;
}
- Read upRead up
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 analyzeParameterListForCallback
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function analyzeParameterListForCallback(
CodeBase $code_base,
FunctionInterface $method,
array $arg_nodes,
Context $context,
Function analyze
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public static function analyze(
FunctionInterface $method,
Node $node,
Context $context,
CodeBase $code_base
- Read upRead up
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 checkAbstractStaticMethodCall
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
private static function checkAbstractStaticMethodCall(
FunctionInterface $method,
Node $node,
Context $context,
CodeBase $code_base
- Read upRead up
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 analyzeParameterStrict
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
private static function analyzeParameterStrict(CodeBase $code_base, Context $context, FunctionInterface $method, $argument_node, UnionType $argument_type, Variable $alternate_parameter, UnionType $parameter_type, int $lineno, int $i): void
{
if ($alternate_parameter instanceof Parameter && $alternate_parameter->isPassByReference() && $alternate_parameter->getReferenceType() === Parameter::REFERENCE_WRITE_ONLY) {
return;
}
- Read upRead up
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 ArgumentType has an overall complexity of 252 which is very high. The configured complexity threshold is 50. Open
final class ArgumentType
{
/**
* @param FunctionInterface $method
- Exclude checks
Method analyzeParameter
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function analyzeParameter(CodeBase $code_base, Context $context, FunctionInterface $method, UnionType $argument_type, int $lineno, int $i, $argument_node, ?Node $node): void
{
// Expand it to include all parent types up the chain
try {
$argument_type_expanded_resolved =
Method analyze
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function analyze(
FunctionInterface $method,
Node $node,
Context $context,
CodeBase $code_base
Function analyzeForCallback
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public static function analyzeForCallback(
FunctionInterface $method,
array $arg_nodes,
Context $context,
CodeBase $code_base,
- Read upRead up
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 analyzeParameterStrict
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function analyzeParameterStrict(CodeBase $code_base, Context $context, FunctionInterface $method, $argument_node, UnionType $argument_type, Variable $alternate_parameter, UnionType $parameter_type, int $lineno, int $i): void
{
if ($alternate_parameter instanceof Parameter && $alternate_parameter->isPassByReference() && $alternate_parameter->getReferenceType() === Parameter::REFERENCE_WRITE_ONLY) {
return;
}
ArgumentType
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
final class ArgumentType
{
/**
* @param FunctionInterface $method
Method analyzeForCallback
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function analyzeForCallback(
FunctionInterface $method,
array $arg_nodes,
Context $context,
CodeBase $code_base,
Method isExpressionReturningReference
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function isExpressionReturningReference(CodeBase $code_base, Context $context, $node): bool
{
if (!($node instanceof Node)) {
return false;
}
Method checkAbstractStaticMethodCall
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function checkAbstractStaticMethodCall(
FunctionInterface $method,
Node $node,
Context $context,
CodeBase $code_base
Function analyzeRemainingParametersForVariadic
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static function analyzeRemainingParametersForVariadic(
CodeBase $code_base,
Context $context,
FunctionInterface $method,
int $start_index,
- Read upRead up
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 checkIsDeprecatedOrInternal
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function checkIsDeprecatedOrInternal(CodeBase $code_base, Context $context, FunctionInterface $method): void
{
// Special common cases where we want slightly
// better multi-signature error messages
if ($method->isPHPInternal()) {
Method warnInvalidArgumentType
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
Context $context,
FunctionInterface $method,
Parameter $alternate_parameter,
UnionType $alternate_parameter_type,
Method emitUndeclaredNamedArgument
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function emitUndeclaredNamedArgument(
CodeBase $code_base,
Context $context,
FunctionInterface $method,
Node $argument
Function checkAllNamedArgumentsPassed
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private static function checkAllNamedArgumentsPassed(
CodeBase $code_base,
Context $context,
int $lineno,
FunctionInterface $method,
- Read upRead up
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 maybeWarnProvidingUnusedParameter
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function maybeWarnProvidingUnusedParameter(
CodeBase $code_base,
Context $context,
int $lineno,
FunctionInterface $method,
Method checkAllNamedArgumentsPassed
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function checkAllNamedArgumentsPassed(
CodeBase $code_base,
Context $context,
int $lineno,
FunctionInterface $method,
Method analyzeParameterStrict
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
private static function analyzeParameterStrict(CodeBase $code_base, Context $context, FunctionInterface $method, $argument_node, UnionType $argument_type, Variable $alternate_parameter, UnionType $parameter_type, int $lineno, int $i): void
Method analyzeRemainingParametersForVariadic
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function analyzeRemainingParametersForVariadic(
CodeBase $code_base,
Context $context,
FunctionInterface $method,
int $start_index,
Method analyzeParameter
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function analyzeParameter(CodeBase $code_base, Context $context, FunctionInterface $method, UnionType $argument_type, int $lineno, int $i, $argument_node, ?Node $node): void
Function maybeWarnProvidingUnusedParameter
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function maybeWarnProvidingUnusedParameter(
CodeBase $code_base,
Context $context,
int $lineno,
FunctionInterface $method,
- Read upRead up
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 analyzeRemainingParametersForVariadic
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
Context $context,
FunctionInterface $method,
int $start_index,
Node $node,
Avoid deeply nested control flow statements. Open
if ($class->isTrait()) {
$issue_type = Issue::AbstractStaticMethodCallInTrait;
}
Method maybeWarnProvidingUnusedParameter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
Context $context,
int $lineno,
FunctionInterface $method,
Parameter $parameter,
Function checkIsDeprecatedOrInternal
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private static function checkIsDeprecatedOrInternal(CodeBase $code_base, Context $context, FunctionInterface $method): void
{
// Special common cases where we want slightly
// better multi-signature error messages
if ($method->isPHPInternal()) {
- Read upRead up
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 checkAllNamedArgumentsPassed
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
Context $context,
int $lineno,
FunctionInterface $method,
array $positions_used
Method emitParamTooMany
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
Context $context,
FunctionInterface $method,
Node $node,
int $argcount
Method analyzeParameterListForCallback
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
FunctionInterface $method,
array $arg_nodes,
Context $context,
Closure $get_argument_type
Method analyzeForCallback
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
FunctionInterface $method,
array $arg_nodes,
Context $context,
CodeBase $code_base,
Closure $get_argument_type
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $nullable_issue_type;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Function isUnpack
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function isUnpack(array $children): bool
{
foreach ($children as $child) {
if ($child instanceof Node) {
if ($child->kind === ast\AST_UNPACK) {
- Read upRead up
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 isVarargs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function isVarargs(CodeBase $code_base, FunctionInterface $method): bool
{
foreach ($method->alternateGenerator($code_base) as $alternate_method) {
foreach ($alternate_method->getParameterList() as $parameter) {
if ($parameter->isVariadic()) {
- Read upRead up
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 analyzeParameterList() has an NPath complexity of 6065288. The configured NPath complexity threshold is 200. Open
private static function analyzeParameterList(
CodeBase $code_base,
FunctionInterface $method,
Node $node,
Context $context
- Read upRead up
- Exclude checks
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 analyze() has an NPath complexity of 960. The configured NPath complexity threshold is 200. Open
public static function analyze(
FunctionInterface $method,
Node $node,
Context $context,
CodeBase $code_base
- Read upRead up
- Exclude checks
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 analyzeParameterList() has 172 lines of code. Current threshold is set to 100. Avoid really long methods. Open
private static function analyzeParameterList(
CodeBase $code_base,
FunctionInterface $method,
Node $node,
Context $context
- Exclude checks
The method analyzeParameterListForCallback() has 127 lines of code. Current threshold is set to 100. Avoid really long methods. Open
private static function analyzeParameterListForCallback(
CodeBase $code_base,
FunctionInterface $method,
array $arg_nodes,
Context $context,
- Exclude checks
The method analyzeParameter() has an NPath complexity of 1493856. The configured NPath complexity threshold is 200. Open
public static function analyzeParameter(CodeBase $code_base, Context $context, FunctionInterface $method, UnionType $argument_type, int $lineno, int $i, $argument_node, ?Node $node): void
{
// Expand it to include all parent types up the chain
try {
$argument_type_expanded_resolved =
- Read upRead up
- Exclude checks
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 analyzeParameterListForCallback() has an NPath complexity of 149768. The configured NPath complexity threshold is 200. Open
private static function analyzeParameterListForCallback(
CodeBase $code_base,
FunctionInterface $method,
array $arg_nodes,
Context $context,
- Read upRead up
- Exclude checks
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 analyzeParameterStrict() has an NPath complexity of 384. The configured NPath complexity threshold is 200. Open
private static function analyzeParameterStrict(CodeBase $code_base, Context $context, FunctionInterface $method, $argument_node, UnionType $argument_type, Variable $alternate_parameter, UnionType $parameter_type, int $lineno, int $i): void
{
if ($alternate_parameter instanceof Parameter && $alternate_parameter->isPassByReference() && $alternate_parameter->getReferenceType() === Parameter::REFERENCE_WRITE_ONLY) {
return;
}
- Read upRead up
- Exclude checks
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 warnInvalidArgumentType() has an NPath complexity of 23808. The configured NPath complexity threshold is 200. Open
private static function warnInvalidArgumentType(
CodeBase $code_base,
Context $context,
FunctionInterface $method,
Parameter $alternate_parameter,
- Read upRead up
- Exclude checks
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 analyzeParameter() has 121 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public static function analyzeParameter(CodeBase $code_base, Context $context, FunctionInterface $method, UnionType $argument_type, int $lineno, int $i, $argument_node, ?Node $node): void
{
// Expand it to include all parent types up the chain
try {
$argument_type_expanded_resolved =
- Exclude checks
The class ArgumentType has 1427 lines of code. Current threshold is 1000. Avoid really long classes. Open
final class ArgumentType
{
/**
* @param FunctionInterface $method
- Exclude checks
The method warnInvalidArgumentType() has 160 lines of code. Current threshold is set to 100. Avoid really long methods. Open
private static function warnInvalidArgumentType(
CodeBase $code_base,
Context $context,
FunctionInterface $method,
Parameter $alternate_parameter,
- Exclude checks
The method warnInvalidArgumentType has 11 parameters. Consider reducing the number of parameters to less than 10. Open
private static function warnInvalidArgumentType(
CodeBase $code_base,
Context $context,
FunctionInterface $method,
Parameter $alternate_parameter,
- Exclude checks
The method warnInvalidArgumentType() has a Cyclomatic Complexity of 22. The configured cyclomatic complexity threshold is 10. Open
private static function warnInvalidArgumentType(
CodeBase $code_base,
Context $context,
FunctionInterface $method,
Parameter $alternate_parameter,
- Read upRead up
- Exclude checks
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 checkAbstractStaticMethodCall() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
private static function checkAbstractStaticMethodCall(
FunctionInterface $method,
Node $node,
Context $context,
CodeBase $code_base
- Read upRead up
- Exclude checks
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 analyzeForCallback() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public static function analyzeForCallback(
FunctionInterface $method,
array $arg_nodes,
Context $context,
CodeBase $code_base,
- Read upRead up
- Exclude checks
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 maybeWarnProvidingUnusedParameter() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
private static function maybeWarnProvidingUnusedParameter(
CodeBase $code_base,
Context $context,
int $lineno,
FunctionInterface $method,
- Read upRead up
- Exclude checks
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 analyzeParameterListForCallback() has a Cyclomatic Complexity of 27. The configured cyclomatic complexity threshold is 10. Open
private static function analyzeParameterListForCallback(
CodeBase $code_base,
FunctionInterface $method,
array $arg_nodes,
Context $context,
- Read upRead up
- Exclude checks
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 analyzeParameterStrict() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10. Open
private static function analyzeParameterStrict(CodeBase $code_base, Context $context, FunctionInterface $method, $argument_node, UnionType $argument_type, Variable $alternate_parameter, UnionType $parameter_type, int $lineno, int $i): void
{
if ($alternate_parameter instanceof Parameter && $alternate_parameter->isPassByReference() && $alternate_parameter->getReferenceType() === Parameter::REFERENCE_WRITE_ONLY) {
return;
}
- Read upRead up
- Exclude checks
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 analyzeParameterList() has a Cyclomatic Complexity of 38. The configured cyclomatic complexity threshold is 10. Open
private static function analyzeParameterList(
CodeBase $code_base,
FunctionInterface $method,
Node $node,
Context $context
- Read upRead up
- Exclude checks
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 isExpressionReturningReference() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10. Open
public static function isExpressionReturningReference(CodeBase $code_base, Context $context, $node): bool
{
if (!($node instanceof Node)) {
return false;
}
- Read upRead up
- Exclude checks
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 analyze() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10. Open
public static function analyze(
FunctionInterface $method,
Node $node,
Context $context,
CodeBase $code_base
- Read upRead up
- Exclude checks
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 analyzeParameter() has a Cyclomatic Complexity of 33. The configured cyclomatic complexity threshold is 10. Open
public static function analyzeParameter(CodeBase $code_base, Context $context, FunctionInterface $method, UnionType $argument_type, int $lineno, int $i, $argument_node, ?Node $node): void
{
// Expand it to include all parent types up the chain
try {
$argument_type_expanded_resolved =
- Read upRead up
- Exclude checks
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 ArgumentType has a coupling between objects value of 27. Consider to reduce the number of dependencies under 13. Open
final class ArgumentType
{
/**
* @param FunctionInterface $method
- Read upRead up
- Exclude checks
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
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = $original_i;
- Read upRead up
- Exclude checks
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
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = $original_i;
- Read upRead up
- Exclude checks
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
Avoid variables with short names like $i. Configured minimum length is 3. Open
public static function analyzeParameter(CodeBase $code_base, Context $context, FunctionInterface $method, UnionType $argument_type, int $lineno, int $i, $argument_node, ?Node $node): void
- Read upRead up
- Exclude checks
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
Avoid variables with short names like $i. Configured minimum length is 3. Open
int $i
- Read upRead up
- Exclude checks
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
Avoid variables with short names like $i. Configured minimum length is 3. Open
int $i
- Read upRead up
- Exclude checks
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
Avoid variables with short names like $i. Configured minimum length is 3. Open
private static function analyzeParameterStrict(CodeBase $code_base, Context $context, FunctionInterface $method, $argument_node, UnionType $argument_type, Variable $alternate_parameter, UnionType $parameter_type, int $lineno, int $i): void
- Read upRead up
- Exclude checks
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;
}
}
}