Showing 3,272 of 4,939 total issues
Method guessErrorColumnUsingTokens
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function guessErrorColumnUsingTokens(
FileCacheEntry $file_cache_entry,
Error $native_parse_error
): int {
if (!\function_exists('token_get_all')) {
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'))) {
Consider simplifying this complex logical expression. Open
if ((
(
$lnode->children['prop'] instanceof Node
&& $lnode->children['prop']->kind === ast\AST_VAR
)
Method getClassListInner
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getClassListInner(bool $ignore_missing_classes): array
{
$node = $this->node;
if (!($node instanceof Node)) {
if (\is_string($node)) {
Method recordHoverTextForElementType
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function recordHoverTextForElementType(
CodeBase $code_base,
Context $context,
TypedElementInterface $element
): void {
Method readMessages
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function readMessages(): int
{
$emitted_messages = 0;
while (($c = \fgetc($this->input)) !== false && $c !== '') {
$this->buffer .= $c;
Method analyzeBinaryBitwiseCommon
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function analyzeBinaryBitwiseCommon(Node $node): UnionType
{
$left = UnionTypeVisitor::unionTypeFromNode(
$this->code_base,
$this->context,
Method phpParserStmtlistToAstNode
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function phpParserStmtlistToAstNode($parser_nodes, ?int $lineno, bool $return_null_on_empty = false): ?\ast\Node
{
if ($parser_nodes instanceof PhpParser\Node\Statement\CompoundStatementNode) {
$parser_nodes = $parser_nodes->statements;
} elseif ($parser_nodes instanceof PhpParser\Node\StatementNode) {
Method visitNew
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitNew(Node $node): UnionType
{
static $object_type;
if ($object_type === null) {
$object_type = ObjectType::instance(false);
Method extractUnionType
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function extractUnionType(array $flags): UnionType
{
static $type_lookup = null;
if ($type_lookup === null) {
$type_lookup = [
Method makeIfLoaded
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function makeIfLoaded(string $namespace, string $name)
{
$name_parts = \explode('\\', $name);
$name = (string)\array_pop($name_parts);
if ($name === '') {
Method parseGenericArrayTypeFromTemplateParameterList
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function parseGenericArrayTypeFromTemplateParameterList(
array $template_parameter_type_list,
bool $is_nullable,
bool $always_has_elements,
bool $is_associative
Method analyzeNumericArithmeticOp
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function analyzeNumericArithmeticOp(Node $node, bool $combination_is_int): Context
{
return $this->updateTargetWithType($node, function (UnionType $left) use ($node, $combination_is_int): UnionType {
$code_base = $this->code_base;
$context = $this->context;
Method analyzeClassInheritance
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function analyzeClassInheritance(
CodeBase $code_base,
Clazz $clazz
): void {
Method tryToAssignPHPDocTypeToParameter
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function tryToAssignPHPDocTypeToParameter(
CodeBase $code_base,
FunctionInterface $method,
int $i,
Parameter $parameter,
Method compareNamedParameters
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function compareNamedParameters(): void
{
if (PHP_MAJOR_VERSION < 8) {
fwrite(STDERR, "compare-named-parameters MUST BE RUN IN PHP 8.0+, BUT WAS RUN IN " . PHP_VERSION . "\n");
fwrite(STDERR, "exiting without generating stubs\n");
Method visitVar
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitVar(Node $node): void
{
// @phan-suppress-next-line PhanUndeclaredProperty
if ($node->flags & PhanAnnotationAdder::FLAG_INITIALIZES || isset($node->is_reference)) {
return;
Function exportFunctionAndMethodSet
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function exportFunctionAndMethodSet(): array
{
$result = [];
foreach ($this->getFunctionAndMethodSet() as $function_or_method) {
if ($function_or_method->isPHPInternal()) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function recordTypeOfElement
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function recordTypeOfElement(
CodeBase $code_base,
Context $context,
TypedElementInterface $element
): 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
Function fromReflectionParameter
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function fromReflectionParameter(
\ReflectionParameter $reflection_parameter
): Parameter {
$flags = 0;
// Check to see if it's a pass-by-reference parameter
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"