Showing 3,272 of 4,939 total issues
Function maybeWarnSameNamespaceUse
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function maybeWarnSameNamespaceUse(string $alias, FullyQualifiedGlobalStructuralElement $target, int $flags, int $lineno): void
{
if (\strcasecmp($alias, $target->getName()) !== 0) {
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 parseMultiPartHeredoc
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static function parseMultiPartHeredoc(PhpParser\Node\StringLiteral $n, array $children): ast\Node
{
$inner_node_parts = [];
$end_of_start_quote = self::$file_contents[$n->startQuote->start + $n->startQuote->length - 1];
$end_quote_text = $n->endQuote->getText(self::$file_contents);
- 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 fromTypeInSignature
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function fromTypeInSignature(Node $node): UnionType
{
$is_nullable = $node->kind === ast\AST_NULLABLE_TYPE;
if ($is_nullable) {
$node = $node->children['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 analyzeFunctions
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function analyzeFunctions(CodeBase $code_base, array $file_filter = null): void
{
$plugin_set = ConfigPluginSet::instance();
$has_function_or_method_plugins = $plugin_set->hasAnalyzeFunctionPlugins() || $plugin_set->hasAnalyzeMethodPlugins();
$show_progress = CLI::shouldShowProgress();
- 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 updateSignatureParamNames
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function updateSignatureParamNames(string $function_like_name, array $arguments_from_phan): array
{
$arguments_from_external_stub = $this->parseFunctionLikeSignature($function_like_name);
if (is_null($arguments_from_external_stub)) {
return $arguments_from_phan;
- 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 extractInfoFromReflection
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static function extractInfoFromReflection(): array
{
$result = [];
$function_names = get_defined_functions();
unset($function_names['user']);
- 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 shouldWarnAboutMoreSpecificType
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static function shouldWarnAboutMoreSpecificType(CodeBase $code_base, UnionType $actual_type, UnionType $declared_return_type): bool
{
if ($declared_return_type->isEmpty()) {
// There was no phpdoc type declaration, so let UnknownElementTypePlugin warn about that instead of this.
// This plugin warns about `@return mixed` but not the absence of a declaration because the former normally prevents phan from inferring something more specific.
- 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 generateStaticElementSuggestionsForClass
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function generateStaticElementSuggestionsForClass(string $class, string $instance_element_prefix): array
{
// TODO support ::class
if (!class_exists($class)) {
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 areAllSwitchCasesTheSameType
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static function areAllSwitchCasesTheSameType(array $values_to_check): bool
{
$categories = 0;
foreach ($values_to_check as $value) {
if (is_int($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
Function getAnalyzeFunctionCallClosures
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function getAnalyzeFunctionCallClosures(CodeBase $code_base): array
{
/**
* @param list<Node|string|int|float> $args the nodes for the arguments to the invocation
*/
- 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 initializeTypeCastingMatrix
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function initializeTypeCastingMatrix(): array
{
/**
* @return array<string,bool>
*/
Method castTypeListToCountable
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function castTypeListToCountable(CodeBase $code_base, array $type_list, bool $assume_subclass_implements_countable): array
{
$result = [];
foreach ($type_list as $type) {
if ($type instanceof IterableType) {
Method analyzeSetUnionTypePassByRef
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function analyzeSetUnionTypePassByRef(
CodeBase $code_base,
Context $context,
PassByReferenceVariable $reference_element,
UnionType $new_type,
Method checkErrorProneTruthyCast
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function checkErrorProneTruthyCast(Node $node, Context $context, UnionType $union_type): void
{
// Here, we only perform the redundant condition checks on whichever ran first, to avoid warning about both impossible and redundant conditions
if (isset($node->did_check_error_prone_truthy)) {
return;
Method checkIsDeprecatedOrInternal
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function checkIsDeprecatedOrInternal(CodeBase $code_base, Context $context, FunctionInterface $method): void
{
// Special common cases where we want slightly
// better multi-signature error messages
if ($method->isPHPInternal()) {
Method warnOverridingFinalMethod
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function warnOverridingFinalMethod(CodeBase $code_base, Method $method, Clazz $class, Method $o_method): void
{
if ($method->isFromPHPDoc()) {
// TODO: Track phpdoc methods separately from real methods
if ($class->checkHasSuppressIssueAndIncrementCount(Issue::AccessOverridesFinalMethodPHPDoc)) {
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 computeBinaryOpResult
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function computeBinaryOpResult($left, $right, int $flags)
{
// Don't make errors in the analyzed code crash Phan (e.g. converting arrays to strings).
return self::evalSuppressingErrors(/** @return Node|array|int|string|float|bool|null */ static function () use ($left, $right, $flags) {
switch ($flags) {
Method visitMatchArmList
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitMatchArmList(Node $node): void
{
$children = $node->children;
if (!$children) {
// This plugin will never emit errors if there are 0 elements.