diff --git a/composer.json b/composer.json
index f08bde5165c..30fefaeda0a 100644
--- a/composer.json
+++ b/composer.json
@@ -106,8 +106,8 @@
"psalter"
],
"scripts": {
- "cs": "phpcs -p",
- "cs-fix": "phpcbf -p",
+ "cs": "phpcs -ps",
+ "cs-fix": "phpcbf -ps",
"lint": "parallel-lint ./src ./tests",
"phpunit": "paratest --runner=WrapperRunner",
"phpunit-std": "phpunit",
diff --git a/phpcs.xml b/phpcs.xml
index fa2200f0d43..b539ffc6481 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -133,16 +133,16 @@
-
-
-
+
+
+
-
-
+
+
-
+
@@ -182,13 +182,6 @@
https://github.com/slevomat/coding-standard#slevomatcodingstandardtypehintsreturntypehint-
-->
-
-
-
-
-
-
-
@@ -235,7 +228,7 @@
-->
-
@@ -246,7 +239,7 @@
-
@@ -258,4 +251,17 @@
+
+
+
+
+
+
+
+
+
+ src/Psalm/Storage/Assertion/HasArrayKey\.php
+ src/Psalm/Storage/Assertion/IsNotCountable\.php
+ src/Psalm/Storage/Assertion/NonEmptyCountable\.php
+
diff --git a/src/Psalm/Aliases.php b/src/Psalm/Aliases.php
index e112f956b88..526021c8a57 100644
--- a/src/Psalm/Aliases.php
+++ b/src/Psalm/Aliases.php
@@ -54,7 +54,6 @@ final class Aliases
* @param array $functions_flipped
* @param array $constants_flipped
* @internal
- *
* @psalm-mutation-free
*/
public function __construct(
diff --git a/src/Psalm/Codebase.php b/src/Psalm/Codebase.php
index 3e9234fed7f..9af83cd0fa6 100644
--- a/src/Psalm/Codebase.php
+++ b/src/Psalm/Codebase.php
@@ -389,7 +389,6 @@ private function loadAnalyzer(): void
/**
* @param array $candidate_files
- *
*/
public function reloadFiles(ProjectAnalyzer $project_analyzer, array $candidate_files): void
{
@@ -465,7 +464,6 @@ public function collectLocations(): void
/**
* @param 'always'|'auto' $find_unused_code
- *
*/
public function reportUnusedCode(string $find_unused_code = 'auto'): void
{
@@ -483,7 +481,6 @@ public function reportUnusedVariables(): void
/**
* @param array $files_to_analyze
- *
*/
public function addFilesToAnalyze(array $files_to_analyze): void
{
@@ -493,7 +490,6 @@ public function addFilesToAnalyze(array $files_to_analyze): void
/**
* Scans all files their related files
- *
*/
public function scanFiles(int $threads = 1): void
{
@@ -606,7 +602,6 @@ public function findReferencesToProperty(string $property_id): array
/**
* @return CodeLocation[]
- *
* @psalm-return array
*/
public function findReferencesToClassLike(string $fq_class_name): array
@@ -786,7 +781,6 @@ public function traitHasCorrectCasing(string $fq_trait_name): bool
* a method, closure, or function.
*
* @param non-empty-string $function_id
- *
* @return FunctionStorage|MethodStorage
*/
public function getFunctionLikeStorage(
@@ -838,7 +832,6 @@ public function methodExists(
/**
* @param string|MethodIdentifier $method_id
- *
* @return array
*/
public function getMethodParams($method_id): array
@@ -848,7 +841,6 @@ public function getMethodParams($method_id): array
/**
* @param string|MethodIdentifier $method_id
- *
*/
public function isVariadic($method_id): bool
{
@@ -858,7 +850,6 @@ public function isVariadic($method_id): bool
/**
* @param string|MethodIdentifier $method_id
* @param list $call_args
- *
*/
public function getMethodReturnType($method_id, ?string &$self_class, array $call_args = []): ?Union
{
@@ -872,7 +863,6 @@ public function getMethodReturnType($method_id, ?string &$self_class, array $cal
/**
* @param string|MethodIdentifier $method_id
- *
*/
public function getMethodReturnsByRef($method_id): bool
{
@@ -881,8 +871,6 @@ public function getMethodReturnsByRef($method_id): bool
/**
* @param string|MethodIdentifier $method_id
- * @param CodeLocation|null $defined_location
- *
*/
public function getMethodReturnTypeLocation(
$method_id,
@@ -896,7 +884,6 @@ public function getMethodReturnTypeLocation(
/**
* @param string|MethodIdentifier $method_id
- *
*/
public function getDeclaringMethodId($method_id): ?string
{
@@ -909,7 +896,6 @@ public function getDeclaringMethodId($method_id): ?string
* Get the class this method appears in (vs is declared in, which could give a trait)
*
* @param string|MethodIdentifier $method_id
- *
*/
public function getAppearingMethodId($method_id): ?string
{
@@ -920,7 +906,6 @@ public function getAppearingMethodId($method_id): ?string
/**
* @param string|MethodIdentifier $method_id
- *
* @return array
*/
public function getOverriddenMethodIds($method_id): array
@@ -930,7 +915,6 @@ public function getOverriddenMethodIds($method_id): array
/**
* @param string|MethodIdentifier $method_id
- *
*/
public function getCasedMethodId($method_id): string
{
@@ -986,8 +970,6 @@ public function getFunctionStorageForSymbol(string $file_path, string $symbol):
}
/**
- * @param string $file_path
- * @param string $symbol
* @return array{ type: string, description?: string|null}|null
*/
public function getSymbolInformation(string $file_path, string $symbol): ?array
@@ -1941,7 +1923,6 @@ public function queueClassLikeForScanning(
/**
* @param array $taints
- *
* @psalm-suppress PossiblyUnusedMethod
*/
public function addTaintSource(
@@ -1969,7 +1950,6 @@ public function addTaintSource(
/**
* @param array $taints
- *
* @psalm-suppress PossiblyUnusedMethod
*/
public function addTaintSink(
diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php
index 0c633616c8d..0a4caf9256b 100644
--- a/src/Psalm/Config.php
+++ b/src/Psalm/Config.php
@@ -169,6 +169,7 @@ class Config
/**
* These are special object classes that allow any and all properties to be get/set on them
+ *
* @var array
*/
protected $universal_object_crates;
@@ -205,7 +206,6 @@ class Config
* The directory to store PHP Parser (and other) caches
*
* @internal
- *
* @var string|null
*/
public $cache_directory;
@@ -647,7 +647,6 @@ protected function __construct()
* Searches up a folder hierarchy for the most immediate config.
*
* @throws ConfigException if a config path is not found
- *
*/
public static function getConfigForPath(string $path, string $current_dir): Config
{
@@ -664,7 +663,6 @@ public static function getConfigForPath(string $path, string $current_dir): Conf
* Searches up a folder hierarchy for the most immediate config.
*
* @throws ConfigException
- *
*/
public static function locateConfigFile(string $path): ?string
{
@@ -730,9 +728,9 @@ public function computeHash(): string
/**
* Creates a new config object from an XML string
+ *
* @param string|null $current_dir Current working directory, if different to $base_dir
* @param non-empty-string $file_contents
- *
* @throws ConfigException
*/
public static function loadFromXML(
@@ -771,7 +769,6 @@ private static function loadDomDocument(string $base_dir, string $file_contents)
/**
* @param non-empty-string $file_contents
- *
* @throws ConfigException
*/
private static function validateXmlConfig(string $base_dir, string $file_contents): void
@@ -941,12 +938,10 @@ private static function processConfigDeprecations(
/**
* @param non-empty-string $file_contents
- *
* @psalm-suppress MixedMethodCall
* @psalm-suppress MixedAssignment
* @psalm-suppress MixedArgument
* @psalm-suppress MixedPropertyFetch
- *
* @throws ConfigException
*/
private static function fromXmlAndPaths(
@@ -1361,7 +1356,6 @@ public function setCustomErrorLevel(string $issue_key, string $error_level): voi
/**
* @throws ConfigException if a Config file could not be found
- *
*/
private function loadFileExtensions(SimpleXMLElement $extensions): void
{
@@ -1559,9 +1553,7 @@ private static function requirePath(string $path): void
/**
* @template T
- *
* @param T::class $must_extend
- *
* @return class-string
*/
private function getPluginClassForPath(Codebase $codebase, string $path, string $must_extend): string
diff --git a/src/Psalm/Context.php b/src/Psalm/Context.php
index fc9d283c864..334c405f7b2 100644
--- a/src/Psalm/Context.php
+++ b/src/Psalm/Context.php
@@ -439,7 +439,6 @@ public function __destruct()
* @param bool $has_leaving_statements whether or not the parent scope is abandoned between
* $start_context and $end_context
* @param array $updated_vars
- *
*/
public function update(
Context $start_context,
@@ -513,7 +512,6 @@ public function updateReferencesPossiblyFromConfusingScope(
/**
* @param array $new_vars_in_scope
- *
* @return array
*/
public function getRedefinedVars(array $new_vars_in_scope, bool $include_new_vars = false): array
@@ -636,9 +634,7 @@ public function decrementReferenceCount(string $ref_id): void
/**
* @param Clause[] $clauses
* @param array $changed_var_ids
- *
* @return array{list, list}
- *
* @psalm-pure
*/
public static function removeReconciledClauses(array $clauses, array $changed_var_ids): array
@@ -667,7 +663,6 @@ public static function removeReconciledClauses(array $clauses, array $changed_va
/**
* @param Clause[] $clauses
- *
* @return list
*/
public static function filterClauses(
diff --git a/src/Psalm/ErrorBaseline.php b/src/Psalm/ErrorBaseline.php
index 84a804cdfe4..e93b7f14220 100644
--- a/src/Psalm/ErrorBaseline.php
+++ b/src/Psalm/ErrorBaseline.php
@@ -34,8 +34,6 @@ final class ErrorBaseline
{
/**
* @param array}>> $existingIssues
- *
- *
* @psalm-pure
*/
public static function countTotalIssues(array $existingIssues): int
@@ -58,7 +56,6 @@ public static function countTotalIssues(array $existingIssues): int
/**
* @param array> $issues
- *
*/
public static function create(
FileProvider $fileProvider,
@@ -73,7 +70,6 @@ public static function create(
/**
* @return array}>>
- *
* @throws ConfigException
*/
public static function read(FileProvider $fileProvider, string $baselineFile): array
@@ -133,9 +129,7 @@ public static function read(FileProvider $fileProvider, string $baselineFile): a
/**
* @param array> $issues
- *
* @return array}>>
- *
* @throws ConfigException
*/
public static function update(
@@ -181,7 +175,6 @@ public static function update(
/**
* @param array> $issues
- *
* @return array}>>
*/
private static function countIssueTypesByFile(array $issues): array
@@ -193,7 +186,6 @@ private static function countIssueTypesByFile(array $issues): array
array_merge(...array_values($issues)),
/**
* @param array}>> $carry
- *
* @return array}>>
*/
static function (array $carry, IssueData $issue): array {
@@ -237,7 +229,6 @@ static function (array $carry, IssueData $issue): array {
/**
* @param array}>> $groupedIssues
- *
*/
private static function writeToFile(
FileProvider $fileProvider,
diff --git a/src/Psalm/Internal/Algebra.php b/src/Psalm/Internal/Algebra.php
index 1aa6da4861c..be967892a0a 100644
--- a/src/Psalm/Internal/Algebra.php
+++ b/src/Psalm/Internal/Algebra.php
@@ -26,9 +26,7 @@ class Algebra
{
/**
* @param array>> $all_types
- *
* @return array>>
- *
* @psalm-pure
*/
public static function negateTypes(array $all_types): array
@@ -74,9 +72,7 @@ public static function negateTypes(array $all_types): array
* (!$a) && (!$b) && ($a || $b || $c) => $c
*
* @param list $clauses
- *
* @return list
- *
* @psalm-pure
*/
public static function simplifyCNF(array $clauses): array
@@ -330,7 +326,6 @@ public static function simplifyCNF(array $clauses): array
* @param list $clauses
* @param array $cond_referenced_var_ids
* @param array>> $active_truths
- *
* @return array>>
*/
public static function getTruthsFromFormula(
@@ -403,9 +398,7 @@ public static function getTruthsFromFormula(
/**
* @param non-empty-list $clauses
- *
* @return list
- *
* @psalm-pure
*/
public static function groupImpossibilities(array $clauses): array
@@ -522,9 +515,7 @@ public static function groupImpossibilities(array $clauses): array
/**
* @param list $left_clauses
* @param list $right_clauses
- *
* @return list
- *
* @psalm-pure
*/
public static function combineOredClauses(
@@ -645,7 +636,6 @@ public static function combineOredClauses(
* (!$a || !$c || !$f)
*
* @param list $clauses
- *
* @return non-empty-list
*/
public static function negateFormula(array $clauses): array
diff --git a/src/Psalm/Internal/Analyzer/AttributesAnalyzer.php b/src/Psalm/Internal/Analyzer/AttributesAnalyzer.php
index 6a8177efbe3..f1aede90ee8 100644
--- a/src/Psalm/Internal/Analyzer/AttributesAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/AttributesAnalyzer.php
@@ -297,7 +297,6 @@ private static function getAttributeClassFlags(
/**
* @param iterable $attribute_groups
- *
* @return Generator
*/
private static function iterateAttributeNodes(iterable $attribute_groups): Generator
diff --git a/src/Psalm/Internal/Analyzer/CanAlias.php b/src/Psalm/Internal/Analyzer/CanAlias.php
index d97e0db4cc9..a91ee0e2293 100644
--- a/src/Psalm/Internal/Analyzer/CanAlias.php
+++ b/src/Psalm/Internal/Analyzer/CanAlias.php
@@ -11,37 +11,40 @@
use function implode;
use function strtolower;
+/**
+ * @internal
+ */
trait CanAlias
{
/**
* @var array
*/
- private $aliased_classes = [];
+ private array $aliased_classes = [];
/**
* @var array
*/
- private $aliased_class_locations = [];
+ private array $aliased_class_locations = [];
/**
* @var array
*/
- private $aliased_classes_flipped = [];
+ private array $aliased_classes_flipped = [];
/**
* @var array
*/
- private $aliased_classes_flipped_replaceable = [];
+ private array $aliased_classes_flipped_replaceable = [];
/**
* @var array
*/
- private $aliased_functions = [];
+ private array $aliased_functions = [];
/**
* @var array
*/
- private $aliased_constants = [];
+ private array $aliased_constants = [];
public function visitUse(PhpParser\Node\Stmt\Use_ $stmt): void
{
diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php
index a7a32ad833b..1ea2962b09d 100644
--- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php
@@ -109,7 +109,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer
/**
* @var array
*/
- public $inferred_property_types = [];
+ public array $inferred_property_types = [];
/**
* @param PhpParser\Node\Stmt\Class_|PhpParser\Node\Stmt\Enum_ $class
@@ -517,7 +517,7 @@ public function analyze(
)
);
}
-
+
$const_id = strtolower($this->fq_class_name) . '::' . $const->name;
foreach ($codebase->class_constants_to_rename as $original_const_id => $new_const_name) {
diff --git a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php
index 56eed4212eb..9a86f1496b7 100644
--- a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php
@@ -81,33 +81,23 @@ abstract class ClassLikeAnalyzer extends SourceAnalyzer
'unknown type' => true,
];
- /**
- * @var PhpParser\Node\Stmt\ClassLike
- */
- protected $class;
+ protected PhpParser\Node\Stmt\ClassLike $class;
- /** @var FileAnalyzer */
- public $file_analyzer;
+ public FileAnalyzer $file_analyzer;
- /**
- * @var string
- */
- protected $fq_class_name;
+ protected string $fq_class_name;
/**
* The parent class
- *
- * @var string|null
*/
- protected $parent_fq_class_name;
+ protected ?string $parent_fq_class_name = null;
/**
* @var PhpParser\Node\Stmt[]
*/
- protected $leftover_stmts = [];
+ protected array $leftover_stmts = [];
- /** @var ClassLikeStorage */
- protected $storage;
+ protected ClassLikeStorage $storage;
public function __construct(PhpParser\Node\Stmt\ClassLike $class, SourceAnalyzer $source, string $fq_class_name)
{
@@ -404,8 +394,6 @@ public static function checkFullyQualifiedClassLikeName(
/**
* Gets the fully-qualified class name from a Name object
- *
- *
*/
public static function getFQCLNFromNameObject(
PhpParser\Node\Name $class_name,
@@ -495,7 +483,6 @@ public function isStatic(): bool
* Gets the Psalm type from a particular value
*
* @param mixed $value
- *
*/
public static function getTypeFromValue($value): Union
{
diff --git a/src/Psalm/Internal/Analyzer/ClassLikeNameOptions.php b/src/Psalm/Internal/Analyzer/ClassLikeNameOptions.php
index 5e5a2cd1af7..60f61a9e87d 100644
--- a/src/Psalm/Internal/Analyzer/ClassLikeNameOptions.php
+++ b/src/Psalm/Internal/Analyzer/ClassLikeNameOptions.php
@@ -7,23 +7,17 @@
*/
class ClassLikeNameOptions
{
- /** @var bool */
- public $inferred;
+ public bool $inferred;
- /** @var bool */
- public $allow_trait;
+ public bool $allow_trait;
- /** @var bool */
- public $allow_interface;
+ public bool $allow_interface;
- /** @var bool */
- public $allow_enum;
+ public bool $allow_enum;
- /** @var bool */
- public $from_docblock;
+ public bool $from_docblock;
- /** @var bool */
- public $from_attribute;
+ public bool $from_attribute;
public function __construct(
bool $inferred = false,
diff --git a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php
index 925af7f35d6..02a5e91b3b9 100644
--- a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php
@@ -39,9 +39,7 @@ class CommentAnalyzer
/**
* @param array>|null $template_type_map
* @param array $type_aliases
- *
* @throws DocblockParseException if there was a problem parsing the docblock
- *
* @return list
*/
public static function getTypeFromComment(
@@ -66,9 +64,7 @@ public static function getTypeFromComment(
/**
* @param array>|null $template_type_map
* @param array $type_aliases
- *
* @return list
- *
* @throws DocblockParseException if there was a problem parsing the docblock
*/
public static function arrayToDocblocks(
@@ -260,9 +256,7 @@ public static function sanitizeDocblockType(string $docblock_type): string
/**
* @throws DocblockParseException if an invalid string is found
- *
* @return non-empty-list
- *
* @psalm-pure
*/
public static function splitDocLine(string $return_block): array
diff --git a/src/Psalm/Internal/Analyzer/DataFlowNodeData.php b/src/Psalm/Internal/Analyzer/DataFlowNodeData.php
index 46c97f99957..bc4f2dbf533 100644
--- a/src/Psalm/Internal/Analyzer/DataFlowNodeData.php
+++ b/src/Psalm/Internal/Analyzer/DataFlowNodeData.php
@@ -6,67 +6,33 @@
/**
* @psalm-immutable
- *
* @internal
*/
class DataFlowNodeData
{
use ImmutableNonCloneableTrait;
- /**
- * @var int
- */
- public $line_from;
+ public int $line_from;
- /**
- * @var int
- */
- public $line_to;
+ public int $line_to;
- /**
- * @var string
- */
- public $label;
+ public string $label;
- /**
- * @var string
- */
- public $file_name;
+ public string $file_name;
- /**
- * @var string
- */
- public $file_path;
+ public string $file_path;
- /**
- * @var string
- */
- public $snippet;
+ public string $snippet;
- /**
- * @var int
- */
- public $from;
+ public int $from;
- /**
- * @var int
- */
- public $to;
+ public int $to;
- /**
- * @var int
- */
- public $snippet_from;
+ public int $snippet_from;
- /**
- * @var int
- */
- public $column_from;
+ public int $column_from;
- /**
- * @var int
- */
- public $column_to;
+ public int $column_to;
public function __construct(
string $label,
diff --git a/src/Psalm/Internal/Analyzer/FileAnalyzer.php b/src/Psalm/Internal/Analyzer/FileAnalyzer.php
index fc8b48aa70f..7fb1fb01eda 100644
--- a/src/Psalm/Internal/Analyzer/FileAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/FileAnalyzer.php
@@ -44,25 +44,13 @@ class FileAnalyzer extends SourceAnalyzer
{
use CanAlias;
- /**
- * @var string
- */
- protected $file_name;
+ protected string $file_name;
- /**
- * @var string
- */
- protected $file_path;
+ protected string $file_path;
- /**
- * @var string|null
- */
- protected $root_file_path;
+ protected ?string $root_file_path = null;
- /**
- * @var string|null
- */
- protected $root_file_name;
+ protected ?string $root_file_name = null;
/**
* @var array
@@ -97,27 +85,18 @@ class FileAnalyzer extends SourceAnalyzer
/**
* @var array
*/
- public $interface_analyzers_to_analyze = [];
+ public array $interface_analyzers_to_analyze = [];
/**
* @var array
*/
- public $class_analyzers_to_analyze = [];
+ public array $class_analyzers_to_analyze = [];
- /**
- * @var null|Context
- */
- public $context;
+ public ?Context $context = null;
- /**
- * @var ProjectAnalyzer
- */
- public $project_analyzer;
+ public ProjectAnalyzer $project_analyzer;
- /**
- * @var Codebase
- */
- public $codebase;
+ public Codebase $codebase;
private int $first_statement_offset = -1;
@@ -292,7 +271,6 @@ public function analyze(
/**
* @param array $stmts
- *
* @return list
*/
public function populateCheckers(array $stmts): array
diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php
index ffed9e60d94..8444abff344 100644
--- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php
@@ -67,9 +67,7 @@ class ReturnTypeAnalyzer
* @param Closure|Function_|ClassMethod|ArrowFunction $function
* @param PhpParser\Node\Stmt[] $function_stmts
* @param string[] $compatible_method_ids
- *
* @return false|null
- *
* @psalm-suppress PossiblyUnusedReturnValue unused but seems important
* @psalm-suppress ComplexMethod Unavoidably complex method
*/
@@ -781,7 +779,6 @@ public static function verifyReturnType(
/**
* @param Closure|Function_|ClassMethod|ArrowFunction $function
- *
* @return false|null
*/
public static function checkReturnType(
@@ -978,7 +975,6 @@ public static function checkReturnType(
/**
* @param Closure|Function_|ClassMethod|ArrowFunction $function
- *
*/
private static function addOrUpdateReturnType(
FunctionLike $function,
diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php
index d2292f18dd7..d71a547f402 100644
--- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php
+++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php
@@ -31,9 +31,7 @@ class ReturnTypeCollector
*
* @param array $stmts
* @param list $yield_types
- *
* @return list a list of return types
- *
* @psalm-suppress ComplexMethod to be refactored
*/
public static function getReturnTypes(
diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
index 1d445ac7442..71404ec4912 100644
--- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
@@ -90,64 +90,46 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
*/
protected $function;
- /**
- * @var Codebase
- */
- protected $codebase;
+ protected Codebase $codebase;
/**
* @var array
*/
- protected $suppressed_issues;
+ protected array $suppressed_issues;
- /**
- * @var bool
- */
- protected $is_static = false;
+ protected bool $is_static = false;
/**
* @var ?array
*/
- protected $return_vars_in_scope = [];
+ protected ?array $return_vars_in_scope = [];
/**
* @var ?array
*/
- protected $return_vars_possibly_in_scope = [];
+ protected ?array $return_vars_possibly_in_scope = [];
private ?Union $local_return_type = null;
/**
* @var array
*/
- protected static $no_effects_hashes = [];
+ protected static array $no_effects_hashes = [];
- /**
- * @var bool
- */
- public $track_mutations = false;
+ public bool $track_mutations = false;
- /**
- * @var bool
- */
- public $inferred_impure = false;
+ public bool $inferred_impure = false;
- /**
- * @var bool
- */
- public $inferred_has_mutation = false;
+ public bool $inferred_has_mutation = false;
/**
* Holds param nodes for functions with func_get_args calls
*
* @var array
*/
- public $param_nodes = [];
+ public array $param_nodes = [];
- /**
- * @var FunctionLikeStorage
- */
- protected $storage;
+ protected FunctionLikeStorage $storage;
/**
* @param TFunction $function
@@ -163,9 +145,7 @@ public function __construct($function, SourceAnalyzer $source, FunctionLikeStora
/**
* @param bool $add_mutations whether or not to add mutations to this method
- *
* @return false|null
- *
* @psalm-suppress PossiblyUnusedReturnValue unused but seems important
*/
public function analyze(
@@ -1781,7 +1761,6 @@ public function removeSuppressedIssues(array $new_issues): void
/**
* Adds a suppressed issue, useful when creating a method checker from scratch
- *
*/
public function addSuppressedIssue(string $issue_name): void
{
diff --git a/src/Psalm/Internal/Analyzer/IssueData.php b/src/Psalm/Internal/Analyzer/IssueData.php
index 318afe57f6a..6b273c0b1fb 100644
--- a/src/Psalm/Internal/Analyzer/IssueData.php
+++ b/src/Psalm/Internal/Analyzer/IssueData.php
@@ -11,121 +11,86 @@
*/
class IssueData
{
- /**
- * @var string
- */
- public $severity;
+ public string $severity;
- /**
- * @var int
- */
- public $line_from;
+ public int $line_from;
- /**
- * @var int
- */
- public $line_to;
+ public int $line_to;
/**
- * @var string
* @readonly
*/
- public $type;
+ public string $type;
/**
- * @var string
* @readonly
*/
- public $message;
+ public string $message;
/**
- * @var string
* @readonly
*/
- public $file_name;
+ public string $file_name;
/**
- * @var string
* @readonly
*/
- public $file_path;
+ public string $file_path;
/**
- * @var string
* @readonly
*/
- public $snippet;
+ public string $snippet;
/**
- * @var string
* @readonly
*/
- public $selected_text;
+ public string $selected_text;
- /**
- * @var int
- */
- public $from;
+ public int $from;
- /**
- * @var int
- */
- public $to;
+ public int $to;
- /**
- * @var int
- */
- public $snippet_from;
+ public int $snippet_from;
- /**
- * @var int
- */
- public $snippet_to;
+ public int $snippet_to;
/**
- * @var int
* @readonly
*/
- public $column_from;
+ public int $column_from;
/**
- * @var int
* @readonly
*/
- public $column_to;
+ public int $column_to;
- /**
- * @var int
- */
- public $error_level;
+ public int $error_level;
/**
- * @var int
* @readonly
*/
- public $shortcode;
+ public int $shortcode;
/**
- * @var string
* @readonly
*/
- public $link;
+ public string $link;
/**
* @var ?list
*/
- public $taint_trace;
+ public ?array $taint_trace = null;
/**
* @var ?list
*/
- public $other_references;
+ public ?array $other_references = null;
/**
- * @var ?string
* @readonly
*/
- public $dupe_key;
+ public ?string $dupe_key = null;
/**
* @param ?list $taint_trace
diff --git a/src/Psalm/Internal/Analyzer/MethodAnalyzer.php b/src/Psalm/Internal/Analyzer/MethodAnalyzer.php
index e11abef5195..ae725773f81 100644
--- a/src/Psalm/Internal/Analyzer/MethodAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/MethodAnalyzer.php
@@ -88,6 +88,7 @@ public function __construct(
/**
* Determines whether a given method is static or not
+ *
* @param array $suppressed_issues
*/
public static function checkStatic(
@@ -159,7 +160,6 @@ public static function checkStatic(
/**
* @param string[] $suppressed_issues
* @param lowercase-string|null $calling_method_id
- *
*/
public static function checkMethodExists(
Codebase $codebase,
diff --git a/src/Psalm/Internal/Analyzer/MethodComparator.php b/src/Psalm/Internal/Analyzer/MethodComparator.php
index 7522b905ff8..034273858ba 100644
--- a/src/Psalm/Internal/Analyzer/MethodComparator.php
+++ b/src/Psalm/Internal/Analyzer/MethodComparator.php
@@ -48,9 +48,7 @@ class MethodComparator
{
/**
* @param string[] $suppressed_issues
- *
* @return false|null
- *
* @psalm-suppress PossiblyUnusedReturnValue unused but seems important
*/
public static function compare(
diff --git a/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php b/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php
index 6ee0ea96933..e0d412cbfc6 100644
--- a/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php
@@ -31,7 +31,7 @@ class NamespaceAnalyzer extends SourceAnalyzer
* @var FileAnalyzer
* @psalm-suppress NonInvariantDocblockPropertyType
*/
- protected $source;
+ protected SourceAnalyzer $source;
private Namespace_ $namespace;
@@ -42,7 +42,7 @@ class NamespaceAnalyzer extends SourceAnalyzer
*
* @var array>
*/
- protected static $public_namespace_constants = [];
+ protected static array $public_namespace_constants = [];
public function __construct(Namespace_ $namespace, FileAnalyzer $source)
{
@@ -153,7 +153,6 @@ public function getFileAnalyzer(): FileAnalyzer
* case-insensitive comparison. Identifiers can be namespaces, classlikes, functions, or methods.
*
* @psalm-pure
- *
* @throws InvalidArgumentException if $identifier is not a valid identifier
*/
public static function isWithin(string $calling_identifier, string $identifier): bool
@@ -187,9 +186,7 @@ public static function isWithin(string $calling_identifier, string $identifier):
* Identifiers can be namespaces, classlikes, functions, or methods.
*
* @psalm-pure
- *
* @psalm-assert-if-false !empty $identifiers
- *
* @param list $identifiers
*/
public static function isWithinAny(string $calling_identifier, array $identifiers): bool
@@ -208,10 +205,8 @@ public static function isWithinAny(string $calling_identifier, array $identifier
}
/**
- * @param non-empty-string $fullyQualifiedClassName, e.g. '\Psalm\Internal\Analyzer\NamespaceAnalyzer'
- *
+ * @param non-empty-string $fullyQualifiedClassName e.g. '\Psalm\Internal\Analyzer\NamespaceAnalyzer'
* @return non-empty-string , e.g. 'Psalm'
- *
* @psalm-pure
*/
public static function getNameSpaceRoot(string $fullyQualifiedClassName): string
@@ -225,7 +220,6 @@ public static function getNameSpaceRoot(string $fullyQualifiedClassName): string
/**
* @return ($lowercase is true ? lowercase-string : string)
- *
* @psalm-pure
*/
public static function normalizeIdentifier(string $identifier, bool $lowercase = true): string
@@ -242,7 +236,6 @@ public static function normalizeIdentifier(string $identifier, bool $lowercase =
* Splits an identifier into parts, eg `Foo\Bar::baz` becomes ["Foo", "\\", "Bar", "::", "baz"].
*
* @return list
- *
* @psalm-pure
*/
public static function getIdentifierParts(string $identifier): array
diff --git a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php
index 07f4300fcf7..38696dbbb08 100644
--- a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php
@@ -114,10 +114,7 @@ class ProjectAnalyzer
*/
private Config $config;
- /**
- * @var self
- */
- public static $instance;
+ public static ProjectAnalyzer $instance;
/**
* An object representing everything we know about the code
@@ -128,70 +125,41 @@ class ProjectAnalyzer
private ClassLikeStorageProvider $classlike_storage_provider;
- private ?ParserCacheProvider $parser_cache_provider;
+ private ?ParserCacheProvider $parser_cache_provider = null;
- /** @var ?ProjectCacheProvider */
- public $project_cache_provider;
+ public ?ProjectCacheProvider $project_cache_provider = null;
private FileReferenceProvider $file_reference_provider;
- /**
- * @var Progress
- */
- public $progress;
+ public Progress $progress;
- /**
- * @var bool
- */
- public $debug_lines = false;
+ public bool $debug_lines = false;
- /**
- * @var bool
- */
- public $debug_performance = false;
+ public bool $debug_performance = false;
- /**
- * @var bool
- */
- public $show_issues = true;
+ public bool $show_issues = true;
- /** @var int */
- public $threads;
+ public int $threads;
/**
* @var array
*/
private array $issues_to_fix = [];
- /**
- * @var bool
- */
- public $dry_run = false;
+ public bool $dry_run = false;
- /**
- * @var bool
- */
- public $full_run = false;
+ public bool $full_run = false;
- /**
- * @var bool
- */
- public $only_replace_php_types_with_non_docblock_types = false;
+ public bool $only_replace_php_types_with_non_docblock_types = false;
- /**
- * @var ?int
- */
- public $onchange_line_limit;
+ public ?int $onchange_line_limit = null;
- /**
- * @var bool
- */
- public $provide_completion = false;
+ public bool $provide_completion = false;
/**
* @var list
*/
- public $check_paths_files = [];
+ public array $check_paths_files = [];
/**
* @var array
@@ -206,17 +174,14 @@ class ProjectAnalyzer
/**
* @var array
*/
- private $to_refactor = [];
+ private array $to_refactor = [];
- /**
- * @var ?ReportOptions
- */
- public $stdout_report_options;
+ public ?ReportOptions $stdout_report_options = null;
/**
* @var array
*/
- public $generated_report_options;
+ public array $generated_report_options;
/**
* @var array>
@@ -247,17 +212,13 @@ class ProjectAnalyzer
/**
* When this is true, the language server will send the diagnostic code with a help link.
- *
- * @var bool
*/
- public $language_server_use_extended_diagnostic_codes = false;
+ public bool $language_server_use_extended_diagnostic_codes = false;
/**
* If this is true then the language server will send log messages to the client with additional information.
- *
- * @var bool
*/
- public $language_server_verbose = false;
+ public bool $language_server_verbose = false;
/**
* @param array $generated_report_options
@@ -1112,7 +1073,6 @@ protected function getDiffFiles(): array
/**
* @param array $file_list
- *
*/
private function checkDiffFilesWithConfig(Config $config, array $file_list = []): void
{
@@ -1232,7 +1192,6 @@ public function getConfig(): Config
/**
* @param array $diff_files
- *
* @return array
*/
public function getReferencedFilesFromDiff(array $diff_files, bool $include_referencing_files = true): array
@@ -1280,7 +1239,6 @@ public function alterCodeAfterCompletion(
/**
* @param array $to_refactor
- *
*/
public function refactorCodeAfterCompletion(array $to_refactor): void
{
@@ -1318,7 +1276,6 @@ public function setPhpVersion(string $version, string $source): void
/**
* @param array $issues
* @throws UnsupportedIssueToFixException
- *
*/
public function setIssuesToFix(array $issues): void
{
@@ -1450,6 +1407,7 @@ public function getFunctionLikeAnalyzer(
* Adapted from https://gist.github.com/divinity76/01ef9ca99c111565a72d3a8a6e42f7fb
* returns number of cpu cores
* Copyleft 2018, license: WTFPL
+ *
* @throws NumberOfCpuCoreNotFound
*/
public static function getCpuCount(): int
@@ -1478,7 +1436,6 @@ public static function getCpuCount(): int
/**
* @return array
- *
* @psalm-pure
*/
public static function getSupportedIssuesToFix(): array
diff --git a/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php b/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php
index b0b2858c2b8..72af912397a 100644
--- a/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php
@@ -31,9 +31,7 @@ class ScopeAnalyzer
* @param array $stmts
* @param list<'loop'|'switch'> $break_types
* @param bool $return_is_exit Exit and Throw statements are treated differently from return if this is false
- *
* @return list
- *
* @psalm-suppress ComplexMethod nothing much we can do
*/
public static function getControlActions(
@@ -397,7 +395,6 @@ public static function getControlActions(
/**
* @param array $stmts
- *
*/
public static function onlyThrowsOrExits(NodeTypeProvider $type_provider, array $stmts): bool
{
@@ -429,7 +426,6 @@ public static function onlyThrowsOrExits(NodeTypeProvider $type_provider, array
/**
* @param array $stmts
- *
*/
public static function onlyThrows(array $stmts): bool
{
diff --git a/src/Psalm/Internal/Analyzer/SourceAnalyzer.php b/src/Psalm/Internal/Analyzer/SourceAnalyzer.php
index 506ee7b5cde..705176d6818 100644
--- a/src/Psalm/Internal/Analyzer/SourceAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/SourceAnalyzer.php
@@ -13,10 +13,7 @@
*/
abstract class SourceAnalyzer implements StatementsSource
{
- /**
- * @var SourceAnalyzer
- */
- protected $source;
+ protected SourceAnalyzer $source;
public function __destruct()
{
@@ -122,7 +119,8 @@ public function getSource(): StatementsSource
/**
* Get a list of suppressed issues
- *@psalm-mutation-free
+ *
+ * @psalm-mutation-free
* @return array
*/
public function getSuppressedIssues(): array
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php
index 2f934d11951..f2fcb18d28b 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php
@@ -387,7 +387,6 @@ public static function analyze(
/**
* @param PhpParser\Node\Stmt\Foreach_|PhpParser\Node\Expr\YieldFrom $stmt
- *
* @return false|null
*/
public static function checkIteratorType(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php
index d1b0e1f0fa5..2fbc984da60 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php
@@ -50,7 +50,6 @@ class IfAnalyzer
{
/**
* @param array $pre_assignment_else_redefined_vars
- *
* @return false|null
*/
public static function analyze(
@@ -401,6 +400,7 @@ public static function addConditionallyAssignedVarsToContext(
/**
* Returns all expressions inside an ored expression
+ *
* @return non-empty-list
*/
private static function getDefinitelyEvaluatedOredExpressions(PhpParser\Node\Expr $stmt): array
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php
index b89c8dc54a7..3a87d9e8f9f 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php
@@ -64,7 +64,6 @@ class IfElseAnalyzer
* (x: null)
* throw new Exception -- effects: remove null from the type of x
*
- *
* @return null|false
*/
public static function analyze(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php
index c8dce61b121..79ac5bda923 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php
@@ -36,7 +36,6 @@ class LoopAnalyzer
* @param array $stmts
* @param PhpParser\Node\Expr[] $pre_conditions
* @param PhpParser\Node\Expr[] $post_expressions
- *
* @return false|null
*/
public static function analyze(
@@ -568,7 +567,6 @@ private static function updateLoopScopeContexts(
/**
* @param list $pre_condition_clauses
- *
* @return list
*/
private static function applyPreConditionToLoopContext(
@@ -647,7 +645,6 @@ private static function applyPreConditionToLoopContext(
/**
* @param array> $assignment_map
- *
*/
private static function getAssignmentMapDepth(string $first_var_id, array $assignment_map): int
{
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayCreationInfo.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayCreationInfo.php
index cf7447a1057..f122b73f67d 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayCreationInfo.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayCreationInfo.php
@@ -14,47 +14,38 @@ class ArrayCreationInfo
/**
* @var list
*/
- public $item_key_atomic_types = [];
+ public array $item_key_atomic_types = [];
/**
* @var list
*/
- public $item_value_atomic_types = [];
+ public array $item_value_atomic_types = [];
/**
* @var array
*/
- public $property_types = [];
+ public array $property_types = [];
/**
* @var array
*/
- public $class_strings = [];
+ public array $class_strings = [];
- /**
- * @var bool
- */
- public $can_create_objectlike = true;
+ public bool $can_create_objectlike = true;
/**
* @var array
*/
- public $array_keys = [];
+ public array $array_keys = [];
- /**
- * @var int
- */
- public $int_offset = 0;
+ public int $int_offset = 0;
- /**
- * @var bool
- */
- public $all_list = true;
+ public bool $all_list = true;
/**
* @var array
*/
- public $parent_taint_nodes = [];
+ public array $parent_taint_nodes = [];
public bool $can_be_empty = true;
}
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php
index a19fe3b2e2b..a38327a271d 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php
@@ -925,7 +925,6 @@ private static function processIrreconcilableFunctionCall(
/**
* @param PhpParser\Node\Expr\FuncCall|PhpParser\Node\Expr\MethodCall|PhpParser\Node\Expr\StaticCall $expr
- *
* @return list>>>
*/
protected static function processCustomAssertion(
@@ -3476,8 +3475,6 @@ private static function getTypedValueEqualityAssertions(
}
/**
- * @param PhpParser\Node\Expr\FuncCall $expr
- * @param StatementsAnalyzer $source
* @return list>>>
*/
private static function getIsaAssertions(
@@ -3582,9 +3579,6 @@ private static function getIsaAssertions(
}
/**
- * @param PhpParser\Node\Expr\FuncCall $expr
- * @param StatementsAnalyzer $source
- * @param string|null $first_var_name
* @return list>>>
*/
private static function getInarrayAssertions(
@@ -3662,9 +3656,6 @@ private static function getInarrayAssertions(
}
/**
- * @param PhpParser\Node\Expr\FuncCall $expr
- * @param Union|null $first_var_type
- * @param string|null $first_var_name
* @return list>>>
*/
private static function getArrayKeyExistsAssertions(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/AssignedProperty.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/AssignedProperty.php
index c1d06eb6fc8..a49249992b5 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/AssignedProperty.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/AssignedProperty.php
@@ -9,20 +9,11 @@
*/
class AssignedProperty
{
- /**
- * @var Union
- */
- public $property_type;
+ public Union $property_type;
- /**
- * @var string
- */
- public $id;
+ public string $id;
- /**
- * @var Union
- */
- public $assignment_type;
+ public Union $assignment_type;
public function __construct(
Union $property_type,
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php
index d69df245442..8c3afc95672 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php
@@ -92,7 +92,6 @@ class InstancePropertyAssignmentAnalyzer
/**
* @param PropertyFetch|PropertyProperty $stmt
* @param bool $direct_assignment whether the variable is assigned explicitly
- *
* @return false|null
*/
public static function analyze(
@@ -878,7 +877,6 @@ private static function analyzeRegularAssignment(
/**
* @param list $invalid_assignment_types
- *
* @psalm-suppress ComplexMethod Unavoidably complex method
*/
private static function analyzeAtomicAssignment(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php
index 05ea3dae4f9..e5c71802001 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php
@@ -100,7 +100,6 @@ class AssignmentAnalyzer
{
/**
* @param PhpParser\Node\Expr|null $assign_value This has to be null to support list destructuring
- *
* @return false|Union
*/
public static function analyze(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php
index 6d99a6da774..043da46ac4c 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php
@@ -292,7 +292,6 @@ private static function getNumericalType($result): Union
/**
* @param string[] $invalid_left_messages
* @param string[] $invalid_right_messages
- *
* @psalm-suppress ComplexMethod Unavoidably complex method.
*/
private static function analyzeOperands(
@@ -929,7 +928,6 @@ private static function analyzeOperands(
}
/**
- * @param PhpParser\Node $operation
* @param float|int $operand1
* @param float|int $operand2
*/
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php
index fca29300314..6f19a633a50 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php
@@ -53,9 +53,6 @@ class ConcatAnalyzer
{
private const MAX_LITERALS = 64;
- /**
- * @param Union|null $result_type
- */
public static function analyze(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr $left,
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php
index 3d815318b7a..e0d2005802c 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php
@@ -72,7 +72,6 @@ class ArgumentsAnalyzer
/**
* @param list $args
* @param array|null $function_params
- *
* @return false|null
*/
public static function analyze(
@@ -698,9 +697,7 @@ private static function handleClosureArg(
* @param list $args
* @param string|MethodIdentifier|null $method_id
* @param array $function_params
- *
* @return false|null
- *
* @psalm-suppress ComplexMethod there's just not much that can be done about this
*/
public static function checkArgumentsMatch(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php
index 92fa5b49161..3443219f0eb 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php
@@ -134,7 +134,6 @@ public static function checkArgumentsMatch(
/**
* @param list $args
- *
* @return false|null
*/
public static function handleAddition(
@@ -329,7 +328,6 @@ public static function handleAddition(
/**
* @param list $args
- *
* @return false|null
*/
public static function handleSplice(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallInfo.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallInfo.php
index 61984a89d7d..c2e38864d5b 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallInfo.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallInfo.php
@@ -12,60 +12,36 @@
*/
class FunctionCallInfo
{
- /**
- * @var ?string
- */
- public $function_id;
+ public ?string $function_id = null;
- /**
- * @var ?bool
- */
- public $function_exists;
+ public ?bool $function_exists = null;
- /**
- * @var bool
- */
- public $is_stubbed = false;
+ public bool $is_stubbed = false;
- /**
- * @var bool
- */
- public $in_call_map = false;
+ public bool $in_call_map = false;
/**
* @var array
*/
- public $defined_constants = [];
+ public array $defined_constants = [];
/**
* @var array
*/
- public $global_variables = [];
+ public array $global_variables = [];
/**
* @var ?array
*/
- public $function_params;
+ public ?array $function_params = null;
- /**
- * @var ?FunctionLikeStorage
- */
- public $function_storage;
+ public ?FunctionLikeStorage $function_storage = null;
- /**
- * @var ?PhpParser\Node\Name
- */
- public $new_function_name;
+ public ?PhpParser\Node\Name $new_function_name = null;
- /**
- * @var bool
- */
- public $allow_named_args = true;
+ public bool $allow_named_args = true;
- /**
- * @var array
- */
- public $byref_uses = [];
+ public array $byref_uses = [];
/**
* @mutation-free
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicCallContext.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicCallContext.php
index 8477dd558d3..7e033b36f1d 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicCallContext.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicCallContext.php
@@ -10,11 +10,10 @@
*/
class AtomicCallContext
{
- /** @var MethodIdentifier */
- public $method_id;
+ public MethodIdentifier $method_id;
/** @var list */
- public $args;
+ public array $args;
/** @param list $args */
public function __construct(MethodIdentifier $method_id, array $args)
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalysisResult.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalysisResult.php
index ba2e13db734..e83742e070b 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalysisResult.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalysisResult.php
@@ -10,83 +10,56 @@
*/
class AtomicMethodCallAnalysisResult
{
- /**
- * @var ?Union
- */
- public $return_type;
+ public ?Union $return_type = null;
- /**
- * @var bool
- */
- public $returns_by_ref = false;
+ public bool $returns_by_ref = false;
- /**
- * @var bool
- */
- public $has_mock = false;
+ public bool $has_mock = false;
- /**
- * @var bool
- */
- public $has_valid_method_call_type = false;
+ public bool $has_valid_method_call_type = false;
- /**
- * @var bool
- */
- public $has_mixed_method_call = false;
+ public bool $has_mixed_method_call = false;
/**
* @var array
*/
- public $invalid_method_call_types = [];
+ public array $invalid_method_call_types = [];
/**
* @var array
*/
- public $existent_method_ids = [];
+ public array $existent_method_ids = [];
/**
* @var array
*/
- public $non_existent_class_method_ids = [];
+ public array $non_existent_class_method_ids = [];
/**
* @var array
*/
- public $non_existent_interface_method_ids = [];
+ public array $non_existent_interface_method_ids = [];
/**
* @var array
*/
- public $non_existent_magic_method_ids = [];
+ public array $non_existent_magic_method_ids = [];
- /**
- * @var bool
- */
- public $check_visibility = true;
+ public bool $check_visibility = true;
- /**
- * @var bool
- */
- public $too_many_arguments = true;
+ public bool $too_many_arguments = true;
/**
* @var list
*/
- public $too_many_arguments_method_ids = [];
+ public array $too_many_arguments_method_ids = [];
- /**
- * @var bool
- */
- public $too_few_arguments = false;
+ public bool $too_few_arguments = false;
/**
* @var list
*/
- public $too_few_arguments_method_ids = [];
+ public array $too_few_arguments_method_ids = [];
- /**
- * @var bool
- */
- public $can_memoize = false;
+ public bool $can_memoize = false;
}
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php
index 29f510c6359..aa6ac74b96d 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php
@@ -64,7 +64,6 @@ class AtomicMethodCallAnalyzer extends CallAnalyzer
{
/**
* @param TNamedObject|TTemplateParam|null $static_type
- *
* @psalm-suppress ComplexMethod it's really complex, but unavoidably so
*/
public static function analyze(
@@ -512,7 +511,6 @@ public static function analyze(
/**
* @param TNamedObject|TTemplateParam $lhs_type_part
* @param array $intersection_types
- *
* @return array{?Union, array}
*/
private static function getIntersectionReturnType(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallProhibitionAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallProhibitionAnalyzer.php
index fcb44cb9e1d..dd4a19fafbc 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallProhibitionAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallProhibitionAnalyzer.php
@@ -19,7 +19,6 @@ class MethodCallProhibitionAnalyzer
{
/**
* @param string[] $suppressed_issues
- *
* @return false|null
*/
public static function analyze(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodVisibilityAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodVisibilityAnalyzer.php
index ad6c4fcc41a..f96f679fc98 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodVisibilityAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodVisibilityAnalyzer.php
@@ -24,7 +24,6 @@ class MethodVisibilityAnalyzer
{
/**
* @param string[] $suppressed_issues
- *
* @return false|null
*/
public static function analyze(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php
index 1982bcf707b..11a00eeb38c 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php
@@ -410,10 +410,8 @@ private static function createFirstClassCallableReturnType(?MethodStorage $metho
* Returns the pseudo method if exists, with its defining class storage.
* If the method is not declared, null is returned.
*
- * @param Codebase $codebase
* @param ClassLikeStorage $static_class_storage The called class
* @param lowercase-string $method_name_lc
- *
* @return array{MethodStorage, ClassLikeStorage}
*/
private static function findPseudoMethodAndClassStorages(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php
index e6474f9baa6..75dd5bcb815 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php
@@ -1079,10 +1079,8 @@ public static function handleNonObjectCall(
* Returns the pseudo method if exists, with its defining class storage.
* If the method is not declared, null is returned.
*
- * @param Codebase $codebase
* @param ClassLikeStorage $static_class_storage The called class
* @param lowercase-string $method_name_lc
- *
* @return array{MethodStorage, ClassLikeStorage}|null
*/
private static function findPseudoMethodAndClassStorages(
@@ -1114,15 +1112,9 @@ private static function findPseudoMethodAndClassStorages(
* Forward static call to instance call, using `VirtualMethodCall` and `MethodCallAnalyzer::analyze()`
* The resolved method return type will be set as type of the $stmt node.
*
- * @param StatementsAnalyzer $statements_analyzer
- * @param PhpParser\Node\Expr\StaticCall $stmt
- * @param PhpParser\Node\Identifier $stmt_name
- * @param Context $context
* @param string $virtual_var_name Temporary var name to use for create the fake MethodCall statement.
* @param bool $always_set_node_type If true, when the method has no declared typed, mixed will be set on node.
- *
* @return bool Result of analysis. False if the call is invalid.
- *
* @see MethodCallAnalyzer::analyze()
*/
private static function forwardCallToInstanceMethod(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
index 502e46a47f5..659111f8259 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
@@ -493,7 +493,6 @@ public static function getGenericParamForOffset(
/**
* @param PhpParser\Node\Scalar\String_|PhpParser\Node\Expr\Array_|PhpParser\Node\Expr\BinaryOp\Concat $callable_arg
- *
* @return list
*/
public static function getFunctionIdsFromCallableArg(
@@ -597,7 +596,6 @@ public static function getFunctionIdsFromCallableArg(
/**
* @param non-empty-string $function_id
* @param bool $can_be_in_root_scope if true, the function can be shortened to the root version
- *
*/
public static function checkFunctionExists(
StatementsAnalyzer $statements_analyzer,
@@ -640,7 +638,6 @@ public static function checkFunctionExists(
* @param Identifier|Name $expr
* @param Possibilities[] $var_assertions
* @param list $args
- *
*/
public static function applyAssertionsToContext(
PhpParser\NodeAbstract $expr,
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php
index f50ab1d324d..5f32e104d9e 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php
@@ -1090,7 +1090,6 @@ public static function handleMixedArrayAccess(
* @param TArray|TKeyedArray|TClassStringMap $type
* @param-out TArray|TKeyedArray|TClassStringMap $type
* @param list $key_values
- *
* @psalm-suppress ConflictingReferenceConstraint Ignore
*/
private static function handleArrayAccessOnArray(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php
index 79bbe947414..c0bcba608a7 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php
@@ -77,7 +77,6 @@ class AtomicPropertyFetchAnalyzer
{
/**
* @param array $invalid_fetch_types $invalid_fetch_types
- *
* @psalm-suppress ComplexMethod Unavoidably complex method.
*/
public static function analyze(
diff --git a/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php
index 618031bd768..348ee488ceb 100644
--- a/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php
@@ -582,6 +582,7 @@ private static function handleTaints(
/**
* If a function returns a closure, we try to infer the param/return types of
* the inner closure.
+ *
* @see \Psalm\Tests\ReturnTypeTest:756
* @param PhpParser\Node\Expr\Closure|PhpParser\Node\Expr\ArrowFunction $expr
*/
diff --git a/src/Psalm/Internal/Analyzer/Statements/UnusedAssignmentRemover.php b/src/Psalm/Internal/Analyzer/Statements/UnusedAssignmentRemover.php
index 2d5895885f1..8a83cd265a6 100644
--- a/src/Psalm/Internal/Analyzer/Statements/UnusedAssignmentRemover.php
+++ b/src/Psalm/Internal/Analyzer/Statements/UnusedAssignmentRemover.php
@@ -32,7 +32,6 @@ class UnusedAssignmentRemover
/**
* @param array $stmts
* @param array $var_loc_map
- *
*/
public function findUnusedAssignment(
Codebase $codebase,
diff --git a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php
index 8387a85436d..d6a9b6089b2 100644
--- a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php
@@ -94,20 +94,11 @@
*/
class StatementsAnalyzer extends SourceAnalyzer
{
- /**
- * @var SourceAnalyzer
- */
- protected $source;
+ protected SourceAnalyzer $source;
- /**
- * @var FileAnalyzer
- */
- protected $file_analyzer;
+ protected FileAnalyzer $file_analyzer;
- /**
- * @var Codebase
- */
- protected $codebase;
+ protected Codebase $codebase;
/**
* @var array
@@ -139,17 +130,15 @@ class StatementsAnalyzer extends SourceAnalyzer
/**
* @var array
*/
- public $byref_uses = [];
+ public array $byref_uses = [];
private ?ParsedDocblock $parsed_docblock = null;
private ?string $fake_this_class = null;
- /** @var NodeDataProvider */
- public $node_data;
+ public NodeDataProvider $node_data;
- /** @var ?DataFlowGraph */
- public $data_flow_graph;
+ public ?DataFlowGraph $data_flow_graph = null;
/**
* Locations of foreach values
@@ -159,7 +148,7 @@ class StatementsAnalyzer extends SourceAnalyzer
* @var array>
* @psalm-internal Psalm\Internal\Analyzer
*/
- public $foreach_var_locations = [];
+ public array $foreach_var_locations = [];
public function __construct(SourceAnalyzer $source, NodeDataProvider $node_data)
{
@@ -179,7 +168,6 @@ public function __construct(SourceAnalyzer $source, NodeDataProvider $node_data)
* Checks an array of statements for validity
*
* @param array $stmts
- *
* @return null|false
*/
public function analyze(
diff --git a/src/Psalm/Internal/Analyzer/TypeAnalyzer.php b/src/Psalm/Internal/Analyzer/TypeAnalyzer.php
index 05a4548c84e..0c871fe2200 100644
--- a/src/Psalm/Internal/Analyzer/TypeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/TypeAnalyzer.php
@@ -18,7 +18,6 @@ class TypeAnalyzer
*
* @param array $new_types
* @param array $existing_types
- *
* @return array
*/
public static function combineKeyedTypes(array $new_types, array $existing_types): array
diff --git a/src/Psalm/Internal/Clause.php b/src/Psalm/Internal/Clause.php
index 2d76469f49f..7e1c952bed2 100644
--- a/src/Psalm/Internal/Clause.php
+++ b/src/Psalm/Internal/Clause.php
@@ -24,17 +24,15 @@
/**
* @internal
- *
* @psalm-immutable
*/
class Clause
{
use ImmutableNonCloneableTrait;
- /** @var int */
- public $creating_conditional_id;
- /** @var int */
- public $creating_object_id;
+ public int $creating_conditional_id;
+
+ public int $creating_object_id;
/**
* An array of strings of the form
@@ -51,7 +49,7 @@ class Clause
*
* @var array>
*/
- public $possibilities;
+ public array $possibilities;
/**
* An array of things that are not true
@@ -67,22 +65,18 @@ class Clause
*
* @var array>|null
*/
- public $impossibilities;
+ public ?array $impossibilities = null;
- /** @var bool */
- public $wedge;
+ public bool $wedge;
- /** @var bool */
- public $reconcilable;
+ public bool $reconcilable;
- /** @var bool */
- public $generated = false;
+ public bool $generated = false;
/** @var array */
- public $redefined_vars = [];
+ public array $redefined_vars = [];
- /** @var string */
- public $hash;
+ public string $hash;
/**
* @param array> $possibilities
diff --git a/src/Psalm/Internal/CliUtils.php b/src/Psalm/Internal/CliUtils.php
index 76afad8d136..b1b5ad0542d 100644
--- a/src/Psalm/Internal/CliUtils.php
+++ b/src/Psalm/Internal/CliUtils.php
@@ -132,7 +132,6 @@ public static function requireAutoloaders(
foreach ($autoload_files as $file) {
/**
* @psalm-suppress UnresolvableInclude
- *
* @var mixed
*/
$autoloader = require_once $file;
@@ -255,7 +254,6 @@ public static function getArguments(): array
/**
* @param string|array|null|false $f_paths
- *
* @return list|null
*/
public static function getPathsToCheck($f_paths): ?array
diff --git a/src/Psalm/Internal/Codebase/Analyzer.php b/src/Psalm/Internal/Codebase/Analyzer.php
index 239f7c453d0..beeaa80aa3c 100644
--- a/src/Psalm/Internal/Codebase/Analyzer.php
+++ b/src/Psalm/Internal/Codebase/Analyzer.php
@@ -110,7 +110,7 @@ class Analyzer
*
* @var array
*/
- private $mixed_counts = [];
+ private array $mixed_counts = [];
/**
* Used to store member names of mixed property/method access
@@ -141,7 +141,7 @@ class Analyzer
*
* @var array
*/
- private $files_with_analysis_results = [];
+ private array $files_with_analysis_results = [];
/**
* We may update fewer files than we analyse (i.e. for dead code detection)
@@ -178,12 +178,12 @@ class Analyzer
/**
* @var array>
*/
- public $possible_method_param_types = [];
+ public array $possible_method_param_types = [];
/**
* @var array
*/
- public $mutable_classes = [];
+ public array $mutable_classes = [];
public function __construct(
Config $config,
@@ -199,7 +199,6 @@ public function __construct(
/**
* @param array $files_to_analyze
- *
*/
public function addFilesToAnalyze(array $files_to_analyze): void
{
@@ -209,7 +208,6 @@ public function addFilesToAnalyze(array $files_to_analyze): void
/**
* @param array $files_to_analyze
- *
*/
public function addFilesToShowResults(array $files_to_analyze): void
{
@@ -218,7 +216,6 @@ public function addFilesToShowResults(array $files_to_analyze): void
/**
* @param array $files_to_update
- *
*/
public function setFilesToUpdate(array $files_to_update): void
{
@@ -1072,7 +1069,6 @@ public function hasMixedMemberName(string $member_id): bool
/**
* @param array> $names
- *
*/
public function addMixedMemberNames(array $names): void
{
@@ -1102,7 +1098,6 @@ public function getMixedCountsForFile(string $file_path): array
/**
* @param list{int, int} $mixed_counts
- *
*/
public function setMixedCountsForFile(string $file_path, array $mixed_counts): void
{
diff --git a/src/Psalm/Internal/Codebase/ClassLikes.php b/src/Psalm/Internal/Codebase/ClassLikes.php
index 5019317f43e..f9069e1de02 100644
--- a/src/Psalm/Internal/Codebase/ClassLikes.php
+++ b/src/Psalm/Internal/Codebase/ClassLikes.php
@@ -74,55 +74,52 @@ class ClassLikes
{
private ClassLikeStorageProvider $classlike_storage_provider;
- /**
- * @var FileReferenceProvider
- */
- public $file_reference_provider;
+ public FileReferenceProvider $file_reference_provider;
/**
* @var array
*/
- private $existing_classlikes_lc = [];
+ private array $existing_classlikes_lc = [];
/**
* @var array
*/
- private $existing_classes_lc = [];
+ private array $existing_classes_lc = [];
/**
* @var array
*/
- private $existing_classes = [];
+ private array $existing_classes = [];
/**
* @var array
*/
- private $existing_interfaces_lc = [];
+ private array $existing_interfaces_lc = [];
/**
* @var array
*/
- private $existing_interfaces = [];
+ private array $existing_interfaces = [];
/**
* @var array
*/
- private $existing_traits_lc = [];
+ private array $existing_traits_lc = [];
/**
* @var array
*/
- private $existing_traits = [];
+ private array $existing_traits = [];
/**
* @var array
*/
- private $existing_enums_lc = [];
+ private array $existing_enums_lc = [];
/**
* @var array
*/
- private $existing_enums = [];
+ private array $existing_enums = [];
/**
* @var array
@@ -139,15 +136,9 @@ class ClassLikes
*/
private array $trait_nodes = [];
- /**
- * @var bool
- */
- public $collect_references = false;
+ public bool $collect_references = false;
- /**
- * @var bool
- */
- public $collect_locations = false;
+ public bool $collect_locations = false;
private StatementsProvider $statements_provider;
@@ -1577,7 +1568,6 @@ public function airliftClassDefinedDocblockType(
/**
* @param ReflectionProperty::IS_PUBLIC|ReflectionProperty::IS_PROTECTED|ReflectionProperty::IS_PRIVATE
* $visibility
- *
* @return array
*/
public function getConstantsForClass(string $class_name, int $visibility): array
@@ -2281,7 +2271,6 @@ public function getThreadData(): array
* 7: array,
* 8: array,
* } $thread_data
- *
*/
public function addThreadData(array $thread_data): void
{
diff --git a/src/Psalm/Internal/Codebase/DataFlowGraph.php b/src/Psalm/Internal/Codebase/DataFlowGraph.php
index 5f66a1955cc..6a79fa7e2bf 100644
--- a/src/Psalm/Internal/Codebase/DataFlowGraph.php
+++ b/src/Psalm/Internal/Codebase/DataFlowGraph.php
@@ -20,7 +20,7 @@
abstract class DataFlowGraph
{
/** @var array> */
- protected $forward_edges = [];
+ protected array $forward_edges = [];
abstract public function addNode(DataFlowNode $node): void;
@@ -58,7 +58,6 @@ public function addPath(
/**
* @param array $previous_path_types
- *
* @psalm-pure
*/
protected static function shouldIgnoreFetch(
diff --git a/src/Psalm/Internal/Codebase/Functions.php b/src/Psalm/Internal/Codebase/Functions.php
index 70ea45c5000..320540013d9 100644
--- a/src/Psalm/Internal/Codebase/Functions.php
+++ b/src/Psalm/Internal/Codebase/Functions.php
@@ -42,19 +42,15 @@ class Functions
/**
* @var array
*/
- private static $stubbed_functions;
+ private static array $stubbed_functions;
- /** @var FunctionReturnTypeProvider */
- public $return_type_provider;
+ public FunctionReturnTypeProvider $return_type_provider;
- /** @var FunctionExistenceProvider */
- public $existence_provider;
+ public FunctionExistenceProvider $existence_provider;
- /** @var FunctionParamsProvider */
- public $params_provider;
+ public FunctionParamsProvider $params_provider;
- /** @var DynamicFunctionStorageProvider */
- public $dynamic_storage_provider;
+ public DynamicFunctionStorageProvider $dynamic_storage_provider;
private Reflection $reflection;
@@ -232,7 +228,6 @@ public function functionExists(
/**
* @param non-empty-string $function_name
- *
* @return non-empty-string
*/
public function getFullyQualifiedFunctionNameFromString(string $function_name, StatementsSource $source): string
diff --git a/src/Psalm/Internal/Codebase/InternalCallMapHandler.php b/src/Psalm/Internal/Codebase/InternalCallMapHandler.php
index 56c6054748a..64ad62709e4 100644
--- a/src/Psalm/Internal/Codebase/InternalCallMapHandler.php
+++ b/src/Psalm/Internal/Codebase/InternalCallMapHandler.php
@@ -50,7 +50,7 @@ class InternalCallMapHandler
/**
* @var array>|null
*/
- private static $call_map_callables = [];
+ private static ?array $call_map_callables = [];
/**
* @var array>>
@@ -86,7 +86,6 @@ public static function getCallableFromCallMapById(
/**
* @param array $callables
* @param list $args
- *
*/
public static function getMatchingCallableFromCallMapOptions(
Codebase $codebase,
diff --git a/src/Psalm/Internal/Codebase/Methods.php b/src/Psalm/Internal/Codebase/Methods.php
index 7cc94518634..940edc9c472 100644
--- a/src/Psalm/Internal/Codebase/Methods.php
+++ b/src/Psalm/Internal/Codebase/Methods.php
@@ -54,29 +54,19 @@ class Methods
{
private ClassLikeStorageProvider $classlike_storage_provider;
- /**
- * @var bool
- */
- public $collect_locations = false;
+ public bool $collect_locations = false;
- /**
- * @var FileReferenceProvider
- */
- public $file_reference_provider;
+ public FileReferenceProvider $file_reference_provider;
private ClassLikes $classlikes;
- /** @var MethodReturnTypeProvider */
- public $return_type_provider;
+ public MethodReturnTypeProvider $return_type_provider;
- /** @var MethodParamsProvider */
- public $params_provider;
+ public MethodParamsProvider $params_provider;
- /** @var MethodExistenceProvider */
- public $existence_provider;
+ public MethodExistenceProvider $existence_provider;
- /** @var MethodVisibilityProvider */
- public $visibility_provider;
+ public MethodVisibilityProvider $visibility_provider;
public function __construct(
ClassLikeStorageProvider $storage_provider,
@@ -347,7 +337,6 @@ public function methodExists(
/**
* @param list $args
- *
* @return list
*/
public function getMethodParams(
@@ -560,7 +549,6 @@ public function isVariadic(MethodIdentifier $method_id): bool
/**
* @param list|null $args
- *
*/
public function getMethodReturnType(
MethodIdentifier $method_id,
@@ -918,10 +906,6 @@ public function getMethodReturnsByRef(MethodIdentifier $method_id): bool
return $this->getStorage($method_id)->returns_by_ref;
}
- /**
- * @param CodeLocation|null $defined_location
- *
- */
public function getMethodReturnTypeLocation(
MethodIdentifier $method_id,
CodeLocation &$defined_location = null
@@ -953,7 +937,6 @@ public function getMethodReturnTypeLocation(
/**
* @param lowercase-string $method_name_lc
* @param lowercase-string $declaring_method_name_lc
- *
*/
public function setDeclaringMethodId(
string $fq_class_name,
@@ -972,7 +955,6 @@ public function setDeclaringMethodId(
/**
* @param lowercase-string $method_name_lc
* @param lowercase-string $appearing_method_name_lc
- *
*/
public function setAppearingMethodId(
string $fq_class_name,
diff --git a/src/Psalm/Internal/Codebase/Populator.php b/src/Psalm/Internal/Codebase/Populator.php
index b5abb3b3aa2..64f322f8f43 100644
--- a/src/Psalm/Internal/Codebase/Populator.php
+++ b/src/Psalm/Internal/Codebase/Populator.php
@@ -43,7 +43,7 @@ class Populator
/**
* @var array>
*/
- private $invalid_class_storages = [];
+ private array $invalid_class_storages = [];
private Progress $progress;
diff --git a/src/Psalm/Internal/Codebase/Properties.php b/src/Psalm/Internal/Codebase/Properties.php
index 769cd378c80..ad44695ce87 100644
--- a/src/Psalm/Internal/Codebase/Properties.php
+++ b/src/Psalm/Internal/Codebase/Properties.php
@@ -29,30 +29,15 @@ class Properties
private ClassLikes $classlikes;
- /**
- * @var bool
- */
- public $collect_locations = false;
+ public bool $collect_locations = false;
- /**
- * @var FileReferenceProvider
- */
- public $file_reference_provider;
+ public FileReferenceProvider $file_reference_provider;
- /**
- * @var PropertyExistenceProvider
- */
- public $property_existence_provider;
+ public PropertyExistenceProvider $property_existence_provider;
- /**
- * @var PropertyTypeProvider
- */
- public $property_type_provider;
+ public PropertyTypeProvider $property_type_provider;
- /**
- * @var PropertyVisibilityProvider
- */
- public $property_visibility_provider;
+ public PropertyVisibilityProvider $property_visibility_provider;
public function __construct(
@@ -70,7 +55,6 @@ public function __construct(
/**
* Whether or not a given property exists
- *
*/
public function propertyExists(
string $property_id,
diff --git a/src/Psalm/Internal/Codebase/Reflection.php b/src/Psalm/Internal/Codebase/Reflection.php
index cd521511f98..a750d4ad673 100644
--- a/src/Psalm/Internal/Codebase/Reflection.php
+++ b/src/Psalm/Internal/Codebase/Reflection.php
@@ -46,7 +46,7 @@ class Reflection
/**
* @var array
*/
- private static $builtin_functions = [];
+ private static array $builtin_functions = [];
public function __construct(ClassLikeStorageProvider $storage_provider, Codebase $codebase)
{
@@ -355,7 +355,6 @@ private function getReflectionParamData(ReflectionParameter $param): FunctionLik
/**
* @param callable-string $function_id
- *
* @return false|null
*/
public function registerFunction(string $function_id): ?bool
@@ -471,7 +470,6 @@ private function registerInheritedMethods(
/**
* @param lowercase-string $fq_class_name
* @param lowercase-string $parent_class
- *
*/
private function registerInheritedProperties(
string $fq_class_name,
diff --git a/src/Psalm/Internal/Codebase/Scanner.php b/src/Psalm/Internal/Codebase/Scanner.php
index 177454a8828..6d4d86d4fcc 100644
--- a/src/Psalm/Internal/Codebase/Scanner.php
+++ b/src/Psalm/Internal/Codebase/Scanner.php
@@ -90,47 +90,47 @@ class Scanner
/**
* @var array
*/
- private $classlike_files = [];
+ private array $classlike_files = [];
/**
* @var array
*/
- private $deep_scanned_classlike_files = [];
+ private array $deep_scanned_classlike_files = [];
/**
* @var array
*/
- private $files_to_scan = [];
+ private array $files_to_scan = [];
/**
* @var array
*/
- private $classes_to_scan = [];
+ private array $classes_to_scan = [];
/**
* @var array
*/
- private $classes_to_deep_scan = [];
+ private array $classes_to_deep_scan = [];
/**
* @var array
*/
- private $files_to_deep_scan = [];
+ private array $files_to_deep_scan = [];
/**
* @var array
*/
- private $scanned_files = [];
+ private array $scanned_files = [];
/**
* @var array
*/
- private $store_scan_failure = [];
+ private array $store_scan_failure = [];
/**
* @var array
*/
- private $reflected_classlikes_lc = [];
+ private array $reflected_classlikes_lc = [];
private Reflection $reflection;
@@ -166,7 +166,6 @@ public function __construct(
/**
* @param array $files_to_scan
- *
*/
public function addFilesToShallowScan(array $files_to_scan): void
{
@@ -743,7 +742,6 @@ public function getThreadData(): array
/**
* @param ThreadData $thread_data
- *
*/
public function addThreadData(array $thread_data): void
{
diff --git a/src/Psalm/Internal/Codebase/TaintFlowGraph.php b/src/Psalm/Internal/Codebase/TaintFlowGraph.php
index 17ad6cb2152..5bbf5ff6130 100644
--- a/src/Psalm/Internal/Codebase/TaintFlowGraph.php
+++ b/src/Psalm/Internal/Codebase/TaintFlowGraph.php
@@ -52,7 +52,7 @@ class TaintFlowGraph extends DataFlowGraph
private array $sources = [];
/** @var array */
- private $nodes = [];
+ private array $nodes = [];
/** @var array */
private array $sinks = [];
diff --git a/src/Psalm/Internal/Codebase/VariableUseGraph.php b/src/Psalm/Internal/Codebase/VariableUseGraph.php
index d536a4a71f1..608bfd64519 100644
--- a/src/Psalm/Internal/Codebase/VariableUseGraph.php
+++ b/src/Psalm/Internal/Codebase/VariableUseGraph.php
@@ -16,7 +16,7 @@
class VariableUseGraph extends DataFlowGraph
{
/** @var array> */
- protected $backward_edges = [];
+ protected array $backward_edges = [];
/** @var array */
private array $nodes = [];
diff --git a/src/Psalm/Internal/DataFlow/DataFlowNode.php b/src/Psalm/Internal/DataFlow/DataFlowNode.php
index 95c2327970d..e0c38e03934 100644
--- a/src/Psalm/Internal/DataFlow/DataFlowNode.php
+++ b/src/Psalm/Internal/DataFlow/DataFlowNode.php
@@ -8,39 +8,33 @@
/**
* @psalm-consistent-constructor
- *
* @internal
*/
class DataFlowNode
{
- /** @var string */
- public $id;
+ public string $id;
- /** @var ?string */
- public $unspecialized_id;
+ public ?string $unspecialized_id = null;
- /** @var string */
- public $label;
+ public string $label;
- /** @var ?CodeLocation */
- public $code_location;
+ public ?CodeLocation $code_location = null;
- /** @var ?string */
- public $specialization_key;
+ public ?string $specialization_key = null;
/** @var array */
- public $taints;
+ public array $taints;
/** @var ?self */
- public $previous;
+ public ?DataFlowNode $previous = null;
/** @var list */
- public $path_types = [];
+ public array $path_types = [];
/**
* @var array>
*/
- public $specialized_calls = [];
+ public array $specialized_calls = [];
/**
* @param array $taints
diff --git a/src/Psalm/Internal/DataFlow/Path.php b/src/Psalm/Internal/DataFlow/Path.php
index e28eecb91fd..a6de16c95ee 100644
--- a/src/Psalm/Internal/DataFlow/Path.php
+++ b/src/Psalm/Internal/DataFlow/Path.php
@@ -6,20 +6,21 @@
/**
* @psalm-immutable
- *
* @internal
*/
class Path
{
use ImmutableNonCloneableTrait;
- public $type;
+ public string $type;
- public $unescaped_taints;
+ /** @var ?array */
+ public ?array $unescaped_taints = null;
- public $escaped_taints;
+ /** @var ?array */
+ public ?array $escaped_taints = null;
- public $length;
+ public int $length;
/**
* @param ?array $unescaped_taints
diff --git a/src/Psalm/Internal/Diff/AstDiffer.php b/src/Psalm/Internal/Diff/AstDiffer.php
index 7ab61cee590..5165d47ceb1 100644
--- a/src/Psalm/Internal/Diff/AstDiffer.php
+++ b/src/Psalm/Internal/Diff/AstDiffer.php
@@ -27,7 +27,6 @@ class AstDiffer
* @param Closure(Stmt, Stmt, string, string, bool=): bool $is_equal
* @param array $a
* @param array $b
- *
* @return array{0:non-empty-list>, 1: int, 2: int, 3: array}
*/
protected static function calculateTrace(
@@ -79,9 +78,7 @@ protected static function calculateTrace(
* @param array $a
* @param array $b
* @param array $bc
- *
* @return list
- *
* @psalm-pure
*/
protected static function extractDiff(array $trace, int $x, int $y, array $a, array $b, array $bc): array
diff --git a/src/Psalm/Internal/Diff/ClassStatementsDiffer.php b/src/Psalm/Internal/Diff/ClassStatementsDiffer.php
index ccc6e947815..fed20010c29 100644
--- a/src/Psalm/Internal/Diff/ClassStatementsDiffer.php
+++ b/src/Psalm/Internal/Diff/ClassStatementsDiffer.php
@@ -21,7 +21,6 @@ class ClassStatementsDiffer extends AstDiffer
*
* @param array $a
* @param array $b
- *
* @return array{
* 0: list,
* 1: list,
diff --git a/src/Psalm/Internal/Diff/DiffElem.php b/src/Psalm/Internal/Diff/DiffElem.php
index 6d506c70111..b76caab99f9 100644
--- a/src/Psalm/Internal/Diff/DiffElem.php
+++ b/src/Psalm/Internal/Diff/DiffElem.php
@@ -8,7 +8,6 @@
/**
* @internal
- *
* @psalm-immutable
*/
class DiffElem
@@ -22,7 +21,7 @@ class DiffElem
public const TYPE_KEEP_SIGNATURE = 4;
/** @var int One of the TYPE_* constants */
- public $type;
+ public int $type;
/** @var mixed Is null for add operations */
public $old;
/** @var mixed Is null for remove operations */
diff --git a/src/Psalm/Internal/Diff/FileDiffer.php b/src/Psalm/Internal/Diff/FileDiffer.php
index 4e1ee3fd860..6d72bc038ce 100644
--- a/src/Psalm/Internal/Diff/FileDiffer.php
+++ b/src/Psalm/Internal/Diff/FileDiffer.php
@@ -28,9 +28,7 @@ class FileDiffer
/**
* @param list $a
* @param list $b
- *
* @return array{0:non-empty-list>, 1: int, 2: int}
- *
* @psalm-pure
*/
private static function calculateTrace(
@@ -72,9 +70,7 @@ private static function calculateTrace(
* @param list> $trace
* @param list $a
* @param list $b
- *
* @return list
- *
* @psalm-pure
*/
private static function extractDiff(array $trace, int $x, int $y, array $a, array $b): array
@@ -125,7 +121,6 @@ private static function extractDiff(array $trace, int $x, int $y, array $a, arra
/**
* @return array
- *
* @psalm-pure
*/
public static function getDiff(string $a_code, string $b_code): array
@@ -273,9 +268,7 @@ public static function getDiff(string $a_code, string $b_code): array
* Coalesce equal-length sequences of remove+add into a replace operation.
*
* @param DiffElem[] $diff
- *
* @return list
- *
* @psalm-pure
*/
private static function coalesceReplacements(array $diff): array
diff --git a/src/Psalm/Internal/Diff/FileStatementsDiffer.php b/src/Psalm/Internal/Diff/FileStatementsDiffer.php
index cb90a339c51..02316c62589 100644
--- a/src/Psalm/Internal/Diff/FileStatementsDiffer.php
+++ b/src/Psalm/Internal/Diff/FileStatementsDiffer.php
@@ -15,9 +15,9 @@ class FileStatementsDiffer extends AstDiffer
{
/**
* Calculate diff (edit script) from $a to $b.
+ *
* @param list $a
* @param list $b
- *
* @return array{
* 0: list,
* 1: list,
diff --git a/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php b/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php
index a3788f848e6..03b5469fba7 100644
--- a/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php
+++ b/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php
@@ -15,9 +15,9 @@ class NamespaceStatementsDiffer extends AstDiffer
{
/**
* Calculate diff (edit script) from $a to $b.
+ *
* @param array $a
* @param array $b
- *
* @return array{
* 0: list,
* 1: list,
diff --git a/src/Psalm/Internal/EventDispatcher.php b/src/Psalm/Internal/EventDispatcher.php
index ad6e091daf1..b42c7b3da36 100644
--- a/src/Psalm/Internal/EventDispatcher.php
+++ b/src/Psalm/Internal/EventDispatcher.php
@@ -64,7 +64,7 @@ class EventDispatcher
*
* @var list>
*/
- public $after_function_checks = [];
+ public array $after_function_checks = [];
/**
* Static methods to be called after every function call
@@ -75,49 +75,49 @@ class EventDispatcher
*
* @var list>
*/
- public $after_every_function_checks = [];
+ public array $after_every_function_checks = [];
/**
* Static methods to be called after expression checks have completed
*
* @var list>
*/
- public $after_expression_checks = [];
+ public array $after_expression_checks = [];
/**
* Static methods to be called before statement checks are processed
*
* @var list>
*/
- public $before_statement_checks = [];
+ public array $before_statement_checks = [];
/**
* Static methods to be called after statement checks have completed
*
* @var list>
*/
- public $after_statement_checks = [];
+ public array $after_statement_checks = [];
/**
* Static methods to be called after method checks have completed
*
* @var list>
*/
- public $string_interpreters = [];
+ public array $string_interpreters = [];
/**
* Static methods to be called after classlike exists checks have completed
*
* @var list>
*/
- public $after_classlike_exists_checks = [];
+ public array $after_classlike_exists_checks = [];
/**
* Static methods to be called after classlike checks have completed
*
* @var list>
*/
- public $after_classlike_checks = [];
+ public array $after_classlike_checks = [];
/**
* Static methods to be called after classlikes have been scanned
@@ -131,7 +131,7 @@ class EventDispatcher
*
* @var list>
*/
- public $after_codebase_populated = [];
+ public array $after_codebase_populated = [];
/**
* @var list>
@@ -143,42 +143,42 @@ class EventDispatcher
*
* @var list>
*/
- public $after_analysis = [];
+ public array $after_analysis = [];
/**
* Static methods to be called after a file has been analyzed
*
* @var list>
*/
- public $after_file_checks = [];
+ public array $after_file_checks = [];
/**
* Static methods to be called before a file is analyzed
*
* @var list>
*/
- public $before_file_checks = [];
+ public array $before_file_checks = [];
/**
* Static methods to be called after functionlike checks have completed
*
* @var list>
*/
- public $after_functionlike_checks = [];
+ public array $after_functionlike_checks = [];
/**
* Static methods to be called to see if taints should be added
*
* @var list>
*/
- public $add_taints_checks = [];
+ public array $add_taints_checks = [];
/**
* Static methods to be called to see if taints should be removed
*
* @var list>
*/
- public $remove_taints_checks = [];
+ public array $remove_taints_checks = [];
/**
* @param class-string $class
diff --git a/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php b/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php
index 25d731dcc96..2d87476fc77 100644
--- a/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php
+++ b/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php
@@ -18,7 +18,6 @@
* Environment variables collector for CI environment.
*
* @author Kitamura Satoshi
- *
* @internal
*/
class BuildInfoCollector
@@ -27,17 +26,13 @@ class BuildInfoCollector
* Environment variables.
*
* Overwritten through collection process.
- *
- * @var array
*/
- protected $env;
+ protected array $env;
/**
* Read environment variables.
- *
- * @var array
*/
- protected $readEnv = [];
+ protected array $readEnv = [];
public function __construct(array $env)
{
@@ -72,7 +67,6 @@ public function collect(): array
* "TRAVIS", "TRAVIS_JOB_ID" must be set.
*
* @return $this
- *
* @psalm-suppress PossiblyUndefinedStringArrayOffset
*/
protected function fillTravisCi(): self
@@ -149,7 +143,6 @@ protected function fillCircleCi(): self
* "APPVEYOR", "APPVEYOR_BUILD_NUMBER" must be set.
*
* @psalm-suppress PossiblyUndefinedStringArrayOffset
- *
* @return $this
*/
protected function fillAppVeyor(): self
@@ -221,7 +214,6 @@ protected function fillJenkins(): self
* "JENKINS_URL", "BUILD_NUMBER" must be set.
*
* @psalm-suppress PossiblyUndefinedStringArrayOffset
- *
* @return $this
*/
protected function fillScrutinizer(): self
diff --git a/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php b/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php
index 68d3ff77eed..d9ec447db52 100644
--- a/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php
+++ b/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php
@@ -19,17 +19,14 @@
* Git repository info collector.
*
* @author Kitamura Satoshi
- *
* @internal
*/
class GitInfoCollector
{
/**
* Git command.
- *
- * @var SystemCommandExecutor
*/
- protected $executor;
+ protected SystemCommandExecutor $executor;
/**
* Constructor.
@@ -102,7 +99,6 @@ protected function collectCommit(): CommitInfo
* Collect remotes info.
*
* @throws RuntimeException
- *
* @return list