diff --git a/src/Psalm/CodeLocation.php b/src/Psalm/CodeLocation.php index b40b2aa52..8453ce2a5 100644 --- a/src/Psalm/CodeLocation.php +++ b/src/Psalm/CodeLocation.php @@ -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; } /** diff --git a/src/Psalm/Exception/DocblockParseException.php b/src/Psalm/Exception/DocblockParseException.php index 306c7eeb8..433f6632d 100644 --- a/src/Psalm/Exception/DocblockParseException.php +++ b/src/Psalm/Exception/DocblockParseException.php @@ -6,6 +6,6 @@ namespace Psalm\Exception; use Exception; -final class DocblockParseException extends Exception +class DocblockParseException extends Exception { } diff --git a/src/Psalm/Internal/Diff/AstDiffer.php b/src/Psalm/Internal/Diff/AstDiffer.php index 3c8897115..1e436c0db 100644 --- a/src/Psalm/Internal/Diff/AstDiffer.php +++ b/src/Psalm/Internal/Diff/AstDiffer.php @@ -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 $b * @return array{0:non-empty-list>, 1: int, 2: int, 3: array} */ - private static function calculateTrace( + protected static function calculateTrace( Closure $is_equal, array $a, array $b, @@ -81,7 +81,7 @@ final class AstDiffer * @return list * @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) { diff --git a/src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php b/src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php index 2dfc57363..c35c5e382 100644 --- a/src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php +++ b/src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php @@ -26,7 +26,7 @@ use const PHP_VERSION_ID; /** * @internal */ -final class ClassLikeStorageCacheProvider +class ClassLikeStorageCacheProvider { private readonly Cache $cache; diff --git a/src/Psalm/Internal/Provider/FileReferenceCacheProvider.php b/src/Psalm/Internal/Provider/FileReferenceCacheProvider.php index 6a69e2018..e91df5dde 100644 --- a/src/Psalm/Internal/Provider/FileReferenceCacheProvider.php +++ b/src/Psalm/Internal/Provider/FileReferenceCacheProvider.php @@ -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); } diff --git a/src/Psalm/Internal/Provider/FileStorageCacheProvider.php b/src/Psalm/Internal/Provider/FileStorageCacheProvider.php index 411d79ec9..e86503a91 100644 --- a/src/Psalm/Internal/Provider/FileStorageCacheProvider.php +++ b/src/Psalm/Internal/Provider/FileStorageCacheProvider.php @@ -25,7 +25,7 @@ use const PHP_VERSION_ID; /** * @internal */ -final class FileStorageCacheProvider +class FileStorageCacheProvider { private string $modified_timestamps = ''; diff --git a/src/Psalm/Internal/Provider/ParserCacheProvider.php b/src/Psalm/Internal/Provider/ParserCacheProvider.php index d06376db8..9e809f495 100644 --- a/src/Psalm/Internal/Provider/ParserCacheProvider.php +++ b/src/Psalm/Internal/Provider/ParserCacheProvider.php @@ -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'; diff --git a/src/Psalm/Internal/Provider/ProjectCacheProvider.php b/src/Psalm/Internal/Provider/ProjectCacheProvider.php index 91bf751fc..70167aaf5 100644 --- a/src/Psalm/Internal/Provider/ProjectCacheProvider.php +++ b/src/Psalm/Internal/Provider/ProjectCacheProvider.php @@ -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';