diff --git a/src/Psalm/Aliases.php b/src/Psalm/Aliases.php index 2dedcf01c1f..ea49c47f530 100644 --- a/src/Psalm/Aliases.php +++ b/src/Psalm/Aliases.php @@ -22,7 +22,14 @@ final class Aliases * @internal * @psalm-mutation-free */ - public function __construct(public ?string $namespace = null, public array $uses = [], public array $functions = [], public array $constants = [], public array $uses_flipped = [], public array $functions_flipped = [], public array $constants_flipped = []) - { + public function __construct( + public ?string $namespace = null, + public array $uses = [], + public array $functions = [], + public array $constants = [], + public array $uses_flipped = [], + public array $functions_flipped = [], + public array $constants_flipped = [], + ) { } } diff --git a/src/Psalm/Config/Creator.php b/src/Psalm/Config/Creator.php index e0b2fd532bb..2f88ade1042 100644 --- a/src/Psalm/Config/Creator.php +++ b/src/Psalm/Config/Creator.php @@ -289,7 +289,11 @@ private static function guessPhpFileDirs(string $current_dir): array $nodes = []; /** @var string[] */ - $php_files = [...glob($current_dir . DIRECTORY_SEPARATOR . '*.php', GLOB_NOSORT) ?: [], ...glob($current_dir . DIRECTORY_SEPARATOR . '**/*.php', GLOB_NOSORT) ?: [], ...glob($current_dir . DIRECTORY_SEPARATOR . '**/**/*.php', GLOB_NOSORT) ?: []]; + $php_files = [ + ...glob($current_dir . DIRECTORY_SEPARATOR . '*.php', GLOB_NOSORT) ?: [], + ...glob($current_dir . DIRECTORY_SEPARATOR . '**/*.php', GLOB_NOSORT) ?: [], + ...glob($current_dir . DIRECTORY_SEPARATOR . '**/**/*.php', GLOB_NOSORT) ?: [], + ]; foreach ($php_files as $php_file) { $php_file = str_replace($current_dir . DIRECTORY_SEPARATOR, '', $php_file); diff --git a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php index 707e3af12e1..83adbb7da94 100644 --- a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php @@ -200,7 +200,7 @@ public static function checkFullyQualifiedClassLikeName( ?string $calling_method_id, array $suppressed_issues, ?ClassLikeNameOptions $options = null, - bool $check_classes = true + bool $check_classes = true, ): ?bool { if ($options === null) { $options = new ClassLikeNameOptions(); diff --git a/src/Psalm/Internal/Analyzer/ClassLikeNameOptions.php b/src/Psalm/Internal/Analyzer/ClassLikeNameOptions.php index 4c91c6b920b..64e9db31885 100644 --- a/src/Psalm/Internal/Analyzer/ClassLikeNameOptions.php +++ b/src/Psalm/Internal/Analyzer/ClassLikeNameOptions.php @@ -9,7 +9,13 @@ */ final class ClassLikeNameOptions { - public function __construct(public bool $inferred = false, public bool $allow_trait = false, public bool $allow_interface = true, public bool $allow_enum = true, public bool $from_docblock = false, public bool $from_attribute = false) - { + public function __construct( + public bool $inferred = false, + public bool $allow_trait = false, + public bool $allow_interface = true, + public bool $allow_enum = true, + public bool $from_docblock = false, + public bool $from_attribute = false, + ) { } } diff --git a/src/Psalm/Internal/Analyzer/DataFlowNodeData.php b/src/Psalm/Internal/Analyzer/DataFlowNodeData.php index da99e343596..4e13c5b0a7f 100644 --- a/src/Psalm/Internal/Analyzer/DataFlowNodeData.php +++ b/src/Psalm/Internal/Analyzer/DataFlowNodeData.php @@ -14,7 +14,18 @@ final class DataFlowNodeData { use ImmutableNonCloneableTrait; - public function __construct(public string $label, public int $line_from, public int $line_to, public string $file_name, public string $file_path, public string $snippet, public int $from, public int $to, public int $snippet_from, public int $column_from, public int $column_to) - { + public function __construct( + public string $label, + public int $line_from, + public int $line_to, + public string $file_name, + public string $file_path, + public string $snippet, + public int $from, + public int $to, + public int $snippet_from, + public int $column_from, + public int $column_to, + ) { } } diff --git a/src/Psalm/Internal/Analyzer/FileAnalyzer.php b/src/Psalm/Internal/Analyzer/FileAnalyzer.php index f18593633ae..bbbe7c41c1e 100644 --- a/src/Psalm/Internal/Analyzer/FileAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FileAnalyzer.php @@ -99,8 +99,11 @@ class FileAnalyzer extends SourceAnalyzer private ?Union $return_type = null; - public function __construct(public ProjectAnalyzer $project_analyzer, protected string $file_path, protected string $file_name) - { + public function __construct( + public ProjectAnalyzer $project_analyzer, + protected string $file_path, + protected string $file_name, + ) { $this->source = $this; $this->codebase = $project_analyzer->getCodebase(); } diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index 0573629c6cb..217d7c5ebe0 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -134,8 +134,11 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer /** * @param TFunction $function */ - public function __construct(protected Closure|Function_|ClassMethod|ArrowFunction $function, SourceAnalyzer $source, protected FunctionLikeStorage $storage) - { + public function __construct( + protected Closure|Function_|ClassMethod|ArrowFunction $function, + SourceAnalyzer $source, + protected FunctionLikeStorage $storage, + ) { $this->source = $source; $this->suppressed_issues = $source->getSuppressedIssues(); $this->codebase = $source->getCodebase(); diff --git a/src/Psalm/Internal/Analyzer/IssueData.php b/src/Psalm/Internal/Analyzer/IssueData.php index c8674fd8fa4..e948337ce45 100644 --- a/src/Psalm/Internal/Analyzer/IssueData.php +++ b/src/Psalm/Internal/Analyzer/IssueData.php @@ -16,10 +16,7 @@ final class IssueData public const SEVERITY_INFO = 'info'; public const SEVERITY_ERROR = 'error'; - /** - * @readonly - */ - public string $link; + public readonly string $link; /** * @param self::SEVERITY_* $severity @@ -30,53 +27,23 @@ public function __construct( public string $severity, public int $line_from, public int $line_to, - /** - * @readonly - */ - public string $type, - /** - * @readonly - */ - public string $message, - /** - * @readonly - */ - public string $file_name, - /** - * @readonly - */ - public string $file_path, - /** - * @readonly - */ - public string $snippet, - /** - * @readonly - */ - public string $selected_text, + public readonly string $type, + public readonly string $message, + public readonly string $file_name, + public readonly string $file_path, + public readonly string $snippet, + public readonly string $selected_text, public int $from, public int $to, public int $snippet_from, public int $snippet_to, - /** - * @readonly - */ - public int $column_from, - /** - * @readonly - */ - public int $column_to, - /** - * @readonly - */ - public int $shortcode = 0, + public readonly int $column_from, + public readonly int $column_to, + public readonly int $shortcode = 0, public int $error_level = -1, public ?array $taint_trace = null, public ?array $other_references = null, - /** - * @readonly - */ - public ?string $dupe_key = null, + public readonly ?string $dupe_key = null, ) { $this->link = $shortcode ? 'https://psalm.dev/' . str_pad((string) $shortcode, 3, "0", STR_PAD_LEFT) : ''; } diff --git a/src/Psalm/Internal/Diff/ClassStatementsDiffer.php b/src/Psalm/Internal/Diff/ClassStatementsDiffer.php index 91e65091e47..95f702e9834 100644 --- a/src/Psalm/Internal/Diff/ClassStatementsDiffer.php +++ b/src/Psalm/Internal/Diff/ClassStatementsDiffer.php @@ -8,9 +8,7 @@ use UnexpectedValueException; use function count; -use function get_class; use function is_string; -use function strpos; use function str_contains; use function strtolower; use function substr; diff --git a/src/Psalm/Internal/LanguageServer/LanguageClient.php b/src/Psalm/Internal/LanguageServer/LanguageClient.php index 19131ca5c2e..12cdfc86c8b 100644 --- a/src/Psalm/Internal/LanguageServer/LanguageClient.php +++ b/src/Psalm/Internal/LanguageServer/LanguageClient.php @@ -4,7 +4,6 @@ namespace Psalm\Internal\LanguageServer; -use JsonMapper; use LanguageServerProtocol\LogMessage; use LanguageServerProtocol\LogTrace; use Psalm\Internal\LanguageServer\Client\Progress\LegacyProgress; diff --git a/src/Psalm/Issue/CodeIssue.php b/src/Psalm/Issue/CodeIssue.php index a5127b3cfef..5a321fd1d9e 100644 --- a/src/Psalm/Issue/CodeIssue.php +++ b/src/Psalm/Issue/CodeIssue.php @@ -20,14 +20,8 @@ abstract class CodeIssue public ?string $dupe_key = null; public function __construct( - /** - * @readonly - */ - public string $message, - /** - * @readonly - */ - public CodeLocation $code_location, + public readonly string $message, + public readonly CodeLocation $code_location, ) { } diff --git a/src/Psalm/Issue/TaintedInput.php b/src/Psalm/Issue/TaintedInput.php index b09361eab05..61d54370ad5 100644 --- a/src/Psalm/Issue/TaintedInput.php +++ b/src/Psalm/Issue/TaintedInput.php @@ -19,14 +19,8 @@ abstract class TaintedInput extends CodeIssue public function __construct( string $message, CodeLocation $code_location, - /** - * @readonly - */ - public array $journey, - /** - * @readonly - */ - public string $journey_text, + public readonly array $journey, + public readonly string $journey_text, ) { parent::__construct($message, $code_location); } diff --git a/src/Psalm/Storage/Assertion/NotInArray.php b/src/Psalm/Storage/Assertion/NotInArray.php index af24e98de59..17c385f8825 100644 --- a/src/Psalm/Storage/Assertion/NotInArray.php +++ b/src/Psalm/Storage/Assertion/NotInArray.php @@ -13,10 +13,7 @@ final class NotInArray extends Assertion { public function __construct( - /** - * @readonly - */ - public Union $type, + public readonly Union $type, ) { } diff --git a/tests/EnumTest.php b/tests/EnumTest.php index 6f128dc2d32..35df957b6b3 100644 --- a/tests/EnumTest.php +++ b/tests/EnumTest.php @@ -632,7 +632,7 @@ function noop(string $s): string $foo = FooEnum::Foo->value; noop($foo); noop(FooEnum::Foo->value); - PHP + PHP, ], 'backedEnumCaseValueFromClassConstant' => [ 'code' => <<<'PHP'