1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Add a few more list types

This commit is contained in:
Brown 2019-10-08 19:06:16 -04:00
parent 2d4a7fbe3e
commit 23fcbec584
5 changed files with 18 additions and 18 deletions

View File

@ -496,7 +496,7 @@ class Codebase
/**
* @param string $file_path
*
* @return array<int, PhpParser\Node\Stmt>
* @return list<PhpParser\Node\Stmt>
*/
public function getStatementsForFile($file_path)
{

View File

@ -68,7 +68,7 @@ class ParserCacheProvider
* @param string $file_content_hash
* @param string $file_path
*
* @return array<int, PhpParser\Node\Stmt>|null
* @return list<PhpParser\Node\Stmt>|null
*
* @psalm-suppress UndefinedFunction
*/
@ -96,10 +96,10 @@ class ParserCacheProvider
&& filemtime($cache_location) > $file_modified_time
) {
if ($this->use_igbinary) {
/** @var array<int, \PhpParser\Node\Stmt> */
/** @var list<\PhpParser\Node\Stmt> */
$stmts = igbinary_unserialize((string)file_get_contents($cache_location));
} else {
/** @var array<int, \PhpParser\Node\Stmt> */
/** @var list<\PhpParser\Node\Stmt> */
$stmts = unserialize((string)file_get_contents($cache_location));
}
@ -110,7 +110,7 @@ class ParserCacheProvider
/**
* @param string $file_path
*
* @return array<int, PhpParser\Node\Stmt>|null
* @return list<PhpParser\Node\Stmt>|null
*
* @psalm-suppress UndefinedFunction
*/
@ -132,11 +132,11 @@ class ParserCacheProvider
if (is_readable($cache_location)) {
if ($this->use_igbinary) {
/** @var array<int, \PhpParser\Node\Stmt> */
/** @var list<\PhpParser\Node\Stmt> */
return igbinary_unserialize((string)file_get_contents($cache_location)) ?: null;
}
/** @var array<int, \PhpParser\Node\Stmt> */
/** @var list<\PhpParser\Node\Stmt> */
return unserialize((string)file_get_contents($cache_location)) ?: null;
}
}
@ -211,7 +211,7 @@ class ParserCacheProvider
/**
* @param string $file_path
* @param string $file_content_hash
* @param array<int, PhpParser\Node\Stmt> $stmts
* @param list<PhpParser\Node\Stmt> $stmts
* @param bool $touch_only
*
* @return void

View File

@ -84,7 +84,7 @@ class StatementsProvider
/**
* @param string $file_path
*
* @return array<int, \PhpParser\Node\Stmt>
* @return list<\PhpParser\Node\Stmt>
*/
public function getStatementsForFile($file_path, Progress $progress = null)
{
@ -153,7 +153,7 @@ class StatementsProvider
$traverser = new PhpParser\NodeTraverser;
$traverser->addVisitor(new \Psalm\Internal\Visitor\CloningVisitor);
// performs a deep clone
/** @var array<int, PhpParser\Node\Stmt> */
/** @var list<PhpParser\Node\Stmt> */
$existing_statements_copy = $traverser->traverse($existing_statements);
} else {
$file_changes = null;
@ -355,10 +355,10 @@ class StatementsProvider
/**
* @param string $file_contents
* @param string $file_path
* @param array<int, \PhpParser\Node\Stmt> $existing_statements
* @param list<\PhpParser\Node\Stmt> $existing_statements
* @param array<int, array{0:int, 1:int, 2: int, 3: int, 4: int, 5:string}> $file_changes
*
* @return array<int, \PhpParser\Node\Stmt>
* @return list<\PhpParser\Node\Stmt>
*/
public static function parseStatements(
$file_contents,
@ -400,7 +400,7 @@ class StatementsProvider
$stmts = $existing_statements;
} else {
try {
/** @var array<int, \PhpParser\Node\Stmt> */
/** @var list<\PhpParser\Node\Stmt> */
$stmts = self::$parser->parse($file_contents, $error_handler) ?: [];
} catch (\Throwable $t) {
$stmts = [];
@ -410,7 +410,7 @@ class StatementsProvider
}
} else {
try {
/** @var array<int, \PhpParser\Node\Stmt> */
/** @var list<\PhpParser\Node\Stmt> */
$stmts = self::$parser->parse($file_contents, $error_handler) ?: [];
} catch (\Throwable $t) {
$stmts = [];

View File

@ -99,7 +99,7 @@ class FileDiffTest extends TestCase
$traverser = new PhpParser\NodeTraverser;
$traverser->addVisitor(new \Psalm\Internal\Visitor\CloningVisitor);
// performs a deep clone
/** @var array<int, PhpParser\Node\Stmt> */
/** @var list<PhpParser\Node\Stmt> */
$a_stmts_copy = $traverser->traverse($a_stmts);
$this->assertTreesEqual($a_stmts, $a_stmts_copy);

View File

@ -17,7 +17,7 @@ class ParserInstanceCacheProvider extends \Psalm\Internal\Provider\ParserCachePr
private $file_content_hash = [];
/**
* @var array<string, array<int, PhpParser\Node\Stmt>>
* @var array<string, list<PhpParser\Node\Stmt>>
*/
private $statements_cache = [];
@ -52,7 +52,7 @@ class ParserInstanceCacheProvider extends \Psalm\Internal\Provider\ParserCachePr
* @param string $file_path
* @param mixed $file_modified_time
*
* @return array<int, PhpParser\Node\Stmt>|null
* @return list<PhpParser\Node\Stmt>|null
*/
public function loadExistingStatementsFromCache($file_path)
{
@ -66,7 +66,7 @@ class ParserInstanceCacheProvider extends \Psalm\Internal\Provider\ParserCachePr
/**
* @param string $file_path
* @param string $file_content_hash
* @param array<int, PhpParser\Node\Stmt> $stmts
* @param list<PhpParser\Node\Stmt> $stmts
* @param bool $touch_only
*
* @return void