mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix #3240 - check arguments when class cannot be found
This commit is contained in:
parent
aceaf6c356
commit
618a54ff41
@ -288,9 +288,25 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna
|
||||
$statements_analyzer->node_data->setType($stmt, $new_type);
|
||||
}
|
||||
|
||||
self::checkFunctionArguments(
|
||||
$statements_analyzer,
|
||||
$stmt->args,
|
||||
null,
|
||||
null,
|
||||
$context
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
self::checkFunctionArguments(
|
||||
$statements_analyzer,
|
||||
$stmt->args,
|
||||
null,
|
||||
null,
|
||||
$context
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -311,6 +327,14 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna
|
||||
|
||||
if ($context->check_classes) {
|
||||
if ($context->isPhantomClass($fq_class_name)) {
|
||||
self::checkFunctionArguments(
|
||||
$statements_analyzer,
|
||||
$stmt->args,
|
||||
null,
|
||||
null,
|
||||
$context
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -323,6 +347,14 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna
|
||||
$statements_analyzer->getSuppressedIssues(),
|
||||
false
|
||||
) === false) {
|
||||
self::checkFunctionArguments(
|
||||
$statements_analyzer,
|
||||
$stmt->args,
|
||||
null,
|
||||
null,
|
||||
$context
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -543,6 +575,14 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna
|
||||
$stmt_type->reference_free = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self::checkFunctionArguments(
|
||||
$statements_analyzer,
|
||||
$stmt->args,
|
||||
null,
|
||||
null,
|
||||
$context
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1100,7 +1100,13 @@ class MethodCallTest extends TestCase
|
||||
|
||||
foo(new AChild());',
|
||||
'error_message' => 'PossiblyNullArgument'
|
||||
]
|
||||
],
|
||||
'checkVariableInUnknownClassConstructor' => [
|
||||
'<?php
|
||||
/** @psalm-suppress UndefinedClass */
|
||||
new Missing($class_arg);',
|
||||
'error_message' => 'PossiblyUndefinedVariable',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user