1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00
This commit is contained in:
Daniil Gentili 2023-10-19 17:38:56 +02:00
parent 78900857ba
commit 048f55d253
8 changed files with 35 additions and 16 deletions

View File

@ -51,6 +51,8 @@ class CodeLocation
protected int $file_end;
protected bool $single_line;
protected int $preview_start;
private int $preview_end = -1;
@ -65,12 +67,20 @@ class CodeLocation
private string $snippet = '';
private ?string $text = null;
public ?int $docblock_start = null;
private ?int $docblock_start_line_number = null;
protected ?int $docblock_line_number = null;
private ?int $regex_type = null;
private bool $have_recalculated = false;
public ?CodeLocation $previous_location = null;
public const VAR_TYPE = 0;
public const FUNCTION_RETURN_TYPE = 1;
public const FUNCTION_PARAM_TYPE = 2;
@ -83,11 +93,11 @@ class CodeLocation
public function __construct(
FileSource $file_source,
PhpParser\Node $stmt,
public ?CodeLocation $previous_location = null,
protected bool $single_line = false,
private ?int $regex_type = null,
private ?string $text = null,
protected ?int $docblock_line_number = null,
?CodeLocation $previous_location = null,
bool $single_line = false,
?int $regex_type = null,
?string $selected_text = null,
?int $comment_line = null,
) {
/** @psalm-suppress ImpureMethodCall Actually mutation-free just not marked */
$this->file_start = (int)$stmt->getAttribute('startFilePos');
@ -97,6 +107,10 @@ class CodeLocation
$this->raw_file_end = $this->file_end;
$this->file_path = $file_source->getFilePath();
$this->file_name = $file_source->getFileName();
$this->single_line = $single_line;
$this->regex_type = $regex_type;
$this->previous_location = $previous_location;
$this->text = $selected_text;
/** @psalm-suppress ImpureMethodCall Actually mutation-free just not marked */
$doc_comment = $stmt->getDocComment();
@ -108,6 +122,8 @@ class CodeLocation
/** @psalm-suppress ImpureMethodCall Actually mutation-free just not marked */
$this->raw_line_number = $stmt->getLine();
$this->docblock_line_number = $comment_line;
}
/**

View File

@ -6,6 +6,6 @@ namespace Psalm\Exception;
use Exception;
final class DocblockParseException extends Exception
class DocblockParseException extends Exception
{
}

View File

@ -21,7 +21,7 @@ use function count;
*
* @internal
*/
final class AstDiffer
abstract class AstDiffer
{
/**
* @param Closure(Stmt, Stmt, string, string, bool=): bool $is_equal
@ -29,7 +29,7 @@ final class AstDiffer
* @param array<int, Stmt> $b
* @return array{0:non-empty-list<array<int, int>>, 1: int, 2: int, 3: array<int, bool>}
*/
private static function calculateTrace(
protected static function calculateTrace(
Closure $is_equal,
array $a,
array $b,
@ -81,7 +81,7 @@ final class AstDiffer
* @return list<DiffElem>
* @psalm-pure
*/
private static function extractDiff(array $trace, int $x, int $y, array $a, array $b, array $bc): array
protected static function extractDiff(array $trace, int $x, int $y, array $a, array $b, array $bc): array
{
$result = [];
for ($d = count($trace) - 1; $d >= 0; --$d) {

View File

@ -26,7 +26,7 @@ use const PHP_VERSION_ID;
/**
* @internal
*/
final class ClassLikeStorageCacheProvider
class ClassLikeStorageCacheProvider
{
private readonly Cache $cache;

View File

@ -28,7 +28,7 @@ use const LOCK_EX;
* @psalm-import-type FileMapType from Analyzer
* @internal
*/
final class FileReferenceCacheProvider
class FileReferenceCacheProvider
{
private const REFERENCE_CACHE_NAME = 'references';
private const CLASSLIKE_FILE_CACHE_NAME = 'classlike_files';
@ -50,10 +50,13 @@ final class FileReferenceCacheProvider
private const FILE_MISSING_MEMBER_CACHE_NAME = 'file_missing_member';
private const UNKNOWN_MEMBER_CACHE_NAME = 'unknown_member_references';
private const METHOD_PARAM_USE_CACHE_NAME = 'method_param_uses';
private readonly Cache $cache;
public function __construct(protected Config $config)
protected Config $config;
protected Cache $cache;
public function __construct(Config $config)
{
$this->config = $config;
$this->cache = new Cache($config);
}

View File

@ -25,7 +25,7 @@ use const PHP_VERSION_ID;
/**
* @internal
*/
final class FileStorageCacheProvider
class FileStorageCacheProvider
{
private string $modified_timestamps = '';

View File

@ -38,7 +38,7 @@ use const SCANDIR_SORT_NONE;
/**
* @internal
*/
final class ParserCacheProvider
class ParserCacheProvider
{
private const FILE_HASHES = 'file_hashes_json';
private const PARSER_CACHE_DIRECTORY = 'php-parser';

View File

@ -22,7 +22,7 @@ use const PHP_VERSION_ID;
*
* @internal
*/
final class ProjectCacheProvider
class ProjectCacheProvider
{
private const GOOD_RUN_NAME = 'good_run';
private const COMPOSER_LOCK_HASH = 'composer_lock_hash';