diff --git a/config.xsd b/config.xsd index d6a58c68cb2..5c49e602c8c 100644 --- a/config.xsd +++ b/config.xsd @@ -388,6 +388,7 @@ + diff --git a/psalm.xml.dist b/psalm.xml.dist index 1a0aa064f06..15e16fd8118 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -59,6 +59,7 @@ + diff --git a/src/Psalm/Internal/Diff/FileDiffer.php b/src/Psalm/Internal/Diff/FileDiffer.php index e9c06c02ae4..668c6456bc5 100644 --- a/src/Psalm/Internal/Diff/FileDiffer.php +++ b/src/Psalm/Internal/Diff/FileDiffer.php @@ -77,8 +77,6 @@ private static function extractDiff(array $trace, int $x, int $y, array $a, arra { $result = []; for ($d = count($trace) - 1; $d >= 0; --$d) { - // Todo: fix integer ranges in fors - /** @var int<0, max> $d */ $v = $trace[$d]; $k = $x - $y; diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php index 0196abd6471..ceca445a355 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php @@ -1032,6 +1032,7 @@ private static function handleReturn( && !$storage->signature_return_type ) { $new = []; + /** @var SplQueue> */ $queue = new SplQueue; $queue->enqueue($storage->return_type->getAtomicTypes()); $queue->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_DELETE); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php index a38c52f7453..d9873f0925d 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php @@ -101,7 +101,6 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev } else { return Type::getArray(); } - $unpacked_type_parts = $unpacked_type_parts->getAtomicTypes(); } else { $unpacked_type_parts = [$type_part]; } diff --git a/src/Psalm/Internal/Provider/StatementsProvider.php b/src/Psalm/Internal/Provider/StatementsProvider.php index da27b46304f..7e265ab3940 100644 --- a/src/Psalm/Internal/Provider/StatementsProvider.php +++ b/src/Psalm/Internal/Provider/StatementsProvider.php @@ -4,6 +4,7 @@ use PhpParser; use PhpParser\ErrorHandler\Collecting; +use PhpParser\Lexer\Emulative; use PhpParser\Node; use PhpParser\Node\Arg; use PhpParser\Node\Expr\ArrayDimFetch; @@ -15,6 +16,7 @@ use PhpParser\Node\Name; use PhpParser\Node\Stmt; use PhpParser\NodeVisitorAbstract; +use PhpParser\Parser; use Psalm\CodeLocation\ParseErrorLocation; use Psalm\Codebase; use Psalm\Config; diff --git a/src/Psalm/Internal/Scope/IfScope.php b/src/Psalm/Internal/Scope/IfScope.php index bef109183d8..38708e3aae4 100644 --- a/src/Psalm/Internal/Scope/IfScope.php +++ b/src/Psalm/Internal/Scope/IfScope.php @@ -62,19 +62,14 @@ class IfScope */ public ?array $negatable_if_types = null; - /** - * @var ClauseConjunction - */ - public array $negated_clauses = []; + public ClauseConjunction $negated_clauses; /** * These are the set of clauses that could be applied after the `if` * statement, if the `if` statement contains branches with leaving statements, * and the else leaves too - * - * @var ClauseConjunction */ - public array $reasonable_clauses = []; + public ClauseConjunction $reasonable_clauses; /** * @var string[] diff --git a/src/Psalm/Internal/Scope/SwitchScope.php b/src/Psalm/Internal/Scope/SwitchScope.php index 005823ef842..b3f6369cd6c 100644 --- a/src/Psalm/Internal/Scope/SwitchScope.php +++ b/src/Psalm/Internal/Scope/SwitchScope.php @@ -38,10 +38,7 @@ class SwitchScope public ?PhpParser\Node\Expr $leftover_case_equality_expr = null; - /** - * @var ClauseConjunction - */ - public array $negated_clauses = []; + public ClauseConjunction $negated_clauses; /** * @var array|null diff --git a/tests/Traits/InvalidCodeAnalysisTestTrait.php b/tests/Traits/InvalidCodeAnalysisTestTrait.php index fc022cd7a75..a6e8eb6d304 100644 --- a/tests/Traits/InvalidCodeAnalysisTestTrait.php +++ b/tests/Traits/InvalidCodeAnalysisTestTrait.php @@ -47,12 +47,10 @@ public function testInvalidCode( $code = str_replace("\n", "\r\n", $code); } - foreach ($error_levels as $error_level) { - $issue_name = $error_level; - $error_level = Config::REPORT_SUPPRESS; - - Config::getInstance()->setCustomErrorLevel($issue_name, $error_level); + foreach ($error_levels as $issue_name) { + Config::getInstance()->setCustomErrorLevel($issue_name, Config::REPORT_SUPPRESS); } + Config::getInstance()->setCustomErrorLevel('LiteralKeyUnshapedArray', Config::REPORT_SUPPRESS); $this->project_analyzer->setPhpVersion($php_version, 'tests'); diff --git a/tests/Traits/ValidCodeAnalysisTestTrait.php b/tests/Traits/ValidCodeAnalysisTestTrait.php index ea9e70a4661..4cbd75a3934 100644 --- a/tests/Traits/ValidCodeAnalysisTestTrait.php +++ b/tests/Traits/ValidCodeAnalysisTestTrait.php @@ -59,6 +59,8 @@ public function testValidCode( Config::getInstance()->setCustomErrorLevel($issue_name, Config::REPORT_SUPPRESS); } + Config::getInstance()->setCustomErrorLevel('LiteralKeyUnshapedArray', Config::REPORT_SUPPRESS); + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $code = str_replace("\n", "\r\n", $code); } diff --git a/tests/TypeReconciliation/RedundantConditionTest.php b/tests/TypeReconciliation/RedundantConditionTest.php index 8f8afef3607..7b105c7ac3a 100644 --- a/tests/TypeReconciliation/RedundantConditionTest.php +++ b/tests/TypeReconciliation/RedundantConditionTest.php @@ -900,18 +900,6 @@ public function get(): ?stdClass{ return new stdClass;} } }', ], - 'countWithNeverValuesInKeyedList' => [ - 'code' => ' [ 'code' => '