mirror of
https://github.com/danog/psalm.git
synced 2024-12-03 10:07:52 +01:00
Fixup
This commit is contained in:
parent
a8ccc92da4
commit
34b427286a
@ -1386,10 +1386,11 @@ final class AssertionFinder
|
||||
|
||||
/**
|
||||
* @param Identical|Equal|NotIdentical|NotEqual $conditional
|
||||
* @return false|int
|
||||
*/
|
||||
private static function hasGetTypeCheck(
|
||||
PhpParser\Node\Expr\BinaryOp $conditional,
|
||||
): false|int {
|
||||
): bool|int {
|
||||
if ($conditional->right instanceof PhpParser\Node\Expr\FuncCall
|
||||
&& $conditional->right->name instanceof PhpParser\Node\Name
|
||||
&& strtolower($conditional->right->name->getFirst()) === 'gettype'
|
||||
@ -1413,10 +1414,11 @@ final class AssertionFinder
|
||||
|
||||
/**
|
||||
* @param Identical|Equal|NotIdentical|NotEqual $conditional
|
||||
* @return false|int
|
||||
*/
|
||||
private static function hasGetDebugTypeCheck(
|
||||
PhpParser\Node\Expr\BinaryOp $conditional,
|
||||
): false|int {
|
||||
): bool|int {
|
||||
if ($conditional->right instanceof PhpParser\Node\Expr\FuncCall
|
||||
&& $conditional->right->name instanceof PhpParser\Node\Name
|
||||
&& strtolower($conditional->right->name->getFirst()) === 'get_debug_type'
|
||||
@ -1442,11 +1444,12 @@ final class AssertionFinder
|
||||
|
||||
/**
|
||||
* @param Identical|Equal|NotIdentical|NotEqual $conditional
|
||||
* @return false|int
|
||||
*/
|
||||
private static function hasGetClassCheck(
|
||||
PhpParser\Node\Expr\BinaryOp $conditional,
|
||||
FileSource $source,
|
||||
): false|int {
|
||||
): bool|int {
|
||||
if (!$source instanceof StatementsAnalyzer) {
|
||||
return false;
|
||||
}
|
||||
@ -1534,11 +1537,12 @@ final class AssertionFinder
|
||||
|
||||
/**
|
||||
* @param Greater|GreaterOrEqual|Smaller|SmallerOrEqual $conditional
|
||||
* @return false|int
|
||||
*/
|
||||
private static function hasNonEmptyCountEqualityCheck(
|
||||
PhpParser\Node\Expr\BinaryOp $conditional,
|
||||
?int &$min_count,
|
||||
): false|int {
|
||||
): bool|int {
|
||||
if ($conditional->left instanceof PhpParser\Node\Expr\FuncCall
|
||||
&& $conditional->left->name instanceof PhpParser\Node\Name
|
||||
&& in_array(strtolower($conditional->left->name->getFirst()), ['count', 'sizeof'])
|
||||
@ -1575,11 +1579,12 @@ final class AssertionFinder
|
||||
|
||||
/**
|
||||
* @param Greater|GreaterOrEqual|Smaller|SmallerOrEqual $conditional
|
||||
* @return false|int
|
||||
*/
|
||||
private static function hasLessThanCountEqualityCheck(
|
||||
PhpParser\Node\Expr\BinaryOp $conditional,
|
||||
?int &$max_count,
|
||||
): false|int {
|
||||
): bool|int {
|
||||
$left_count = $conditional->left instanceof PhpParser\Node\Expr\FuncCall
|
||||
&& $conditional->left->name instanceof PhpParser\Node\Name
|
||||
&& in_array(strtolower($conditional->left->name->getFirst()), ['count', 'sizeof'])
|
||||
@ -1623,11 +1628,12 @@ final class AssertionFinder
|
||||
|
||||
/**
|
||||
* @param Equal|Identical|NotEqual|NotIdentical $conditional
|
||||
* @return false|int
|
||||
*/
|
||||
private static function hasCountEqualityCheck(
|
||||
PhpParser\Node\Expr\BinaryOp $conditional,
|
||||
?int &$count,
|
||||
): false|int {
|
||||
): bool|int {
|
||||
$left_count = $conditional->left instanceof PhpParser\Node\Expr\FuncCall
|
||||
&& $conditional->left->name instanceof PhpParser\Node\Name
|
||||
&& in_array(strtolower($conditional->left->name->getFirst()), ['count', 'sizeof'])
|
||||
@ -1655,12 +1661,13 @@ final class AssertionFinder
|
||||
|
||||
/**
|
||||
* @param PhpParser\Node\Expr\BinaryOp\Greater|PhpParser\Node\Expr\BinaryOp\GreaterOrEqual $conditional
|
||||
* @return false|int
|
||||
*/
|
||||
private static function hasSuperiorNumberCheck(
|
||||
FileSource $source,
|
||||
PhpParser\Node\Expr\BinaryOp $conditional,
|
||||
?int &$literal_value_comparison,
|
||||
): false|int {
|
||||
): bool|int {
|
||||
$right_assignment = false;
|
||||
$value_right = null;
|
||||
if ($source instanceof StatementsAnalyzer
|
||||
@ -1714,12 +1721,13 @@ final class AssertionFinder
|
||||
|
||||
/**
|
||||
* @param PhpParser\Node\Expr\BinaryOp\Smaller|PhpParser\Node\Expr\BinaryOp\SmallerOrEqual $conditional
|
||||
* @return false|int
|
||||
*/
|
||||
private static function hasInferiorNumberCheck(
|
||||
FileSource $source,
|
||||
PhpParser\Node\Expr\BinaryOp $conditional,
|
||||
?int &$literal_value_comparison,
|
||||
): false|int {
|
||||
): bool|int {
|
||||
$right_assignment = false;
|
||||
$value_right = null;
|
||||
if ($source instanceof StatementsAnalyzer
|
||||
@ -1773,10 +1781,11 @@ final class AssertionFinder
|
||||
|
||||
/**
|
||||
* @param PhpParser\Node\Expr\BinaryOp\Greater|PhpParser\Node\Expr\BinaryOp\GreaterOrEqual $conditional
|
||||
* @return false|int
|
||||
*/
|
||||
private static function hasReconcilableNonEmptyCountEqualityCheck(
|
||||
PhpParser\Node\Expr\BinaryOp $conditional,
|
||||
): false|int {
|
||||
): bool|int {
|
||||
$left_count = $conditional->left instanceof PhpParser\Node\Expr\FuncCall
|
||||
&& $conditional->left->name instanceof PhpParser\Node\Name
|
||||
&& in_array(strtolower($conditional->left->name->getFirst()), ['count', 'sizeof']);
|
||||
@ -1794,11 +1803,12 @@ final class AssertionFinder
|
||||
|
||||
/**
|
||||
* @param Identical|Equal|NotIdentical|NotEqual $conditional
|
||||
* @return false|int
|
||||
*/
|
||||
private static function hasTypedValueComparison(
|
||||
PhpParser\Node\Expr\BinaryOp $conditional,
|
||||
FileSource $source,
|
||||
): false|int {
|
||||
): bool|int {
|
||||
if (!$source instanceof StatementsAnalyzer) {
|
||||
return false;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ final class AssignmentAnalyzer
|
||||
?PhpParser\Comment\Doc $doc_comment,
|
||||
array $not_ignored_docblock_var_ids = [],
|
||||
?PhpParser\Node\Expr $assign_expr = null,
|
||||
): false|Union {
|
||||
): ?Union {
|
||||
$var_id = ExpressionIdentifier::getVarId(
|
||||
$assign_var,
|
||||
$statements_analyzer->getFQCLN(),
|
||||
@ -680,7 +680,7 @@ final class AssignmentAnalyzer
|
||||
$assign_value,
|
||||
$assign_value_type,
|
||||
$context,
|
||||
) === false) {
|
||||
) === null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -536,7 +536,7 @@ final class ExpressionAnalyzer
|
||||
!$from_stmt ? $stmt : null,
|
||||
);
|
||||
|
||||
if ($assignment_type === false) {
|
||||
if ($assignment_type === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,6 @@ use function reset;
|
||||
use function serialize;
|
||||
use function substr;
|
||||
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @psalm-immutable
|
||||
|
@ -1118,7 +1118,7 @@ final class Psalm
|
||||
}
|
||||
|
||||
/** @return false|'always'|'auto' */
|
||||
private static function shouldFindUnusedCode(array $options, Config $config): false|string
|
||||
private static function shouldFindUnusedCode(array $options, Config $config): bool|string
|
||||
{
|
||||
$find_unused_code = false;
|
||||
if (isset($options['find-dead-code'])) {
|
||||
|
@ -20,8 +20,6 @@ use function preg_replace;
|
||||
use function strlen;
|
||||
use function strtolower;
|
||||
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
@ -46,8 +46,6 @@ use function spl_object_id;
|
||||
use function strpos;
|
||||
use function strtolower;
|
||||
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
@ -21,7 +21,6 @@ use function mkdir;
|
||||
use function strtolower;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -20,7 +20,6 @@ use function mkdir;
|
||||
use function strtolower;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -32,7 +32,6 @@ use function touch;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
use const LOCK_EX;
|
||||
use const PHP_VERSION_ID;
|
||||
use const SCANDIR_SORT_NONE;
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,6 @@ use function mkdir;
|
||||
use function touch;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
/**
|
||||
* Used to determine which files reference other files, necessary for using the --diff
|
||||
|
@ -37,8 +37,6 @@ use function str_starts_with;
|
||||
use function strlen;
|
||||
use function strpos;
|
||||
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
@ -22,7 +22,7 @@ final class ArgTypeInferer
|
||||
) {
|
||||
}
|
||||
|
||||
public function infer(PhpParser\Node\Arg $arg): false|Union
|
||||
public function infer(PhpParser\Node\Arg $arg): null|Union
|
||||
{
|
||||
$already_inferred_type = $this->statements_analyzer->node_data->getType($arg->value);
|
||||
|
||||
@ -31,7 +31,7 @@ final class ArgTypeInferer
|
||||
}
|
||||
|
||||
if (ExpressionAnalyzer::analyze($this->statements_analyzer, $arg->value, $this->context) === false) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->statements_analyzer->node_data->getType($arg->value) ?? Type::getMixed();
|
||||
|
Loading…
Reference in New Issue
Block a user