File PostOrderAnalysisVisitor.php
has 3473 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Phan\Analysis;
PostOrderAnalysisVisitor
has 128 functions (exceeds 20 allowed). Consider refactoring. 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
Function visitReturn
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function visitReturn(Node $node): Context
{
$context = $this->context;
// Make sure we're actually returning from a method.
if (!$context->isInFunctionLikeScope()) {
- 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 analyzePassByReferenceArgument
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
private static function analyzePassByReferenceArgument(
CodeBase $code_base,
Context $context,
Node $argument,
array $argument_list,
- 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 analyzeCallToFunctionLike
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeCallToFunctionLike(
FunctionInterface $method,
Node $node
): void {
$code_base = $this->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 visitArgList
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function visitArgList(Node $node): Context
{
$argument_name_set = [];
$has_unpack = 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
Function analyzeReturnStrict
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeReturnStrict(
CodeBase $code_base,
FunctionInterface $method,
UnionType $expression_type,
UnionType $method_return_type,
- 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 createPassByReferenceArgumentInCall
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
private function createPassByReferenceArgumentInCall(FunctionInterface $method, Node $argument, Parameter $parameter, ?Parameter $real_parameter): void
{
if ($argument->kind === ast\AST_VAR) {
// We don't do anything with the new variable; just create it
// if it doesn't exist
- 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 updateParameterTypeByArgument
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
private function updateParameterTypeByArgument(
FunctionInterface $method,
Parameter $parameter,
$argument,
array $argument_types,
- 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 visitStaticCall
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function visitStaticCall(Node $node): Context
{
// Get the name of the method being called
$method_name = $node->children['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
Function warnNoopNew
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
private function warnNoopNew(
Node $node,
array $class_list
): void {
$has_constructor_or_destructor = \count($class_list) === 0;
- 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 PostOrderAnalysisVisitor has 116 non-getter- and setter-methods. Consider refactoring PostOrderAnalysisVisitor to keep number of methods under 25. 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
- Read upRead up
- Exclude checks
TooManyMethods
Since: 0.1
A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
The default was changed from 10 to 25 in PHPMD 2.3.
Example
Source https://phpmd.org/rules/codesize.html#toomanymethods
The class PostOrderAnalysisVisitor has 63 public methods. Consider refactoring PostOrderAnalysisVisitor to keep number of public methods under 10. 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
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class PostOrderAnalysisVisitor has an overall complexity of 756 which is very high. The configured complexity threshold is 50. 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
- Exclude checks
Function checkForInvalidNewType
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private function checkForInvalidNewType(Node $node, array $class_list): void
{
// This is either a string (new 'something'()) or a class name (new something())
$class_node = $node->children['class'];
if (!$class_node instanceof Node) {
- 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 visitStaticCall
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitStaticCall(Node $node): Context
{
// Get the name of the method being called
$method_name = $node->children['method'];
Function analyzeProp
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function analyzeProp(Node $node, bool $is_static): Context
{
$exception_or_null = null;
try {
- 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 analyzePassByReferenceArgument
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function analyzePassByReferenceArgument(
CodeBase $code_base,
Context $context,
Node $argument,
array $argument_list,
Method updateParameterTypeByArgument
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function updateParameterTypeByArgument(
FunctionInterface $method,
Parameter $parameter,
$argument,
array $argument_types,
Method visitReturn
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitReturn(Node $node): Context
{
$context = $this->context;
// Make sure we're actually returning from a method.
if (!$context->isInFunctionLikeScope()) {
Function analyzeUnsetProp
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeUnsetProp(Node $node): Context
{
$expr_node = $node->children['expr'];
$context = $this->context;
if (!($expr_node instanceof Node)) {
- 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 analyzeIncOrDec
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeIncOrDec(Node $node): Context
{
$var = $node->children['var'];
$old_type = UnionTypeVisitor::unionTypeFromNode($this->code_base, $this->context, $var);
if (!$old_type->canCastToUnionType(UnionType::fromFullyQualifiedPHPDocString('int|string|float'))) {
- 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 analyzeCallableWithArgumentTypes
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function analyzeCallableWithArgumentTypes(
array $argument_types,
FunctionInterface $method,
array $arguments = [],
bool $erase_old_return_type = 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
Function checkForInfiniteRecursionWithSameArgs
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function checkForInfiniteRecursionWithSameArgs(Node $node, FunctionInterface $method): void
{
$argument_list_node = $node->children['args'];
$parameter_list = $method->getParameterList();
if (\count($argument_list_node->children) !== \count($parameter_list)) {
- 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 analyzeCallToFunctionLike
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function analyzeCallToFunctionLike(
FunctionInterface $method,
Node $node
): void {
$code_base = $this->code_base;
Method analyzeProp
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function analyzeProp(Node $node, bool $is_static): Context
{
$exception_or_null = null;
try {
Function analyzeMethodWithArgumentTypes
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeMethodWithArgumentTypes(
Node $argument_list_node,
FunctionInterface $method
): void {
$method = $this->findDefiningMethod($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
Function getReturnTypesOfConditional
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private function getReturnTypesOfConditional(Context $context, Node $node): \Generator
{
$cond_node = $node->children['cond'];
$cond_truthiness = UnionTypeVisitor::checkCondUnconditionalTruthiness($cond_node);
// For the shorthand $a ?: $b, the cond node will be the truthy value.
- 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 visitArgList
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitArgList(Node $node): Context
{
$argument_name_set = [];
$has_unpack = false;
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
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);
Function visitMethodCall
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function visitMethodCall(Node $node): Context
{
$method_name = $node->children['method'];
if (!\is_string($method_name)) {
- 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 emitTypeMismatchReturnIssue
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function emitTypeMismatchReturnIssue(UnionType $expression_type, FunctionInterface $method, UnionType $method_return_type, int $lineno, $inner_node): void
{
if ($this->shouldSuppressIssue(Issue::TypeMismatchReturnReal, $lineno)) {
// Suppressing TypeMismatchReturnReal also suppresses less severe return type mismatches
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
Method emitTypeMismatchReturnIssue
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function emitTypeMismatchReturnIssue(UnionType $expression_type, FunctionInterface $method, UnionType $method_return_type, int $lineno, $inner_node): void
{
if ($this->shouldSuppressIssue(Issue::TypeMismatchReturnReal, $lineno)) {
// Suppressing TypeMismatchReturnReal also suppresses less severe return type mismatches
return;
Method visitMethodCall
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitMethodCall(Node $node): Context
{
$method_name = $node->children['method'];
if (!\is_string($method_name)) {
Method visitNew
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitNew(Node $node): Context
{
$class_list = [];
try {
$context_node = new ContextNode(
Function visitPrint
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function visitPrint(Node $node): Context
{
$code_base = $this->code_base;
$context = $this->context;
$expr_node = $node->children['expr'];
- 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 analyzeIncOrDec
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function analyzeIncOrDec(Node $node): Context
{
$var = $node->children['var'];
$old_type = UnionTypeVisitor::unionTypeFromNode($this->code_base, $this->context, $var);
if (!$old_type->canCastToUnionType(UnionType::fromFullyQualifiedPHPDocString('int|string|float'))) {
Function analyzeUnsetDim
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeUnsetDim(Node $node): void
{
$expr_node = $node->children['expr'];
if (!($expr_node instanceof Node)) {
// php -l would warn
- 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 checkNonAncestorConstructCall
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function checkNonAncestorConstructCall(
Node $node,
string $static_class,
string $method_name
): void {
- 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 analyzeUnsetDim
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function analyzeUnsetDim(Node $node): void
{
$expr_node = $node->children['expr'];
if (!($expr_node instanceof Node)) {
// php -l would warn
Method checkForInfiniteRecursionWithSameArgs
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function checkForInfiniteRecursionWithSameArgs(Node $node, FunctionInterface $method): void
{
$argument_list_node = $node->children['args'];
$parameter_list = $method->getParameterList();
if (\count($argument_list_node->children) !== \count($parameter_list)) {
Method analyzeReturnStrict
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function analyzeReturnStrict(
CodeBase $code_base,
FunctionInterface $method,
UnionType $expression_type,
UnionType $method_return_type,
Method checkUnionTypeCompatibility
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function checkUnionTypeCompatibility(?Node $type): void
{
if (!$type) {
return;
}
Method compareYieldAgainstDeclaredType
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function compareYieldAgainstDeclaredType(Node $node, FunctionInterface $method, Context $context, array $template_type_list): Context
{
$code_base = $this->code_base;
$type_list_count = \count($template_type_list);
Method createPassByReferenceArgumentInCall
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function createPassByReferenceArgumentInCall(FunctionInterface $method, Node $argument, Parameter $parameter, ?Parameter $real_parameter): void
{
if ($argument->kind === ast\AST_VAR) {
// We don't do anything with the new variable; just create it
// if it doesn't exist
Method getReturnTypesOfConditional
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getReturnTypesOfConditional(Context $context, Node $node): \Generator
{
$cond_node = $node->children['cond'];
$cond_truthiness = UnionTypeVisitor::checkCondUnconditionalTruthiness($cond_node);
// For the shorthand $a ?: $b, the cond node will be the truthy value.
Method checkNonAncestorConstructCall
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function checkNonAncestorConstructCall(
Node $node,
string $static_class,
string $method_name
): void {
Method getReturnTypes
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getReturnTypes(Context $context, $node, int $return_lineno): \Generator
{
if (!($node instanceof Node)) {
if (null === $node) {
yield $return_lineno => [VoidType::instance(false)->asRealUnionType(), null];
Method analyzeUnsetProp
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function analyzeUnsetProp(Node $node): Context
{
$expr_node = $node->children['expr'];
$context = $this->context;
if (!($expr_node instanceof Node)) {
Method visitAssign
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitAssign(Node $node): Context
{
// Get the type of the right side of the
// assignment
$right_type = UnionTypeVisitor::unionTypeFromNode(
Method checkPassingPropertyByReference
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function checkPassingPropertyByReference(CodeBase $code_base, Context $context, FunctionInterface $method, Parameter $parameter, Node $argument, Property $property, int $parameter_offset): void
{
$parameter_type = $parameter->getNonVariadicUnionType();
$expr_node = $argument->children['expr'] ?? null;
if ($expr_node instanceof Node &&
Method checkForInvalidNewType
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function checkForInvalidNewType(Node $node, array $class_list): void
{
// This is either a string (new 'something'()) or a class name (new something())
$class_node = $node->children['class'];
if (!$class_node instanceof Node) {
Method getStaticMethodOrEmitIssue
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getStaticMethodOrEmitIssue(Node $node, string $method_name): ?Method
{
try {
// Get a reference to the method being called
$result = (new ContextNode(
Function getStaticMethodOrEmitIssue
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function getStaticMethodOrEmitIssue(Node $node, string $method_name): ?Method
{
try {
// Get a reference to the method being called
$result = (new ContextNode(
- 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 visitPrint
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitPrint(Node $node): Context
{
$code_base = $this->code_base;
$context = $this->context;
$expr_node = $node->children['expr'];
Method visitBinaryOp
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitBinaryOp(Node $node): Context
{
$flags = $node->flags;
if ($this->isInNoOpPosition($node)) {
if (\in_array($flags, [flags\BINARY_BOOL_AND, flags\BINARY_BOOL_OR, flags\BINARY_COALESCE], true)) {
Method getReturnTypesOfArray
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getReturnTypesOfArray(Context $context, Node $node): \Generator
{
if (\count($node->children) === 0) {
// Possibly unreachable (array shape would be returned instead)
yield $node->lineno => [MixedType::instance(false)->asPHPDocUnionType(), $node];
Method compareYieldFromAgainstDeclaredType
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function compareYieldFromAgainstDeclaredType(Node $node, FunctionInterface $method, Context $context, array $template_type_list, UnionType $yield_from_type): Context
{
$code_base = $this->code_base;
$type_list_count = \count($template_type_list);
Method visitYieldFrom
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitYieldFrom(Node $node): Context
{
$context = $this->context;
// Make sure we're actually returning from a method.
if (!$context->isInFunctionLikeScope()) {
Function isAssignmentOrNestedAssignmentOrModification
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function isAssignmentOrNestedAssignmentOrModification(Node $node): ?bool
{
$parent_node_list = $this->parent_node_list;
$parent_node = \end($parent_node_list);
if (!$parent_node instanceof Node) {
- 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 visitBinaryOp
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function visitBinaryOp(Node $node): Context
{
$flags = $node->flags;
if ($this->isInNoOpPosition($node)) {
if (\in_array($flags, [flags\BINARY_BOOL_AND, flags\BINARY_BOOL_OR, flags\BINARY_COALESCE], true)) {
- 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 visitMethod
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitMethod(Node $node): Context
{
if (!$this->context->isInFunctionLikeScope()) {
throw new AssertionError("Must be in function-like scope to get method");
}
Method checkExpressionInDynamicString
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function checkExpressionInDynamicString(Node $expr_node): void
{
$code_base = $this->code_base;
$context = $this->context;
$type = UnionTypeVisitor::unionTypeFromNode(
Consider simplifying this complex logical expression. Open
if (!$method->isAbstract()
&& !$method->isFromPHPDoc()
&& !$has_interface_class
&& !$return_type->isEmpty()
&& !$method->hasReturn()
Method warnNoopNew
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function warnNoopNew(
Node $node,
array $class_list
): void {
$has_constructor_or_destructor = \count($class_list) === 0;
Method analyzeMethodVisibility
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function analyzeMethodVisibility(
Method $method,
Node $node
): void {
if ($method->isPublic()) {
Method checkDeprecatedUnparenthesizedConditional
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function checkDeprecatedUnparenthesizedConditional(Node $node, Node $cond): void
{
if ($cond->flags & flags\PARENTHESIZED_CONDITIONAL) {
// The condition is unambiguously parenthesized.
return;
Function checkExpressionInDynamicString
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function checkExpressionInDynamicString(Node $expr_node): void
{
$code_base = $this->code_base;
$context = $this->context;
$type = UnionTypeVisitor::unionTypeFromNode(
- 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 checkDeprecatedUnparenthesizedConditional
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function checkDeprecatedUnparenthesizedConditional(Node $node, Node $cond): void
{
if ($cond->flags & flags\PARENTHESIZED_CONDITIONAL) {
// The condition is unambiguously parenthesized.
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
Function visitNew
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function visitNew(Node $node): Context
{
$class_list = [];
try {
$context_node = new ContextNode(
- 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 getReturnTypesOfArray
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function getReturnTypesOfArray(Context $context, Node $node): \Generator
{
if (\count($node->children) === 0) {
// Possibly unreachable (array shape would be returned instead)
yield $node->lineno => [MixedType::instance(false)->asPHPDocUnionType(), $node];
- 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 isAssignmentOrNestedAssignment
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function isAssignmentOrNestedAssignment(Node $node): ?bool
{
$parent_node_list = $this->parent_node_list;
$parent_node = \end($parent_node_list);
if (!$parent_node instanceof Node) {
- 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 checkUnionTypeCompatibility
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function checkUnionTypeCompatibility(?Node $type): void
{
if (!$type) {
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
Function visitUnaryOp
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function visitUnaryOp(Node $node): Context
{
if ($node->flags === flags\UNARY_SILENCE) {
$expr = $node->children['expr'];
if ($expr instanceof Node) {
- 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 visitDim
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitDim(Node $node): Context
{
$code_base = $this->code_base;
$context = $this->context;
// Check the dimension type to trigger PhanUndeclaredVariable, etc.
Method visitContinue
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitContinue(Node $node): Context
{
$nodes = $this->parent_node_list;
$depth = $node->children['depth'] ?? 1;
if (!\is_int($depth)) {
The class PostOrderAnalysisVisitor has 63 public methods and attributes. Consider reducing the number of public items to less than 45. 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
- Read upRead up
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
Method analyzeBinaryShift
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function analyzeBinaryShift(Node $node): void
{
$left = UnionTypeVisitor::unionTypeFromNode(
$this->code_base,
$this->context,
Method analyzeBinaryBitwiseOp
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function analyzeBinaryBitwiseOp(Node $node): void
{
$left = UnionTypeVisitor::unionTypeFromNode(
$this->code_base,
$this->context,
Method analyzeBinaryNumericOp
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function analyzeBinaryNumericOp(Node $node): void
{
$left = UnionTypeVisitor::unionTypeFromNode(
$this->code_base,
$this->context,
Function compareYieldAgainstDeclaredType
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function compareYieldAgainstDeclaredType(Node $node, FunctionInterface $method, Context $context, array $template_type_list): Context
{
$code_base = $this->code_base;
$type_list_count = \count($template_type_list);
- 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 visitUnaryOp
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitUnaryOp(Node $node): Context
{
if ($node->flags === flags\UNARY_SILENCE) {
$expr = $node->children['expr'];
if ($expr instanceof Node) {
Method isAssignmentOrNestedAssignmentOrModification
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function isAssignmentOrNestedAssignmentOrModification(Node $node): ?bool
{
$parent_node_list = $this->parent_node_list;
$parent_node = \end($parent_node_list);
if (!$parent_node instanceof Node) {
Method isAssignmentOrNestedAssignment
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function isAssignmentOrNestedAssignment(Node $node): ?bool
{
$parent_node_list = $this->parent_node_list;
$parent_node = \end($parent_node_list);
if (!$parent_node instanceof Node) {
Method checkForInfiniteRecursion
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function checkForInfiniteRecursion(Node $node, FunctionInterface $method): void
{
$argument_list_node = $node->children['args'];
$kind = $node->kind;
if ($kind === ast\AST_METHOD_CALL || $kind === ast\AST_NULLSAFE_METHOD_CALL) {
Method visitInstanceof
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitInstanceof(Node $node): Context
{
try {
// Fetch the class list, and emit warnings as a side effect.
// TODO: Unify UnionTypeVisitor, AssignmentVisitor, and PostOrderAnalysisVisitor
Method analyzePassByReferenceArgument
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
Context $context,
Node $argument,
array $argument_list,
FunctionInterface $method,
Function checkForInfiniteRecursion
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function checkForInfiniteRecursion(Node $node, FunctionInterface $method): void
{
$argument_list_node = $node->children['args'];
$kind = $node->kind;
if ($kind === ast\AST_METHOD_CALL || $kind === ast\AST_NULLSAFE_METHOD_CALL) {
- 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 visitContinue
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function visitContinue(Node $node): Context
{
$nodes = $this->parent_node_list;
$depth = $node->children['depth'] ?? 1;
if (!\is_int($depth)) {
- 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 getReturnTypes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function getReturnTypes(Context $context, $node, int $return_lineno): \Generator
{
if (!($node instanceof Node)) {
if (null === $node) {
yield $return_lineno => [VoidType::instance(false)->asRealUnionType(), null];
- 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 visitClassConstDecl
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function visitClassConstDecl(Node $node): Context
{
$class = $this->context->getClassInScope($this->code_base);
foreach ($node->children as $child_node) {
- 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 visitConstDecl
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function visitConstDecl(Node $node): Context
{
foreach ($node->children as $child_node) {
if (!$child_node instanceof Node) {
throw new AssertionError('expected const element to be a Node');
- 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 shouldSkipNestedAssignDim
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function shouldSkipNestedAssignDim(array $parent_node_list): bool
{
$cur_parent_node = \end($parent_node_list);
for (;; $cur_parent_node = $prev_parent_node) {
$prev_parent_node = \prev($parent_node_list);
- 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 checkPassingPropertyByReference
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
private static function checkPassingPropertyByReference(CodeBase $code_base, Context $context, FunctionInterface $method, Parameter $parameter, Node $argument, Property $property, int $parameter_offset): void
Method analyzeReturnStrict
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
FunctionInterface $method,
UnionType $expression_type,
UnionType $method_return_type,
int $lineno,
Method analyzeWriteOnlyReference
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
Context $context,
FunctionInterface $method,
Closure $set_variable_type,
array $argument_list,
Method warnAboutInvalidUnionType
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Node $node,
Closure $is_valid_type,
UnionType $left,
UnionType $right,
string $left_issue_type,
Method updateParameterTypeByArgument
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
FunctionInterface $method,
Parameter $parameter,
$argument,
array $argument_types,
array &$parameter_list,
Method emitTypeMismatchReturnIssue
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function emitTypeMismatchReturnIssue(UnionType $expression_type, FunctionInterface $method, UnionType $method_return_type, int $lineno, $inner_node): void
Method compareYieldFromAgainstDeclaredType
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function compareYieldFromAgainstDeclaredType(Node $node, FunctionInterface $method, Context $context, array $template_type_list, UnionType $yield_from_type): Context
Function deduplicateUnionTypes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function deduplicateUnionTypes($types): \Generator
{
$unique_types = [];
foreach ($types as $lineno => $details) {
$type = $details[0];
- 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 analyzeReturnInGenerator
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeReturnInGenerator(
FunctionInterface $method,
Node $node
): void {
$method_generator_type = $method->getReturnTypeAsGeneratorTemplateType();
- 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 checkCanCastToReturnType
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function checkCanCastToReturnType(UnionType $expression_type, UnionType $method_return_type): bool
{
if ($expression_type->hasRealTypeSet() && $method_return_type->hasRealTypeSet()) {
$real_expression_type = $expression_type->getRealUnionType();
$real_method_return_type = $method_return_type->getRealUnionType();
- 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 analyzeMethodVisibility
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeMethodVisibility(
Method $method,
Node $node
): void {
if ($method->isPublic()) {
- 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 checkPassingPropertyByReference
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function checkPassingPropertyByReference(CodeBase $code_base, Context $context, FunctionInterface $method, Parameter $parameter, Node $argument, Property $property, int $parameter_offset): void
{
$parameter_type = $parameter->getNonVariadicUnionType();
$expr_node = $argument->children['expr'] ?? null;
if ($expr_node instanceof Node &&
- 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 visitBreak
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function visitBreak(Node $node): Context
{
$depth = $node->children['depth'] ?? 1;
if (!\is_int($depth)) {
return $this->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
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return \in_array($parent_kind, self::READ_AND_WRITE_KINDS, true);
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return $parent_node !== ($parent_parent_node->children['cond'] ?? null);
Avoid too many return
statements within this method. Open
return $parent_node->children['var'] === $node;
Avoid too many return
statements within this method. Open
return $context;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return $parent_node->children['var'] === $node;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return $this->compareYieldFromAgainstDeclaredType($node, $method, $context, $type_list, $yield_from_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 false;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return $type;
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 $type->isNullableLabeled() ? MixedType::instance(true) : NonNullMixedType::instance(false);
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return null;
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;
Function checkForFunctionInterfaceIssues
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function checkForFunctionInterfaceIssues(Node $node, FunctionInterface $function): void
{
$parameters_seen = [];
foreach ($function->getParameterList() as $i => $parameter) {
if (isset($parameters_seen[$parameter->getName()])) {
- 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 checkForPHP4StyleConstructor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function checkForPHP4StyleConstructor(Clazz $class, Method $method): void
{
if ($class->isClass()
&& ($class->getElementNamespace() ?: "\\") === "\\"
&& \strcasecmp($class->getName(), $method->getName()) === 0
- 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 visitUnset
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function visitUnset(Node $node): Context
{
$context = $this->context;
// Get the type of the thing being unset
$var_node = $node->children['var'];
- 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 warnAboutInvalidUnionType
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function warnAboutInvalidUnionType(
Node $node,
Closure $is_valid_type,
UnionType $left,
UnionType $right,
- 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 visitMethod
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function visitMethod(Node $node): Context
{
if (!$this->context->isInFunctionLikeScope()) {
throw new AssertionError("Must be in function-like scope to get 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
Function visitYieldFrom
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function visitYieldFrom(Node $node): Context
{
$context = $this->context;
// Make sure we're actually returning from a method.
if (!$context->isInFunctionLikeScope()) {
- 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 findDefiningMethod
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function findDefiningMethod(FunctionInterface $method): FunctionInterface
{
if ($method instanceof Method) {
$defining_fqsen = $method->getDefiningFQSEN();
if ($method->getFQSEN() !== $defining_fqsen) {
- 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 visitClone
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function visitClone(Node $node): Context
{
$type = UnionTypeVisitor::unionTypeFromNode(
$this->code_base,
$this->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 compareYieldFromAgainstDeclaredType
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function compareYieldFromAgainstDeclaredType(Node $node, FunctionInterface $method, Context $context, array $template_type_list, UnionType $yield_from_type): Context
{
$code_base = $this->code_base;
$type_list_count = \count($template_type_list);
- 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 analyzeUnsetProp() has an NPath complexity of 264. The configured NPath complexity threshold is 200. Open
private function analyzeUnsetProp(Node $node): Context
{
$expr_node = $node->children['expr'];
$context = $this->context;
if (!($expr_node instanceof Node)) {
- 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 warnNoopNew() has an NPath complexity of 222. The configured NPath complexity threshold is 200. Open
private function warnNoopNew(
Node $node,
array $class_list
): void {
$has_constructor_or_destructor = \count($class_list) === 0;
- 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 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");
}
- 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 visitArgList() has an NPath complexity of 1089. The configured NPath complexity threshold is 200. Open
public function visitArgList(Node $node): Context
{
$argument_name_set = [];
$has_unpack = false;
- 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 checkUnionTypeCompatibility() has an NPath complexity of 288. The configured NPath complexity threshold is 200. Open
private function checkUnionTypeCompatibility(?Node $type): void
{
if (!$type) {
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 checkForInfiniteRecursionWithSameArgs() has an NPath complexity of 1168. The configured NPath complexity threshold is 200. Open
private function checkForInfiniteRecursionWithSameArgs(Node $node, FunctionInterface $method): void
{
$argument_list_node = $node->children['args'];
$parameter_list = $method->getParameterList();
if (\count($argument_list_node->children) !== \count($parameter_list)) {
- 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 updateParameterTypeByArgument() has an NPath complexity of 6240. The configured NPath complexity threshold is 200. Open
private function updateParameterTypeByArgument(
FunctionInterface $method,
Parameter $parameter,
$argument,
array $argument_types,
- 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 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
- Exclude checks
The method visitReturn() has an NPath complexity of 23424. The configured NPath complexity threshold is 200. Open
public function visitReturn(Node $node): Context
{
$context = $this->context;
// Make sure we're actually returning from a method.
if (!$context->isInFunctionLikeScope()) {
- 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 analyzeCallableWithArgumentTypes() has an NPath complexity of 948. The configured NPath complexity threshold is 200. Open
public function analyzeCallableWithArgumentTypes(
array $argument_types,
FunctionInterface $method,
array $arguments = [],
bool $erase_old_return_type = false
- 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 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,
- Exclude checks
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'];
- 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 analyzePassByReferenceArgument() has 109 lines of code. Current threshold is set to 100. Avoid really long methods. Open
private static function analyzePassByReferenceArgument(
CodeBase $code_base,
Context $context,
Node $argument,
array $argument_list,
- Exclude checks
The method visitReturn() has 116 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function visitReturn(Node $node): Context
{
$context = $this->context;
// Make sure we're actually returning from a method.
if (!$context->isInFunctionLikeScope()) {
- Exclude checks
The method analyzePassByReferenceArgument() has an NPath complexity of 348. The configured NPath complexity threshold is 200. Open
private static function analyzePassByReferenceArgument(
CodeBase $code_base,
Context $context,
Node $argument,
array $argument_list,
- 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 analyzeUnsetDim() has an NPath complexity of 1154. The configured NPath complexity threshold is 200. Open
private function analyzeUnsetDim(Node $node): void
{
$expr_node = $node->children['expr'];
if (!($expr_node instanceof Node)) {
// php -l would warn
- 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 visitStaticCall() has 108 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function visitStaticCall(Node $node): Context
{
// Get the name of the method being called
$method_name = $node->children['method'];
- Exclude checks
The method analyzeCallToFunctionLike() has an NPath complexity of 2700. The configured NPath complexity threshold is 200. Open
private function analyzeCallToFunctionLike(
FunctionInterface $method,
Node $node
): void {
$code_base = $this->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 analyzeCallToFunctionLike() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10. Open
private function analyzeCallToFunctionLike(
FunctionInterface $method,
Node $node
): void {
$code_base = $this->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 checkForInvalidNewType() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
private function checkForInvalidNewType(Node $node, array $class_list): void
{
// This is either a string (new 'something'()) or a class name (new something())
$class_node = $node->children['class'];
if (!$class_node instanceof Node) {
- 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 analyzeUnsetProp() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
private function analyzeUnsetProp(Node $node): Context
{
$expr_node = $node->children['expr'];
$context = $this->context;
if (!($expr_node instanceof Node)) {
- 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 analyzeUnsetDim() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. Open
private function analyzeUnsetDim(Node $node): void
{
$expr_node = $node->children['expr'];
if (!($expr_node instanceof Node)) {
// php -l would warn
- 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 visitNew() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function visitNew(Node $node): Context
{
$class_list = [];
try {
$context_node = new ContextNode(
- 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 analyzeProp() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function analyzeProp(Node $node, bool $is_static): Context
{
$exception_or_null = null;
try {
- 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 visitMethodCall() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public function visitMethodCall(Node $node): Context
{
$method_name = $node->children['method'];
if (!\is_string($method_name)) {
- 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 analyzeCallableWithArgumentTypes() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10. Open
public function analyzeCallableWithArgumentTypes(
array $argument_types,
FunctionInterface $method,
array $arguments = [],
bool $erase_old_return_type = 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 checkNonAncestorConstructCall() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
private function checkNonAncestorConstructCall(
Node $node,
string $static_class,
string $method_name
): void {
- 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 checkForInfiniteRecursion() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
private function checkForInfiniteRecursion(Node $node, FunctionInterface $method): void
{
$argument_list_node = $node->children['args'];
$kind = $node->kind;
if ($kind === ast\AST_METHOD_CALL || $kind === ast\AST_NULLSAFE_METHOD_CALL) {
- 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 visitReturn() has a Cyclomatic Complexity of 22. The configured cyclomatic complexity threshold is 10. Open
public function visitReturn(Node $node): Context
{
$context = $this->context;
// Make sure we're actually returning from a method.
if (!$context->isInFunctionLikeScope()) {
- 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 visitMethod() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10. Open
public function visitMethod(Node $node): Context
{
if (!$this->context->isInFunctionLikeScope()) {
throw new AssertionError("Must be in function-like scope to get 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 analyzeReturnStrict() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
private function analyzeReturnStrict(
CodeBase $code_base,
FunctionInterface $method,
UnionType $expression_type,
UnionType $method_return_type,
- 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 analyzePassByReferenceArgument() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10. Open
private static function analyzePassByReferenceArgument(
CodeBase $code_base,
Context $context,
Node $argument,
array $argument_list,
- 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 visitContinue() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function visitContinue(Node $node): Context
{
$nodes = $this->parent_node_list;
$depth = $node->children['depth'] ?? 1;
if (!\is_int($depth)) {
- 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 getStaticMethodOrEmitIssue() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
private function getStaticMethodOrEmitIssue(Node $node, string $method_name): ?Method
{
try {
// Get a reference to the method being called
$result = (new ContextNode(
- 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 analyzeMethodWithArgumentTypes() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
private function analyzeMethodWithArgumentTypes(
Node $argument_list_node,
FunctionInterface $method
): void {
$method = $this->findDefiningMethod($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 visitArgList() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10. Open
public function visitArgList(Node $node): Context
{
$argument_name_set = [];
$has_unpack = 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 checkForInfiniteRecursionWithSameArgs() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10. Open
private function checkForInfiniteRecursionWithSameArgs(Node $node, FunctionInterface $method): void
{
$argument_list_node = $node->children['args'];
$parameter_list = $method->getParameterList();
if (\count($argument_list_node->children) !== \count($parameter_list)) {
- 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 analyzeIncOrDec() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
private function analyzeIncOrDec(Node $node): Context
{
$var = $node->children['var'];
$old_type = UnionTypeVisitor::unionTypeFromNode($this->code_base, $this->context, $var);
if (!$old_type->canCastToUnionType(UnionType::fromFullyQualifiedPHPDocString('int|string|float'))) {
- 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 checkUnionTypeCompatibility() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
private function checkUnionTypeCompatibility(?Node $type): void
{
if (!$type) {
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 isAssignmentOrNestedAssignment() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
private function isAssignmentOrNestedAssignment(Node $node): ?bool
{
$parent_node_list = $this->parent_node_list;
$parent_node = \end($parent_node_list);
if (!$parent_node instanceof Node) {
- 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 emitTypeMismatchReturnIssue() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. Open
private function emitTypeMismatchReturnIssue(UnionType $expression_type, FunctionInterface $method, UnionType $method_return_type, int $lineno, $inner_node): void
{
if ($this->shouldSuppressIssue(Issue::TypeMismatchReturnReal, $lineno)) {
// Suppressing TypeMismatchReturnReal also suppresses less severe return type mismatches
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 visitStaticCall() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10. Open
public function visitStaticCall(Node $node): Context
{
// Get the name of the method being called
$method_name = $node->children['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 visitBinaryOp() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. Open
public function visitBinaryOp(Node $node): Context
{
$flags = $node->flags;
if ($this->isInNoOpPosition($node)) {
if (\in_array($flags, [flags\BINARY_BOOL_AND, flags\BINARY_BOOL_OR, flags\BINARY_COALESCE], true)) {
- 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 isAssignmentOrNestedAssignmentOrModification() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
private function isAssignmentOrNestedAssignmentOrModification(Node $node): ?bool
{
$parent_node_list = $this->parent_node_list;
$parent_node = \end($parent_node_list);
if (!$parent_node instanceof Node) {
- 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 createPassByReferenceArgumentInCall() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. Open
private function createPassByReferenceArgumentInCall(FunctionInterface $method, Node $argument, Parameter $parameter, ?Parameter $real_parameter): void
{
if ($argument->kind === ast\AST_VAR) {
// We don't do anything with the new variable; just create it
// if it doesn't exist
- 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 updateParameterTypeByArgument() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10. Open
private function updateParameterTypeByArgument(
FunctionInterface $method,
Parameter $parameter,
$argument,
array $argument_types,
- 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 warnNoopNew() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
private function warnNoopNew(
Node $node,
array $class_list
): void {
$has_constructor_or_destructor = \count($class_list) === 0;
- 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 PostOrderAnalysisVisitor has a coupling between objects value of 60. Consider to reduce the number of dependencies under 13. 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
- 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 using empty try-catch blocks in compareYieldAgainstDeclaredType. Open
} catch (RecursionDepthException $_) {
}
- Read upRead up
- Exclude checks
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
Avoid using empty try-catch blocks in visitMethod. Open
} catch (Exception $_) {
}
- Read upRead up
- Exclude checks
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
private function warnAboutInvalidUnionType(
Node $node,
Closure $is_valid_type,
UnionType $left,
UnionType $right,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 168.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!\is_string($method_name)) {
if ($method_name instanceof Node) {
$method_name = UnionTypeVisitor::anyStringLiteralForNode($this->code_base, $this->context, $method_name);
}
if (!\is_string($method_name)) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 154.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!\is_string($method_name)) {
if ($method_name instanceof Node) {
$method_name = UnionTypeVisitor::anyStringLiteralForNode($this->code_base, $this->context, $method_name);
}
if (!\is_string($method_name)) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 154.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
private const SKIP_VAR_CHECK_TYPES = [
ast\AST_ARG_LIST => true, // may be a reference
ast\AST_ARRAY_ELEM => true, // [$x, $y] = expr() is an AST_ARRAY_ELEM. visitArray() checks the right-hand side.
ast\AST_ASSIGN_OP => true, // checked in visitAssignOp
ast\AST_ASSIGN_REF => true, // Creates by reference?
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 150.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!$yield_key_type->withStaticResolvedInContext($context)->asExpandedTypes($code_base)->canCastToUnionType($expected_key_type)) {
$this->emitIssue(
Issue::TypeMismatchGeneratorYieldKey,
$node->lineno,
sprintf('(keys of %s)', ASTReverter::toShortString($node)),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 99.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!$yield_value_type->withStaticResolvedInContext($context)->asExpandedTypes($code_base)->canCastToUnionType($expected_value_type)) {
$this->emitIssue(
Issue::TypeMismatchGeneratorYieldValue,
$node->lineno,
sprintf('(values of %s)', ASTReverter::toShortString($node)),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 99.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
public const AST_CAST_FLAGS_LOOKUP = [
flags\TYPE_NULL => 'unset',
flags\TYPE_BOOL => 'bool',
flags\TYPE_LONG => 'int',
flags\TYPE_DOUBLE => 'float',
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 98.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
while ($parent_kind === ast\AST_ARRAY_ELEM) {
if ($parent_node->children['value'] !== $node) {
// e.g. analyzing `$v = [$x => $y];` for $x
return false;
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 97.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
while ($parent_kind === ast\AST_ARRAY_ELEM) {
if ($parent_node->children['value'] !== $node) {
// e.g. analyzing `$v = [$x => $y];` for $x
return false;
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 97.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (BlockAnalysisVisitor::isEmptyIterable($yield_from_type)) {
RedundantCondition::emitInstance(
$node->children['expr'],
$this->code_base,
(clone($this->context))->withLineNumberStart($node->children['expr']->lineno ?? $node->lineno),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 95.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!$yield_key_type->withStaticResolvedInContext($context)->asExpandedTypes($code_base)->canCastToUnionType($expected_key_type->withStaticResolvedInContext($context))) {
$this->emitIssue(
Issue::TypeMismatchGeneratorYieldKey,
$node->lineno,
ASTReverter::toShortString($yield_key_node),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 95.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!$yield_value_type->withStaticResolvedInContext($context)->asExpandedTypes($code_base)->canCastToUnionType($expected_value_type->withStaticResolvedInContext($context))) {
$this->emitIssue(
Issue::TypeMismatchGeneratorYieldValue,
$node->lineno,
ASTReverter::toShortString($yield_value_node),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 95.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76