diff --git a/UPGRADING.md b/UPGRADING.md
index 96b4c8578fa..55cb4f65119 100644
--- a/UPGRADING.md
+++ b/UPGRADING.md
@@ -34,10 +34,16 @@
- [BC] The return type of `Psalm\Internal\LanguageServer\ProtocolWriter#write() changed from `Amp\Promise` to `void` due to the switch to Amp v3
+- [BC] All parameters, properties and return typehints are now strictly typed.
+
+- [BC] `strict_types` is now applied to all files of the Psalm codebase.
+
- [BC] Properties `Psalm\Type\Atomic\TLiteralFloat::$value` and `Psalm\Type\Atomic\TLiteralInt::$value` became typed (`float` and `int` respectively)
- [BC] Property `Psalm\Storage\EnumCaseStorage::$value` changed from `int|string|null` to `TLiteralInt|TLiteralString|null`
+- [BC] `Psalm\CodeLocation\Raw`, `Psalm\CodeLocation\ParseErrorLocation`, `Psalm\CodeLocation\DocblockTypeLocation`, `Psalm\Report\CountReport`, `Psalm\Type\Atomic\TNonEmptyArray` are now all final.
+
# Upgrading from Psalm 4 to Psalm 5
## Changed
diff --git a/bin/generate_issues_list_doc.php b/bin/generate_issues_list_doc.php
index 8a3e179ca2d..0b324af3504 100755
--- a/bin/generate_issues_list_doc.php
+++ b/bin/generate_issues_list_doc.php
@@ -1,6 +1,8 @@
#!/usr/bin/env php
' . PHP_EOL);
exit(1);
@@ -35,7 +37,7 @@
);
array_multisort($order, $files);
-$chunks = array_chunk($files, ceil(count($files) / $number_of_chunks));
+$chunks = array_chunk($files, (int) ceil(count($files) / $number_of_chunks));
$phpunit_config = new DOMDocument('1.0', 'UTF-8');
$phpunit_config->preserveWhiteSpace = false;
diff --git a/bin/improve_class_alias.php b/bin/improve_class_alias.php
index 6b6f34ff299..014fc4144e9 100644
--- a/bin/improve_class_alias.php
+++ b/bin/improve_class_alias.php
@@ -1,5 +1,7 @@
-
+
@@ -91,8 +91,6 @@
-
-
- bin/*
- src/Psalm/Internal/*
- tests/*
+
+
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index fff3a06b79f..d04ba234885 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -1,5 +1,5 @@
-
+
tags['variablesfrom'][0]]]>
@@ -251,6 +251,16 @@
$stub
+
+
+ methods[$declaring_method_name]->stubbed]]>
+
+
+
+
+ methods[$implementing_method_id->method_name]->abstract]]>
+
+
$property_name
@@ -346,9 +356,6 @@
$since_parts[1]
-
- 0]]>
-
diff --git a/src/Psalm/Aliases.php b/src/Psalm/Aliases.php
index 526021c8a57..daa39b90a30 100644
--- a/src/Psalm/Aliases.php
+++ b/src/Psalm/Aliases.php
@@ -1,5 +1,7 @@
*/
- public $uses;
+ public array $uses;
/**
* @var array
*/
- public $uses_flipped;
+ public array $uses_flipped;
/**
* @var array
*/
- public $functions;
+ public array $functions;
/**
* @var array
*/
- public $functions_flipped;
+ public array $functions_flipped;
/**
* @var array
*/
- public $constants;
+ public array $constants;
/**
* @var array
*/
- public $constants_flipped;
+ public array $constants_flipped;
- /** @var string|null */
- public $namespace;
+ public ?string $namespace = null;
- /** @var ?int */
- public $namespace_first_stmt_start;
+ public ?int $namespace_first_stmt_start = null;
- /** @var ?int */
- public $uses_start;
+ public ?int $uses_start = null;
- /** @var ?int */
- public $uses_end;
+ public ?int $uses_end = null;
/**
* @param array $uses
@@ -63,7 +61,7 @@ public function __construct(
array $constants = [],
array $uses_flipped = [],
array $functions_flipped = [],
- array $constants_flipped = []
+ array $constants_flipped = [],
) {
$this->namespace = $namespace;
$this->uses = $uses;
diff --git a/src/Psalm/CodeLocation.php b/src/Psalm/CodeLocation.php
index 750478c4f02..9c35acfb340 100644
--- a/src/Psalm/CodeLocation.php
+++ b/src/Psalm/CodeLocation.php
@@ -1,5 +1,7 @@
file_start = (int)$stmt->getAttribute('startFilePos');
diff --git a/src/Psalm/CodeLocation/DocblockTypeLocation.php b/src/Psalm/CodeLocation/DocblockTypeLocation.php
index f38c79f01ce..36a76aef192 100644
--- a/src/Psalm/CodeLocation/DocblockTypeLocation.php
+++ b/src/Psalm/CodeLocation/DocblockTypeLocation.php
@@ -1,18 +1,20 @@
file_start = $file_start;
// matches how CodeLocation works
diff --git a/src/Psalm/CodeLocation/ParseErrorLocation.php b/src/Psalm/CodeLocation/ParseErrorLocation.php
index 1714ff7fead..d20d96eb8e1 100644
--- a/src/Psalm/CodeLocation/ParseErrorLocation.php
+++ b/src/Psalm/CodeLocation/ParseErrorLocation.php
@@ -1,5 +1,7 @@
file_start = (int)$error->getAttributes()['startFilePos'];
diff --git a/src/Psalm/CodeLocation/Raw.php b/src/Psalm/CodeLocation/Raw.php
index 30d68d2f900..bcafcaa7d25 100644
--- a/src/Psalm/CodeLocation/Raw.php
+++ b/src/Psalm/CodeLocation/Raw.php
@@ -1,5 +1,7 @@
file_start = $file_start;
$this->file_end = $file_end;
diff --git a/src/Psalm/Codebase.php b/src/Psalm/Codebase.php
index b5a00e9f3a0..1e2e47498b7 100644
--- a/src/Psalm/Codebase.php
+++ b/src/Psalm/Codebase.php
@@ -1,5 +1,7 @@
>
*/
- public $use_referencing_locations = [];
+ public array $use_referencing_locations = [];
- /**
- * @var FileStorageProvider
- */
- public $file_storage_provider;
+ public FileStorageProvider $file_storage_provider;
- /**
- * @var ClassLikeStorageProvider
- */
- public $classlike_storage_provider;
+ public ClassLikeStorageProvider $classlike_storage_provider;
- /**
- * @var bool
- */
- public $collect_references = false;
+ public bool $collect_references = false;
- /**
- * @var bool
- */
- public $collect_locations = false;
+ public bool $collect_locations = false;
/**
* @var null|'always'|'auto'
*/
- public $find_unused_code;
+ public ?string $find_unused_code = null;
- /**
- * @var FileProvider
- */
- public $file_provider;
+ public FileProvider $file_provider;
- /**
- * @var FileReferenceProvider
- */
- public $file_reference_provider;
+ public FileReferenceProvider $file_reference_provider;
- /**
- * @var StatementsProvider
- */
- public $statements_provider;
+ public StatementsProvider $statements_provider;
private Progress $progress;
/**
* @var array
*/
- private static $stubbed_constants = [];
+ private static array $stubbed_constants = [];
/**
* Whether to register autoloaded information
- *
- * @var bool
*/
- public $register_autoload_files = false;
+ public bool $register_autoload_files = false;
/**
* Whether to log functions just at the file level or globally (for stubs)
- *
- * @var bool
*/
- public $register_stub_files = false;
+ public bool $register_stub_files = false;
- /**
- * @var bool
- */
- public $find_unused_variables = false;
+ public bool $find_unused_variables = false;
- /**
- * @var Scanner
- */
- public $scanner;
+ public Scanner $scanner;
- /**
- * @var Analyzer
- */
- public $analyzer;
+ public Analyzer $analyzer;
- /**
- * @var Functions
- */
- public $functions;
+ public Functions $functions;
- /**
- * @var ClassLikes
- */
- public $classlikes;
+ public ClassLikes $classlikes;
- /**
- * @var Methods
- */
- public $methods;
+ public Methods $methods;
- /**
- * @var Properties
- */
- public $properties;
+ public Properties $properties;
- /**
- * @var Populator
- */
- public $populator;
+ public Populator $populator;
- /**
- * @var ?TaintFlowGraph
- */
- public $taint_flow_graph;
+ public ?TaintFlowGraph $taint_flow_graph = null;
- /**
- * @var bool
- */
- public $server_mode = false;
+ public bool $server_mode = false;
- /**
- * @var bool
- */
- public $store_node_types = false;
+ public bool $store_node_types = false;
/**
* Whether or not to infer types from usage. Computationally expensive, so turned off by default
- *
- * @var bool
*/
- public $infer_types_from_usage = false;
+ public bool $infer_types_from_usage = false;
- /**
- * @var bool
- */
- public $alter_code = false;
+ public bool $alter_code = false;
- /**
- * @var bool
- */
- public $diff_methods = false;
+ public bool $diff_methods = false;
/**
* @var array
*/
- public $methods_to_move = [];
+ public array $methods_to_move = [];
/**
* @var array
*/
- public $methods_to_rename = [];
+ public array $methods_to_rename = [];
/**
* @var array
*/
- public $properties_to_move = [];
+ public array $properties_to_move = [];
/**
* @var array
*/
- public $properties_to_rename = [];
+ public array $properties_to_rename = [];
/**
* @var array
*/
- public $class_constants_to_move = [];
+ public array $class_constants_to_move = [];
/**
* @var array
*/
- public $class_constants_to_rename = [];
+ public array $class_constants_to_rename = [];
/**
* @var array
*/
- public $classes_to_move = [];
+ public array $classes_to_move = [];
/**
* @var array
*/
- public $call_transforms = [];
+ public array $call_transforms = [];
/**
* @var array
*/
- public $property_transforms = [];
+ public array $property_transforms = [];
/**
* @var array
*/
- public $class_constant_transforms = [];
+ public array $class_constant_transforms = [];
/**
* @var array
*/
- public $class_transforms = [];
+ public array $class_transforms = [];
- /**
- * @var bool
- */
- public $allow_backwards_incompatible_changes = true;
+ public bool $allow_backwards_incompatible_changes = true;
- /** @var int */
- public $analysis_php_version_id = PHP_VERSION_ID;
+ public int $analysis_php_version_id = PHP_VERSION_ID;
/** @var 'cli'|'config'|'composer'|'tests'|'runtime' */
- public $php_version_source = 'runtime';
+ public string $php_version_source = 'runtime';
- /**
- * @var bool
- */
- public $track_unused_suppressions = false;
+ public bool $track_unused_suppressions = false;
/** @internal */
public function __construct(
Config $config,
Providers $providers,
- ?Progress $progress = null
+ ?Progress $progress = null,
) {
if ($progress === null) {
$progress = new VoidProgress();
@@ -672,7 +598,7 @@ public function classOrInterfaceExists(
string $fq_class_name,
?CodeLocation $code_location = null,
?string $calling_fq_class_name = null,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
return $this->classlikes->classOrInterfaceExists(
$fq_class_name,
@@ -691,7 +617,7 @@ public function classOrInterfaceOrEnumExists(
string $fq_class_name,
?CodeLocation $code_location = null,
?string $calling_fq_class_name = null,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
return $this->classlikes->classOrInterfaceOrEnumExists(
$fq_class_name,
@@ -715,7 +641,7 @@ public function classExists(
string $fq_class_name,
?CodeLocation $code_location = null,
?string $calling_fq_class_name = null,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
return $this->classlikes->classExists(
$fq_class_name,
@@ -748,7 +674,7 @@ public function interfaceExists(
string $fq_interface_name,
?CodeLocation $code_location = null,
?string $calling_fq_class_name = null,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
return $this->classlikes->interfaceExists(
$fq_interface_name,
@@ -800,7 +726,7 @@ public function traitHasCorrectCasing(string $fq_trait_name): bool
*/
public function getFunctionLikeStorage(
StatementsAnalyzer $statements_analyzer,
- string $function_id
+ string $function_id,
): FunctionLikeStorage {
$doesMethodExist =
MethodIdentifier::isValidMethodIdReference($function_id)
@@ -823,16 +749,13 @@ public function getFunctionLikeStorage(
/**
* Whether or not a given method exists
- *
- * @param string|MethodIdentifier $method_id
- * @param string|MethodIdentifier|null $calling_method_id
*/
public function methodExists(
- $method_id,
+ string|MethodIdentifier $method_id,
?CodeLocation $code_location = null,
- $calling_method_id = null,
+ string|MethodIdentifier|null $calling_method_id = null,
?string $file_path = null,
- bool $is_used = true
+ bool $is_used = true,
): bool {
return $this->methods->methodExists(
MethodIdentifier::wrap($method_id),
@@ -846,28 +769,26 @@ public function methodExists(
}
/**
- * @param string|MethodIdentifier $method_id
* @return array
*/
- public function getMethodParams($method_id): array
+ public function getMethodParams(string|MethodIdentifier $method_id): array
{
return $this->methods->getMethodParams(MethodIdentifier::wrap($method_id));
}
- /**
- * @param string|MethodIdentifier $method_id
- */
- public function isVariadic($method_id): bool
+ public function isVariadic(string|MethodIdentifier $method_id): bool
{
return $this->methods->isVariadic(MethodIdentifier::wrap($method_id));
}
/**
- * @param string|MethodIdentifier $method_id
* @param list $call_args
*/
- public function getMethodReturnType($method_id, ?string &$self_class, array $call_args = []): ?Union
- {
+ public function getMethodReturnType(
+ string|MethodIdentifier $method_id,
+ ?string &$self_class,
+ array $call_args = [],
+ ): ?Union {
return $this->methods->getMethodReturnType(
MethodIdentifier::wrap($method_id),
$self_class,
@@ -876,20 +797,14 @@ public function getMethodReturnType($method_id, ?string &$self_class, array $cal
);
}
- /**
- * @param string|MethodIdentifier $method_id
- */
- public function getMethodReturnsByRef($method_id): bool
+ public function getMethodReturnsByRef(string|MethodIdentifier $method_id): bool
{
return $this->methods->getMethodReturnsByRef(MethodIdentifier::wrap($method_id));
}
- /**
- * @param string|MethodIdentifier $method_id
- */
public function getMethodReturnTypeLocation(
- $method_id,
- CodeLocation &$defined_location = null
+ string|MethodIdentifier $method_id,
+ CodeLocation &$defined_location = null,
): ?CodeLocation {
return $this->methods->getMethodReturnTypeLocation(
MethodIdentifier::wrap($method_id),
@@ -897,10 +812,7 @@ public function getMethodReturnTypeLocation(
);
}
- /**
- * @param string|MethodIdentifier $method_id
- */
- public function getDeclaringMethodId($method_id): ?string
+ public function getDeclaringMethodId(string|MethodIdentifier $method_id): ?string
{
$new_method_id = $this->methods->getDeclaringMethodId(MethodIdentifier::wrap($method_id));
@@ -909,10 +821,8 @@ 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
+ public function getAppearingMethodId(string|MethodIdentifier $method_id): ?string
{
$new_method_id = $this->methods->getAppearingMethodId(MethodIdentifier::wrap($method_id));
@@ -920,18 +830,14 @@ public function getAppearingMethodId($method_id): ?string
}
/**
- * @param string|MethodIdentifier $method_id
* @return array
*/
- public function getOverriddenMethodIds($method_id): array
+ public function getOverriddenMethodIds(string|MethodIdentifier $method_id): array
{
return $this->methods->getOverriddenMethodIds(MethodIdentifier::wrap($method_id));
}
- /**
- * @param string|MethodIdentifier $method_id
- */
- public function getCasedMethodId($method_id): string
+ public function getCasedMethodId(string|MethodIdentifier $method_id): string
{
return $this->methods->getCasedMethodId(MethodIdentifier::wrap($method_id));
}
@@ -988,7 +894,7 @@ public function getFunctionStorageForSymbol(string $file_path, string $symbol):
* Get Markup content from Reference
*/
public function getMarkupContentForSymbolByReference(
- Reference $reference
+ Reference $reference,
): ?PHPMarkdownContent {
//Direct Assignment
if (is_numeric($reference->symbol[0])) {
@@ -1320,7 +1226,7 @@ public function getReferenceAtPosition(string $file_path, Position $position): ?
*/
public function getReferenceAtPositionAsReference(
string $file_path,
- Position $position
+ Position $position,
): ?Reference {
$is_open = $this->file_provider->isOpen($file_path);
@@ -1433,7 +1339,7 @@ public function getFunctionArgumentAtPosition(string $file_path, Position $posit
*/
public function getSignatureInformation(
string $function_symbol,
- string $file_path = null
+ string $file_path = null,
): ?SignatureInformation {
$signature_label = '';
$signature_documentation = null;
@@ -1630,7 +1536,7 @@ public function getTypeContextAtPosition(string $file_path, Position $position):
public function getCompletionItemsForClassishThing(
string $type_string,
string $gap,
- bool $snippets_supported = false
+ bool $snippets_supported = false,
): array {
$completion_items = [];
@@ -1746,7 +1652,7 @@ public function getCompletionItemsForClassishThing(
public function getCompletionItemsForPartialSymbol(
string $type_string,
int $offset,
- string $file_path
+ string $file_path,
): array {
$fq_suggestion = false;
@@ -1969,7 +1875,7 @@ public function getCompletionItemsForType(Union $type): array
* @return list
*/
public function getCompletionItemsForArrayKeys(
- string $type_string
+ string $type_string,
): array {
$completion_items = [];
$type = Type::parseString($type_string);
@@ -2034,7 +1940,7 @@ public function removeTemporaryFileChanges(string $file_path): void
*/
public function isTypeContainedByType(
Union $input_type,
- Union $container_type
+ Union $container_type,
): bool {
return UnionTypeComparator::isContainedBy($this, $input_type, $container_type);
}
@@ -2054,7 +1960,7 @@ public function isTypeContainedByType(
*/
public function canTypeBeContainedByType(
Union $input_type,
- Union $container_type
+ Union $container_type,
): bool {
return UnionTypeComparator::canBeContainedBy($this, $input_type, $container_type);
}
@@ -2088,13 +1994,12 @@ public function getKeyValueParamsForTraversableObject(Atomic $type): array
/**
* @param array $phantom_classes
- * @psalm-suppress PossiblyUnusedMethod part of the public API
*/
public function queueClassLikeForScanning(
string $fq_classlike_name,
bool $analyze_too = false,
bool $store_failure = true,
- array $phantom_classes = []
+ array $phantom_classes = [],
): void {
$this->scanner->queueClassLikeForScanning($fq_classlike_name, $analyze_too, $store_failure, $phantom_classes);
}
@@ -2107,7 +2012,7 @@ public function addTaintSource(
Union $expr_type,
string $taint_id,
array $taints = TaintKindGroup::ALL_INPUT,
- ?CodeLocation $code_location = null
+ ?CodeLocation $code_location = null,
): Union {
if (!$this->taint_flow_graph) {
return $expr_type;
@@ -2133,7 +2038,7 @@ public function addTaintSource(
public function addTaintSink(
string $taint_id,
array $taints = TaintKindGroup::ALL_INPUT,
- ?CodeLocation $code_location = null
+ ?CodeLocation $code_location = null,
): void {
if (!$this->taint_flow_graph) {
return;
diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php
index 863e7a6d1df..d86d787c73b 100644
--- a/src/Psalm/Config.php
+++ b/src/Psalm/Config.php
@@ -1,5 +1,7 @@
*/
- public static $ERROR_LEVELS = [
+ public static array $ERROR_LEVELS = [
self::REPORT_INFO,
self::REPORT_ERROR,
self::REPORT_SUPPRESS,
@@ -170,7 +172,7 @@ class Config
*
* @var array
*/
- protected $universal_object_crates;
+ protected array $universal_object_crates;
/**
* @var static|null
@@ -179,74 +181,53 @@ class Config
/**
* Whether or not to use types as defined in docblocks
- *
- * @var bool
*/
- public $use_docblock_types = true;
+ public bool $use_docblock_types = true;
/**
* Whether or not to use types as defined in property docblocks.
* This is distinct from the above because you may want to use
* property docblocks, but not function docblocks.
- *
- * @var bool
*/
- public $use_docblock_property_types = false;
+ public bool $use_docblock_property_types = false;
/**
* Whether using property annotations in docblocks should implicitly seal properties
- *
- * @var bool
*/
- public $docblock_property_types_seal_properties = true;
+ public bool $docblock_property_types_seal_properties = true;
/**
* Whether or not to throw an exception on first error
- *
- * @var bool
*/
- public $throw_exception = false;
+ public bool $throw_exception = false;
/**
* The directory to store PHP Parser (and other) caches
*
* @internal
- * @var string|null
*/
- public $cache_directory;
+ public ?string $cache_directory = null;
private bool $cache_directory_initialized = false;
/**
* The directory to store all Psalm project caches
- *
- * @var string|null
*/
- public $global_cache_directory;
+ public ?string $global_cache_directory = null;
/**
* Path to the autoader
- *
- * @var string|null
*/
- public $autoloader;
+ public ?string $autoloader = null;
- /**
- * @var ProjectFileFilter|null
- */
- protected $project_files;
+ protected ?ProjectFileFilter $project_files = null;
- /**
- * @var ProjectFileFilter|null
- */
- protected $extra_files;
+ protected ?ProjectFileFilter $extra_files = null;
/**
* The base directory of this config file
- *
- * @var string
*/
- public $base_dir;
+ public string $base_dir;
/**
* The PHP version to assume as declared in the config file
@@ -298,230 +279,124 @@ class Config
*/
private array $stub_files = [];
- /**
- * @var bool
- */
- public $hide_external_errors = false;
+ public bool $hide_external_errors = false;
- /**
- * @var bool
- */
- public $hide_all_errors_except_passed_files = false;
+ public bool $hide_all_errors_except_passed_files = false;
- /** @var bool */
- public $allow_includes = true;
+ public bool $allow_includes = true;
/** @var 1|2|3|4|5|6|7|8 */
- public $level = 1;
+ public int $level = 1;
- /**
- * @var ?bool
- */
- public $show_mixed_issues;
+ public ?bool $show_mixed_issues = null;
- /** @var bool */
- public $strict_binary_operands = false;
+ public bool $strict_binary_operands = false;
- /**
- * @var bool
- */
- public $remember_property_assignments_after_call = true;
+ public bool $remember_property_assignments_after_call = true;
- /** @var bool */
- public $use_igbinary = false;
+ public bool $use_igbinary = false;
/** @var 'lz4'|'deflate'|'off' */
- public $compressor = 'off';
+ public string $compressor = 'off';
- /**
- * @var bool
- */
- public $allow_string_standin_for_class = false;
+ public bool $allow_string_standin_for_class = false;
- /**
- * @var bool
- */
- public $disable_suppress_all = false;
+ public bool $disable_suppress_all = false;
- /**
- * @var bool
- */
- public $use_phpdoc_method_without_magic_or_parent = false;
+ public bool $use_phpdoc_method_without_magic_or_parent = false;
- /**
- * @var bool
- */
- public $use_phpdoc_property_without_magic_or_parent = false;
+ public bool $use_phpdoc_property_without_magic_or_parent = false;
- /**
- * @var bool
- */
- public $skip_checks_on_unresolvable_includes = false;
+ public bool $skip_checks_on_unresolvable_includes = false;
- /**
- * @var bool
- */
- public $seal_all_methods = false;
+ public bool $seal_all_methods = false;
- /**
- * @var bool
- */
- public $seal_all_properties = false;
+ public bool $seal_all_properties = false;
- /**
- * @var bool
- */
- public $memoize_method_calls = false;
+ public bool $memoize_method_calls = false;
- /**
- * @var bool
- */
- public $hoist_constants = false;
+ public bool $hoist_constants = false;
- /**
- * @var bool
- */
- public $add_param_default_to_docblock_type = false;
+ public bool $add_param_default_to_docblock_type = false;
- /**
- * @var bool
- */
- public $disable_var_parsing = false;
+ public bool $disable_var_parsing = false;
- /**
- * @var bool
- */
- public $check_for_throws_docblock = false;
+ public bool $check_for_throws_docblock = false;
- /**
- * @var bool
- */
- public $check_for_throws_in_global_scope = false;
+ public bool $check_for_throws_in_global_scope = false;
- /**
- * @var bool
- */
- public $ignore_internal_falsable_issues = false;
+ public bool $ignore_internal_falsable_issues = false;
- /**
- * @var bool
- */
- public $ignore_internal_nullable_issues = false;
+ public bool $ignore_internal_nullable_issues = false;
/**
* @var array
*/
- public $ignored_exceptions = [];
+ public array $ignored_exceptions = [];
/**
* @var array
*/
- public $ignored_exceptions_in_global_scope = [];
+ public array $ignored_exceptions_in_global_scope = [];
/**
* @var array
*/
- public $ignored_exceptions_and_descendants = [];
+ public array $ignored_exceptions_and_descendants = [];
/**
* @var array
*/
- public $ignored_exceptions_and_descendants_in_global_scope = [];
+ public array $ignored_exceptions_and_descendants_in_global_scope = [];
- /**
- * @var bool
- */
- public $infer_property_types_from_constructor = true;
+ public bool $infer_property_types_from_constructor = true;
- /**
- * @var bool
- */
- public $ensure_array_string_offsets_exist = false;
+ public bool $ensure_array_string_offsets_exist = false;
- /**
- * @var bool
- */
- public $ensure_array_int_offsets_exist = false;
+ public bool $ensure_array_int_offsets_exist = false;
/**
* @var array
*/
- public $forbidden_functions = [];
+ public array $forbidden_functions = [];
- /**
- * @var bool
- */
- public $find_unused_code = true;
+ public bool $find_unused_code = true;
- /**
- * @var bool
- */
- public $find_unused_variables = false;
+ public bool $find_unused_variables = false;
- /**
- * @var bool
- */
- public $find_unused_psalm_suppress = false;
+ public bool $find_unused_psalm_suppress = false;
public bool $find_unused_baseline_entry = true;
- /**
- * @var bool
- */
- public $run_taint_analysis = false;
+ public bool $run_taint_analysis = false;
- /** @var bool */
- public $use_phpstorm_meta_path = true;
+ public bool $use_phpstorm_meta_path = true;
- /**
- * @var bool
- */
- public $resolve_from_config_file = true;
+ public bool $resolve_from_config_file = true;
- /**
- * @var bool
- */
- public $restrict_return_types = false;
+ public bool $restrict_return_types = false;
- /**
- * @var bool
- */
- public $limit_method_complexity = false;
+ public bool $limit_method_complexity = false;
- /**
- * @var int
- */
- public $max_graph_size = 200;
+ public int $max_graph_size = 200;
- /**
- * @var int
- */
- public $max_avg_path_length = 70;
+ public int $max_avg_path_length = 70;
- /**
- * @var int
- */
- public $max_shaped_array_size = 100;
+ public int $max_shaped_array_size = 100;
/**
* @var string[]
*/
- public $plugin_paths = [];
+ public array $plugin_paths = [];
/**
* @var array
*/
private array $plugin_classes = [];
- /**
- * @var bool
- */
- public $allow_internal_named_arg_calls = true;
+ public bool $allow_internal_named_arg_calls = true;
- /**
- * @var bool
- */
- public $allow_named_arg_calls = true;
+ public bool $allow_named_arg_calls = true;
/** @var array */
private array $predefined_constants = [];
@@ -531,69 +406,51 @@ class Config
private ?ClassLoader $composer_class_loader = null;
- /**
- * @var string
- */
- public $hash = '';
+ public string $hash = '';
- /** @var string|null */
- public $error_baseline;
+ public ?string $error_baseline = null;
- /**
- * @var bool
- */
- public $include_php_versions_in_error_baseline = false;
+ public bool $include_php_versions_in_error_baseline = false;
/**
- * @var string
* @internal
*/
- public $shepherd_endpoint = 'https://shepherd.dev/hooks/psalm';
+ public string $shepherd_endpoint = 'https://shepherd.dev/hooks/psalm';
/**
* @var array
*/
- public $globals = [];
+ public array $globals = [];
- /**
- * @var int
- */
- public $max_string_length = 1_000;
+ public int $max_string_length = 1_000;
private ?IncludeCollector $include_collector = null;
- /**
- * @var TaintAnalysisFileFilter|null
- */
- protected $taint_analysis_ignored_files;
+ protected ?TaintAnalysisFileFilter $taint_analysis_ignored_files = null;
/**
* @var bool whether to emit a backtrace of emitted issues to stderr
*/
- public $debug_emitted_issues = false;
+ public bool $debug_emitted_issues = false;
private bool $report_info = true;
- /**
- * @var EventDispatcher
- */
- public $eventDispatcher;
+ public EventDispatcher $eventDispatcher;
/** @var list */
- public $config_issues = [];
+ public array $config_issues = [];
/**
* @var 'default'|'never'|'always'
*/
- public $trigger_error_exits = 'default';
+ public string $trigger_error_exits = 'default';
/**
* @var string[]
*/
- public $internal_stubs = [];
+ public array $internal_stubs = [];
- /** @var ?int */
- public $threads;
+ public ?int $threads = null;
/**
* A list of php extensions supported by Psalm.
@@ -606,7 +463,7 @@ class Config
* @psalm-readonly-allow-private-mutation
* @var array
*/
- public $php_extensions = [
+ public array $php_extensions = [
"apcu" => null,
"decimal" => null,
"dom" => null,
@@ -633,7 +490,7 @@ class Config
* @var list
* @readonly
*/
- public $php_extensions_supported_by_psalm_callmaps = [
+ public array $php_extensions_supported_by_psalm_callmaps = [
'apache',
'bcmath',
'bzip2',
@@ -698,7 +555,7 @@ class Config
*
* @var array
*/
- public $php_extensions_not_supported = [];
+ public array $php_extensions_not_supported = [];
/**
* @var array
@@ -814,7 +671,7 @@ public static function loadFromXML(
string $base_dir,
string $file_contents,
?string $current_dir = null,
- ?string $file_path = null
+ ?string $file_path = null,
): Config {
if ($current_dir === null) {
$current_dir = $base_dir;
@@ -930,7 +787,7 @@ private static function processDeprecatedAttribute(
DOMAttr $attribute,
string $file_contents,
self $config,
- string $config_path
+ string $config_path,
): void {
$line = $attribute->getLineNo();
assert($line > 0); // getLineNo() always returns non-zero for nodes loaded from file
@@ -956,7 +813,7 @@ private static function processDeprecatedElement(
DOMElement $deprecated_element_xml,
string $file_contents,
self $config,
- string $config_path
+ string $config_path,
): void {
$line = $deprecated_element_xml->getLineNo();
assert($line > 0);
@@ -982,7 +839,7 @@ private static function processConfigDeprecations(
self $config,
DOMDocument $dom_document,
string $file_contents,
- string $config_path
+ string $config_path,
): void {
$config->config_issues = [];
@@ -1025,7 +882,7 @@ private static function fromXmlAndPaths(
string $base_dir,
string $file_contents,
string $current_dir,
- ?string $config_path
+ ?string $config_path,
): self {
$config = new static();
@@ -1308,8 +1165,7 @@ private static function fromXmlAndPaths(
if (isset($config_xml->universalObjectCrates) && isset($config_xml->universalObjectCrates->class)) {
/** @var SimpleXMLElement $universal_object_crate */
foreach ($config_xml->universalObjectCrates->class as $universal_object_crate) {
- /** @var string $classString */
- $classString = $universal_object_crate['name'];
+ $classString = (string) $universal_object_crate['name'];
$config->addUniversalObjectCrate($classString);
}
}
@@ -1467,7 +1323,7 @@ public function setAdvancedErrorLevel(string $issue_key, array $config, ?string
public function safeSetAdvancedErrorLevel(
string $issue_key,
array $config,
- ?string $default_error_level = null
+ ?string $default_error_level = null,
): void {
if (!isset($this->issue_handlers[$issue_key])) {
$this->setAdvancedErrorLevel($issue_key, $config, $default_error_level);
@@ -2468,10 +2324,7 @@ public function visitComposerAutoloadFiles(ProjectAnalyzer $project_analyzer, ?P
}
}
- /**
- * @return string|false
- */
- public function getComposerFilePathForClassLike(string $fq_classlike_name)
+ public function getComposerFilePathForClassLike(string $fq_classlike_name): string|false
{
if (!$this->composer_class_loader) {
return false;
diff --git a/src/Psalm/Config/Creator.php b/src/Psalm/Config/Creator.php
index 5ab0c14dd88..aa52bee23e1 100644
--- a/src/Psalm/Config/Creator.php
+++ b/src/Psalm/Config/Creator.php
@@ -1,5 +1,7 @@
*/
- protected $directories = [];
+ protected array $directories = [];
/**
* @var array
*/
- protected $files = [];
+ protected array $files = [];
/**
* @var array
*/
- protected $fq_classlike_names = [];
+ protected array $fq_classlike_names = [];
/**
* @var array
*/
- protected $fq_classlike_patterns = [];
+ protected array $fq_classlike_patterns = [];
/**
* @var array
*/
- protected $method_ids = [];
+ protected array $method_ids = [];
/**
* @var array
*/
- protected $property_ids = [];
+ protected array $property_ids = [];
/**
* @var array
*/
- protected $class_constant_ids = [];
+ protected array $class_constant_ids = [];
/**
* @var array
*/
- protected $var_names = [];
+ protected array $var_names = [];
/**
* @var array
*/
- protected $files_lowercase = [];
+ protected array $files_lowercase = [];
- /**
- * @var bool
- */
- protected $inclusive;
+ protected bool $inclusive;
/**
* @var array
*/
- protected $ignore_type_stats = [];
+ protected array $ignore_type_stats = [];
/**
* @var array
*/
- protected $declare_strict_types = [];
+ protected array $declare_strict_types = [];
public function __construct(bool $inclusive)
{
@@ -114,8 +113,8 @@ public function __construct(bool $inclusive)
public static function loadFromArray(
array $config,
string $base_dir,
- bool $inclusive
- ) {
+ bool $inclusive,
+ ): static {
$allow_missing_files = ($config['allowMissingFiles'] ?? false) === true;
$filter = new static($inclusive);
@@ -293,7 +292,11 @@ public static function loadFromArray(
$file_path = (string) realpath($prospective_file_path);
- if (!$file_path && !$allow_missing_files) {
+ if (!$file_path) {
+ if ($allow_missing_files) {
+ continue;
+ }
+
throw new ConfigException(
'Could not resolve config path to ' . $prospective_file_path,
);
@@ -381,14 +384,11 @@ public static function loadFromArray(
return $filter;
}
- /**
- * @return static
- */
public static function loadFromXMLElement(
SimpleXMLElement $e,
string $base_dir,
- bool $inclusive
- ) {
+ bool $inclusive,
+ ): static {
$config = [];
$config['allowMissingFiles'] = ((string) $e['allowMissingFiles']) === 'true';
diff --git a/src/Psalm/Config/IssueHandler.php b/src/Psalm/Config/IssueHandler.php
index ed17b2e35c2..a5af5aefe4b 100644
--- a/src/Psalm/Config/IssueHandler.php
+++ b/src/Psalm/Config/IssueHandler.php
@@ -1,5 +1,7 @@
ignoreFiles)) {
diff --git a/src/Psalm/Config/TaintAnalysisFileFilter.php b/src/Psalm/Config/TaintAnalysisFileFilter.php
index 08b91a886d5..471b2122dc6 100644
--- a/src/Psalm/Config/TaintAnalysisFileFilter.php
+++ b/src/Psalm/Config/TaintAnalysisFileFilter.php
@@ -1,5 +1,7 @@
*/
- public $vars_in_scope = [];
+ public array $vars_in_scope = [];
/**
* @var array
*/
- public $vars_possibly_in_scope = [];
+ public array $vars_possibly_in_scope = [];
/**
* Keeps track of how many times a var_in_scope has been referenced. May not be set for all $vars_in_scope.
*
* @var array>
*/
- public $referenced_counts = [];
+ public array $referenced_counts = [];
/**
* Maps references to referenced variables for the current scope.
@@ -63,21 +65,21 @@ final class Context
*
* @var array
*/
- public $references_in_scope = [];
+ public array $references_in_scope = [];
/**
* Set of references to variables in another scope. These references will be marked as used if they are assigned to.
*
* @var array
*/
- public $references_to_external_scope = [];
+ public array $references_to_external_scope = [];
/**
* A set of globals that are referenced somewhere.
*
* @var array
*/
- public $referenced_globals = [];
+ public array $referenced_globals = [];
/**
* A set of references that might still be in scope from a scope likely to cause confusion. This applies
@@ -86,244 +88,190 @@ final class Context
*
* @var array
*/
- public $references_possibly_from_confusing_scope = [];
+ public array $references_possibly_from_confusing_scope = [];
/**
* Whether or not we're inside the conditional of an if/where etc.
*
* This changes whether or not the context is cloned
- *
- * @var bool
*/
- public $inside_conditional = false;
+ public bool $inside_conditional = false;
/**
* Whether or not we're inside an isset call
*
* Inside issets Psalm is more lenient about certain things
- *
- * @var bool
*/
- public $inside_isset = false;
+ public bool $inside_isset = false;
/**
* Whether or not we're inside an unset call, where
* we don't care about possibly undefined variables
- *
- * @var bool
*/
- public $inside_unset = false;
+ public bool $inside_unset = false;
/**
* Whether or not we're inside an class_exists call, where
* we don't care about possibly undefined classes
- *
- * @var bool
*/
- public $inside_class_exists = false;
+ public bool $inside_class_exists = false;
/**
* Whether or not we're inside a function/method call
- *
- * @var bool
*/
- public $inside_call = false;
+ public bool $inside_call = false;
/**
* Whether or not we're inside any other situation that treats a variable as used
- *
- * @var bool
*/
- public $inside_general_use = false;
+ public bool $inside_general_use = false;
/**
* Whether or not we're inside a return expression
- *
- * @var bool
*/
- public $inside_return = false;
+ public bool $inside_return = false;
/**
* Whether or not we're inside a throw
- *
- * @var bool
*/
- public $inside_throw = false;
+ public bool $inside_throw = false;
/**
* Whether or not we're inside an assignment
- *
- * @var bool
*/
- public $inside_assignment = false;
+ public bool $inside_assignment = false;
/**
* Whether or not we're inside a try block.
- *
- * @var bool
*/
- public $inside_try = false;
+ public bool $inside_try = false;
- /**
- * @var null|CodeLocation
- */
- public $include_location;
+ public ?CodeLocation $include_location = null;
/**
* @var string|null
* The name of the current class. Null if outside a class.
*/
- public $self;
+ public ?string $self = null;
- /**
- * @var string|null
- */
- public $parent;
+ public ?string $parent = null;
- /**
- * @var bool
- */
- public $check_classes = true;
+ public bool $check_classes = true;
- /**
- * @var bool
- */
- public $check_variables = true;
+ public bool $check_variables = true;
- /**
- * @var bool
- */
- public $check_methods = true;
+ public bool $check_methods = true;
- /**
- * @var bool
- */
- public $check_consts = true;
+ public bool $check_consts = true;
- /**
- * @var bool
- */
- public $check_functions = true;
+ public bool $check_functions = true;
/**
* A list of classes checked with class_exists
*
* @var array
*/
- public $phantom_classes = [];
+ public array $phantom_classes = [];
/**
* A list of files checked with file_exists
*
* @var array
*/
- public $phantom_files = [];
+ public array $phantom_files = [];
/**
* A list of clauses in Conjunctive Normal Form
*
* @var list
*/
- public $clauses = [];
+ public array $clauses = [];
/**
* A list of hashed clauses that have already been factored in
*
* @var list
*/
- public $reconciled_expression_clauses = [];
+ public array $reconciled_expression_clauses = [];
/**
* Whether or not to do a deep analysis and collect mutations to this context
- *
- * @var bool
*/
- public $collect_mutations = false;
+ public bool $collect_mutations = false;
/**
* Whether or not to do a deep analysis and collect initializations from private or final methods
- *
- * @var bool
*/
- public $collect_initializations = false;
+ public bool $collect_initializations = false;
/**
* Whether or not to do a deep analysis and collect initializations from public non-final methods
- *
- * @var bool
*/
- public $collect_nonprivate_initializations = false;
+ public bool $collect_nonprivate_initializations = false;
/**
* Stored to prevent re-analysing methods when checking for initialised properties
*
* @var array|null
*/
- public $initialized_methods;
+ public ?array $initialized_methods = null;
/**
* @var array
*/
- public $constants = [];
+ public array $constants = [];
/**
* Whether or not to track exceptions
- *
- * @var bool
*/
- public $collect_exceptions = false;
+ public bool $collect_exceptions = false;
/**
* A list of variables that have been referenced in conditionals
*
* @var array
*/
- public $cond_referenced_var_ids = [];
+ public array $cond_referenced_var_ids = [];
/**
* A list of variables that have been passed by reference (where we know their type)
*
* @var array
*/
- public $byref_constraints = [];
+ public array $byref_constraints = [];
/**
* A list of vars that have been assigned to
*
* @var array
*/
- public $assigned_var_ids = [];
+ public array $assigned_var_ids = [];
/**
* A list of vars that have been may have been assigned to
*
* @var array
*/
- public $possibly_assigned_var_ids = [];
+ public array $possibly_assigned_var_ids = [];
/**
* A list of classes or interfaces that may have been thrown
*
* @var array>
*/
- public $possibly_thrown_exceptions = [];
+ public array $possibly_thrown_exceptions = [];
- /**
- * @var bool
- */
- public $is_global = false;
+ public bool $is_global = false;
/**
* @var array
*/
- public $protected_var_ids = [];
+ public array $protected_var_ids = [];
/**
* If we've branched from the main scope, a byte offset for where that branch happened
- *
- * @var int|null
*/
- public $branch_point;
+ public ?int $branch_point = null;
/**
* What does break mean in this context?
@@ -333,94 +281,55 @@ final class Context
*
* @var list<'loop'|'switch'>
*/
- public $break_types = [];
+ public array $break_types = [];
- /**
- * @var bool
- */
- public $inside_loop = false;
+ public bool $inside_loop = false;
- /**
- * @var LoopScope|null
- */
- public $loop_scope;
+ public ?LoopScope $loop_scope = null;
- /**
- * @var CaseScope|null
- */
- public $case_scope;
+ public ?CaseScope $case_scope = null;
- /**
- * @var FinallyScope|null
- */
- public $finally_scope;
+ public ?FinallyScope $finally_scope = null;
- /**
- * @var Context|null
- */
- public $if_body_context;
+ public ?Context $if_body_context = null;
- /**
- * @var bool
- */
- public $strict_types = false;
+ public bool $strict_types = false;
- /**
- * @var string|null
- */
- public $calling_function_id;
+ public ?string $calling_function_id = null;
/**
* @var lowercase-string|null
*/
- public $calling_method_id;
+ public ?string $calling_method_id = null;
- /**
- * @var bool
- */
- public $inside_negation = false;
+ public bool $inside_negation = false;
- /**
- * @var bool
- */
- public $ignore_variable_property = false;
+ public bool $ignore_variable_property = false;
- /**
- * @var bool
- */
- public $ignore_variable_method = false;
+ public bool $ignore_variable_method = false;
- /**
- * @var bool
- */
- public $pure = false;
+ public bool $pure = false;
/**
* @var bool
* Set by @psalm-immutable
*/
- public $mutation_free = false;
+ public bool $mutation_free = false;
/**
* @var bool
* Set by @psalm-external-mutation-free
*/
- public $external_mutation_free = false;
+ public bool $external_mutation_free = false;
- /**
- * @var bool
- */
- public $error_suppressing = false;
+ public bool $error_suppressing = false;
- /**
- * @var bool
- */
- public $has_returned = false;
+ public bool $has_returned = false;
/**
* @var array
*/
- public $parent_remove_vars = [];
+ public array $parent_remove_vars = [];
/** @internal */
public function __construct(?string $self = null)
@@ -446,7 +355,7 @@ public function update(
Context $end_context,
bool $has_leaving_statements,
array $vars_to_update,
- array &$updated_vars
+ array &$updated_vars,
): void {
foreach ($start_context->vars_in_scope as $var_id => $old_type) {
// this is only true if there was some sort of type negation
@@ -495,7 +404,7 @@ public function update(
*/
public function updateReferencesPossiblyFromConfusingScope(
Context $confusing_scope_context,
- StatementsAnalyzer $statements_analyzer
+ StatementsAnalyzer $statements_analyzer,
): void {
$references = $confusing_scope_context->references_in_scope
+ $confusing_scope_context->references_to_external_scope;
@@ -670,7 +579,7 @@ public static function filterClauses(
string $remove_var_id,
array $clauses,
?Union $new_type = null,
- ?StatementsAnalyzer $statements_analyzer = null
+ ?StatementsAnalyzer $statements_analyzer = null,
): array {
$new_type_string = $new_type ? $new_type->getId() : '';
$clauses_to_keep = [];
@@ -736,7 +645,7 @@ public static function filterClauses(
public function removeVarFromConflictingClauses(
string $remove_var_id,
?Union $new_type = null,
- ?StatementsAnalyzer $statements_analyzer = null
+ ?StatementsAnalyzer $statements_analyzer = null,
): void {
$this->clauses = self::filterClauses($remove_var_id, $this->clauses, $new_type, $statements_analyzer);
$this->parent_remove_vars[$remove_var_id] = true;
@@ -750,7 +659,7 @@ public function removeDescendents(
string $remove_var_id,
Union $existing_type,
?Union $new_type = null,
- ?StatementsAnalyzer $statements_analyzer = null
+ ?StatementsAnalyzer $statements_analyzer = null,
): void {
$this->removeVarFromConflictingClauses(
$remove_var_id,
@@ -929,7 +838,7 @@ public function isSuppressingExceptions(StatementsAnalyzer $statements_analyzer)
public function mergeFunctionExceptions(
FunctionLikeStorage $function_storage,
- CodeLocation $codelocation
+ CodeLocation $codelocation,
): void {
$hash = $codelocation->getHash();
foreach ($function_storage->throws as $possibly_thrown_exception => $_) {
diff --git a/src/Psalm/DocComment.php b/src/Psalm/DocComment.php
index 2a04279f4e6..791f287066c 100644
--- a/src/Psalm/DocComment.php
+++ b/src/Psalm/DocComment.php
@@ -1,5 +1,7 @@
createElement('files');
diff --git a/src/Psalm/Exception/CircularReferenceException.php b/src/Psalm/Exception/CircularReferenceException.php
index 178991f6e9d..51bdf98b31e 100644
--- a/src/Psalm/Exception/CircularReferenceException.php
+++ b/src/Psalm/Exception/CircularReferenceException.php
@@ -1,5 +1,7 @@
start = $start;
$this->end = $end;
diff --git a/src/Psalm/FileSource.php b/src/Psalm/FileSource.php
index fd672862365..0bbd90e89da 100644
--- a/src/Psalm/FileSource.php
+++ b/src/Psalm/FileSource.php
@@ -1,5 +1,7 @@
>> $all_types
@@ -336,7 +338,7 @@ public static function getTruthsFromFormula(
array $clauses,
?int $creating_conditional_id = null,
array &$cond_referenced_var_ids = [],
- array &$active_truths = []
+ array &$active_truths = [],
): array {
$truths = [];
$active_truths = [];
@@ -585,7 +587,7 @@ public static function groupImpossibilities(array $clauses): array
public static function combineOredClauses(
array $left_clauses,
array $right_clauses,
- int $conditional_object_id
+ int $conditional_object_id,
): array {
if (count($left_clauses) > 60_000 || count($right_clauses) > 60_000) {
return [];
diff --git a/src/Psalm/Internal/Algebra/FormulaGenerator.php b/src/Psalm/Internal/Algebra/FormulaGenerator.php
index 9c5482c4a57..e6e42b7b4f9 100644
--- a/src/Psalm/Internal/Algebra/FormulaGenerator.php
+++ b/src/Psalm/Internal/Algebra/FormulaGenerator.php
@@ -1,5 +1,7 @@
@@ -34,7 +36,7 @@ public static function getFormula(
FileSource $source,
?Codebase $codebase = null,
bool $inside_negation = false,
- bool $cache = true
+ bool $cache = true,
): array {
if ($conditional instanceof PhpParser\Node\Expr\BinaryOp\BooleanAnd ||
$conditional instanceof PhpParser\Node\Expr\BinaryOp\LogicalAnd
diff --git a/src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php b/src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php
index 6fc52514aa3..71f22863d2d 100644
--- a/src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php
@@ -1,5 +1,7 @@
'class',
@@ -66,7 +68,7 @@ public static function analyze(
HasAttributesInterface $storage,
array $attribute_groups,
int $target,
- array $suppressed_issues
+ array $suppressed_issues,
): void {
$codebase = $source->getCodebase();
$appearing_non_repeatable_attributes = [];
@@ -138,7 +140,7 @@ private static function analyzeAttributeConstruction(
string $fq_attribute_name,
Attribute $attribute,
array $suppressed_issues,
- ?ClassLikeStorage $classlike_storage = null
+ ?ClassLikeStorage $classlike_storage = null,
): void {
$attribute_name_location = new CodeLocation($source, $attribute->name);
@@ -244,7 +246,7 @@ private static function getAttributeClassFlags(
string $fq_attribute_name,
CodeLocation $attribute_name_location,
?ClassLikeStorage $attribute_class_storage,
- array $suppressed_issues
+ array $suppressed_issues,
): int {
if (strtolower($fq_attribute_name) === "attribute") {
// We override this here because we still want to analyze attributes
@@ -316,7 +318,7 @@ private static function iterateAttributeNodes(iterable $attribute_groups): Gener
public static function analyzeGetAttributes(
StatementsAnalyzer $statements_analyzer,
string $method_id,
- array $args
+ array $args,
): void {
if (count($args) !== 1) {
// We skip this analysis if $flags is specified on getAttributes, since the only option
diff --git a/src/Psalm/Internal/Analyzer/CanAlias.php b/src/Psalm/Internal/Analyzer/CanAlias.php
index 3be3d60d7bd..32bddf3a17b 100644
--- a/src/Psalm/Internal/Analyzer/CanAlias.php
+++ b/src/Psalm/Internal/Analyzer/CanAlias.php
@@ -1,5 +1,7 @@
@@ -145,7 +147,7 @@ public static function getAnonymousClassName(PhpParser\Node\Stmt\Class_ $class,
public function analyze(
?Context $class_context = null,
- ?Context $global_context = null
+ ?Context $global_context = null,
): void {
$class = $this->class;
@@ -688,7 +690,7 @@ public static function addContextProperties(
Context $class_context,
string $fq_class_name,
?string $parent_fq_class_name,
- array $stmts = []
+ array $stmts = [],
): void {
$codebase = $statements_source->getCodebase();
@@ -1017,7 +1019,7 @@ private function checkPropertyInitialization(
ClassLikeStorage $storage,
Context $class_context,
?Context $global_context = null,
- ?MethodAnalyzer $constructor_analyzer = null
+ ?MethodAnalyzer $constructor_analyzer = null,
): void {
if (!$config->reportIssueInFile('PropertyNotSetInConstructor', $this->getFilePath())) {
return;
@@ -1380,7 +1382,7 @@ private function analyzeTraitUse(
Context $class_context,
?Context $global_context = null,
?MethodAnalyzer &$constructor_analyzer = null,
- ?TraitAnalyzer $previous_trait_analyzer = null
+ ?TraitAnalyzer $previous_trait_analyzer = null,
): ?bool {
$codebase = $this->getCodebase();
@@ -1532,7 +1534,7 @@ private function analyzeTraitUse(
private function analyzeProperty(
SourceAnalyzer $source,
PhpParser\Node\Stmt\Property $stmt,
- Context $context
+ Context $context,
): void {
$fq_class_name = $source->getFQCLN();
$property_name = $stmt->props[0]->name->name;
@@ -1634,7 +1636,7 @@ private static function addOrUpdatePropertyType(
PhpParser\Node\Stmt\Property $property,
Union $inferred_type,
StatementsSource $source,
- bool $docblock_only = false
+ bool $docblock_only = false,
): void {
$manipulator = PropertyDocblockManipulator::getForProperty(
$project_analyzer,
@@ -1678,7 +1680,7 @@ private function analyzeClassMethod(
SourceAnalyzer $source,
Context $class_context,
?Context $global_context = null,
- bool $is_fake = false
+ bool $is_fake = false,
): ?MethodAnalyzer {
$config = Config::getInstance();
@@ -1853,7 +1855,7 @@ private function analyzeClassMethod(
private static function getThisObjectType(
ClassLikeStorage $class_storage,
- string $original_fq_classlike_name
+ string $original_fq_classlike_name,
): TNamedObject {
if ($class_storage->template_types) {
$template_params = [];
@@ -1889,7 +1891,7 @@ public static function analyzeClassMethodReturnType(
string $fq_classlike_name,
MethodIdentifier $analyzed_method_id,
MethodIdentifier $actual_method_id,
- bool $did_explicitly_return
+ bool $did_explicitly_return,
): void {
$secondary_return_type_location = null;
@@ -2017,7 +2019,7 @@ private function checkImplementedInterfaces(
PhpParser\Node\Stmt $class,
Codebase $codebase,
string $fq_class_name,
- ClassLikeStorage $storage
+ ClassLikeStorage $storage,
): bool {
$classlike_storage_provider = $codebase->classlike_storage_provider;
@@ -2320,7 +2322,7 @@ private function checkParentClass(
string $parent_fq_class_name,
ClassLikeStorage $storage,
Codebase $codebase,
- ?Context $class_context
+ ?Context $class_context,
): void {
$classlike_storage_provider = $codebase->classlike_storage_provider;
diff --git a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php
index 91b2cc9a23b..cf54d72c3ab 100644
--- a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php
@@ -1,5 +1,7 @@
getFileAnalyzer()->project_analyzer;
$codebase = $project_analyzer->getCodebase();
@@ -203,7 +205,7 @@ public static function checkFullyQualifiedClassLikeName(
?string $calling_fq_class_name,
?string $calling_method_id,
array $suppressed_issues,
- ?ClassLikeNameOptions $options = null
+ ?ClassLikeNameOptions $options = null,
): ?bool {
if ($options === null) {
$options = new ClassLikeNameOptions();
@@ -391,7 +393,7 @@ public static function checkFullyQualifiedClassLikeName(
*/
public static function getFQCLNFromNameObject(
PhpParser\Node\Name $class_name,
- Aliases $aliases
+ Aliases $aliases,
): string {
/** @var string|null */
$resolved_name = $class_name->getAttribute('resolvedName');
@@ -475,10 +477,8 @@ public function isStatic(): bool
/**
* Gets the Psalm type from a particular value
- *
- * @param mixed $value
*/
- public static function getTypeFromValue($value): Union
+ public static function getTypeFromValue(mixed $value): Union
{
switch (gettype($value)) {
case 'boolean':
@@ -517,7 +517,7 @@ public static function checkPropertyVisibility(
SourceAnalyzer $source,
CodeLocation $code_location,
array $suppressed_issues,
- bool $emit_issues = true
+ bool $emit_issues = true,
): ?bool {
[$fq_class_name, $property_name] = explode('::$', $property_id);
@@ -630,7 +630,7 @@ protected function checkTemplateParams(
ClassLikeStorage $storage,
ClassLikeStorage $parent_storage,
CodeLocation $code_location,
- int $given_param_count
+ int $given_param_count,
): void {
$expected_param_count = $parent_storage->template_types === null
? 0
diff --git a/src/Psalm/Internal/Analyzer/ClassLikeNameOptions.php b/src/Psalm/Internal/Analyzer/ClassLikeNameOptions.php
index 60f61a9e87d..d1fb0c95218 100644
--- a/src/Psalm/Internal/Analyzer/ClassLikeNameOptions.php
+++ b/src/Psalm/Internal/Analyzer/ClassLikeNameOptions.php
@@ -1,11 +1,13 @@
inferred = $inferred;
$this->allow_trait = $allow_trait;
diff --git a/src/Psalm/Internal/Analyzer/ClosureAnalyzer.php b/src/Psalm/Internal/Analyzer/ClosureAnalyzer.php
index c5daf4f5ea6..34cd81bc0fb 100644
--- a/src/Psalm/Internal/Analyzer/ClosureAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/ClosureAnalyzer.php
@@ -1,5 +1,7 @@
*/
-class ClosureAnalyzer extends FunctionLikeAnalyzer
+final class ClosureAnalyzer extends FunctionLikeAnalyzer
{
/**
* @param PhpParser\Node\Expr\Closure|PhpParser\Node\Expr\ArrowFunction $function
@@ -70,7 +72,7 @@ public function getClosureId(): string
public static function analyzeExpression(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\FunctionLike $stmt,
- Context $context
+ Context $context,
): bool {
$closure_analyzer = new ClosureAnalyzer($stmt, $statements_analyzer);
@@ -232,7 +234,7 @@ public static function analyzeExpression(
public static function analyzeClosureUses(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr\Closure $stmt,
- Context $context
+ Context $context,
): ?bool {
$param_names = [];
diff --git a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php
index 27b78a59e2e..aabd1747028 100644
--- a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php
@@ -1,5 +1,7 @@
\[\]\-\{\}:|?\\\\]*|\$[a-zA-Z_0-9_]+)';
@@ -57,7 +59,7 @@ public static function getTypeFromComment(
FileSource $source,
Aliases $aliases,
?array $template_type_map = null,
- ?array $type_aliases = null
+ ?array $type_aliases = null,
): array {
$parsed_docblock = DocComment::parsePreservingLength($comment);
@@ -83,7 +85,7 @@ public static function arrayToDocblocks(
FileSource $source,
Aliases $aliases,
?array $template_type_map = null,
- ?array $type_aliases = null
+ ?array $type_aliases = null,
): array {
$var_id = null;
@@ -218,7 +220,7 @@ public static function arrayToDocblocks(
private static function decorateVarDocblockComment(
VarDocblockComment $var_comment,
- ParsedDocblock $parsed_docblock
+ ParsedDocblock $parsed_docblock,
): void {
$var_comment->deprecated = isset($parsed_docblock->tags['deprecated']);
$var_comment->internal = isset($parsed_docblock->tags['internal']);
@@ -418,7 +420,7 @@ public static function splitDocLine(string $return_block): array
public static function getVarComments(
PhpParser\Comment\Doc $doc_comment,
StatementsAnalyzer $statements_analyzer,
- PhpParser\Node\Expr\Variable $var
+ PhpParser\Node\Expr\Variable $var,
): array {
$codebase = $statements_analyzer->getCodebase();
$parsed_docblock = $statements_analyzer->getParsedDocblock();
@@ -465,7 +467,7 @@ public static function populateVarTypesFromDocblock(
array $var_comments,
PhpParser\Node\Expr\Variable $var,
Context $context,
- StatementsAnalyzer $statements_analyzer
+ StatementsAnalyzer $statements_analyzer,
): ?Union {
if (!is_string($var->name)) {
return null;
diff --git a/src/Psalm/Internal/Analyzer/DataFlowNodeData.php b/src/Psalm/Internal/Analyzer/DataFlowNodeData.php
index bc4f2dbf533..7f2e989a547 100644
--- a/src/Psalm/Internal/Analyzer/DataFlowNodeData.php
+++ b/src/Psalm/Internal/Analyzer/DataFlowNodeData.php
@@ -1,5 +1,7 @@
label = $label;
$this->line_from = $line_from;
diff --git a/src/Psalm/Internal/Analyzer/FileAnalyzer.php b/src/Psalm/Internal/Analyzer/FileAnalyzer.php
index d9879558922..832bfecb59e 100644
--- a/src/Psalm/Internal/Analyzer/FileAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/FileAnalyzer.php
@@ -1,5 +1,7 @@
project_analyzer->getCodebase();
@@ -363,7 +365,7 @@ public function addNamespacedInterfaceAnalyzer(string $fq_class_name, InterfaceA
public function getMethodMutations(
MethodIdentifier $method_id,
Context $this_context,
- bool $from_project_analyzer = false
+ bool $from_project_analyzer = false,
): void {
$fq_class_name = $method_id->fq_class_name;
$method_name = $method_id->method_name;
diff --git a/src/Psalm/Internal/Analyzer/FunctionAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionAnalyzer.php
index f22e09cf29f..bcf1395909a 100644
--- a/src/Psalm/Internal/Analyzer/FunctionAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/FunctionAnalyzer.php
@@ -1,5 +1,7 @@
*/
-class FunctionAnalyzer extends FunctionLikeAnalyzer
+final class FunctionAnalyzer extends FunctionLikeAnalyzer
{
public function __construct(PhpParser\Node\Stmt\Function_ $function, SourceAnalyzer $source)
{
@@ -54,7 +56,7 @@ public function getFunctionId(): string
public static function analyzeStatement(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Stmt\Function_ $stmt,
- Context $context
+ Context $context,
): void {
foreach ($stmt->stmts as $function_stmt) {
if ($function_stmt instanceof PhpParser\Node\Stmt\Global_) {
diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php
index 5cfd1b17664..bc571e03548 100644
--- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php
@@ -1,5 +1,7 @@
getSuppressedIssues();
$codebase = $source->getCodebase();
@@ -830,7 +832,7 @@ public static function checkReturnType(
ProjectAnalyzer $project_analyzer,
FunctionLikeAnalyzer $function_like_analyzer,
FunctionLikeStorage $storage,
- Context $context
+ Context $context,
): ?bool {
$codebase = $project_analyzer->getCodebase();
@@ -1026,7 +1028,7 @@ private static function addOrUpdateReturnType(
Union $inferred_return_type,
StatementsSource $source,
bool $docblock_only = false,
- ?FunctionLikeStorage $function_like_storage = null
+ ?FunctionLikeStorage $function_like_storage = null,
): void {
$manipulator = FunctionDocblockManipulator::getForFunction(
$project_analyzer,
diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php
index c707048d1c6..21e9d22d1c4 100644
--- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php
+++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php
@@ -1,5 +1,7 @@
storage;
@@ -872,7 +874,7 @@ private function checkParamReferences(
StatementsAnalyzer $statements_analyzer,
FunctionLikeStorage $storage,
?ClassLikeStorage $class_storage,
- Context $context
+ Context $context,
): void {
$codebase = $statements_analyzer->getCodebase();
@@ -973,7 +975,7 @@ private function processParams(
array $params,
array $param_stmts,
Context $context,
- bool $has_template_types
+ bool $has_template_types,
): bool {
$check_stmts = true;
$codebase = $statements_analyzer->getCodebase();
@@ -1318,7 +1320,7 @@ private function alterParams(
Codebase $codebase,
FunctionLikeStorage $storage,
array $params,
- Context $context
+ Context $context,
): void {
foreach ($this->function->params as $param) {
$param_name_node = null;
@@ -1446,7 +1448,7 @@ public function verifyReturnType(
?string $fq_class_name = null,
?CodeLocation $return_type_location = null,
bool $did_explicitly_return = false,
- bool $closure_inside_call = false
+ bool $closure_inside_call = false,
): void {
ReturnTypeAnalyzer::verifyReturnType(
$this->function,
@@ -1468,7 +1470,7 @@ public function addOrUpdateParamType(
ProjectAnalyzer $project_analyzer,
string $param_name,
Union $inferred_return_type,
- bool $docblock_only = false
+ bool $docblock_only = false,
): void {
$manipulator = FunctionDocblockManipulator::getForFunction(
$project_analyzer,
@@ -1545,7 +1547,7 @@ public function examineParamTypes(
StatementsAnalyzer $statements_analyzer,
Context $context,
Codebase $codebase,
- PhpParser\Node $stmt = null
+ PhpParser\Node $stmt = null,
): void {
$storage = $this->getFunctionLikeStorage($statements_analyzer);
@@ -1801,7 +1803,7 @@ private function getFunctionInformation(
Codebase $codebase,
NodeDataProvider $type_provider,
FunctionLikeStorage $storage,
- bool $add_mutations
+ bool $add_mutations,
): ?array {
$classlike_storage_provider = $codebase->classlike_storage_provider;
$real_method_id = null;
@@ -2048,7 +2050,7 @@ private function getFunctionInformation(
private function detectUnusedParameters(
StatementsAnalyzer $statements_analyzer,
FunctionLikeStorage $storage,
- Context $context
+ Context $context,
): array {
$codebase = $statements_analyzer->getCodebase();
diff --git a/src/Psalm/Internal/Analyzer/InterfaceAnalyzer.php b/src/Psalm/Internal/Analyzer/InterfaceAnalyzer.php
index c1f8ed6b4e5..fc798e4433e 100644
--- a/src/Psalm/Internal/Analyzer/InterfaceAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/InterfaceAnalyzer.php
@@ -1,5 +1,7 @@
severity = $severity;
$this->line_from = $line_from;
diff --git a/src/Psalm/Internal/Analyzer/MethodAnalyzer.php b/src/Psalm/Internal/Analyzer/MethodAnalyzer.php
index 89af7aaec71..3758cd06bef 100644
--- a/src/Psalm/Internal/Analyzer/MethodAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/MethodAnalyzer.php
@@ -1,5 +1,7 @@
*/
-class MethodAnalyzer extends FunctionLikeAnalyzer
+final class MethodAnalyzer extends FunctionLikeAnalyzer
{
// https://github.com/php/php-src/blob/a83923044c48982c80804ae1b45e761c271966d3/Zend/zend_enum.c#L77-L95
private const FORBIDDEN_ENUM_METHODS = [
@@ -51,7 +53,7 @@ class MethodAnalyzer extends FunctionLikeAnalyzer
public function __construct(
PhpParser\Node\Stmt\ClassMethod $function,
SourceAnalyzer $source,
- ?MethodStorage $storage = null
+ ?MethodStorage $storage = null,
) {
$codebase = $source->getCodebase();
@@ -99,7 +101,7 @@ public static function checkStatic(
Codebase $codebase,
CodeLocation $code_location,
array $suppressed_issues,
- ?bool &$is_dynamic_this_method = false
+ ?bool &$is_dynamic_this_method = false,
): void {
$codebase_methods = $codebase->methods;
@@ -165,7 +167,7 @@ public static function checkMethodExists(
MethodIdentifier $method_id,
CodeLocation $code_location,
array $suppressed_issues,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): ?bool {
if ($codebase->methods->methodExists(
$method_id,
@@ -193,7 +195,7 @@ public static function checkMethodExists(
public static function isMethodVisible(
MethodIdentifier $method_id,
Context $context,
- StatementsSource $source
+ StatementsSource $source,
): bool {
$codebase = $source->getCodebase();
@@ -278,7 +280,7 @@ public static function isMethodVisible(
*/
public static function checkMethodSignatureMustOmitReturnType(
MethodStorage $method_storage,
- CodeLocation $code_location
+ CodeLocation $code_location,
): void {
if ($method_storage->signature_return_type === null) {
return;
diff --git a/src/Psalm/Internal/Analyzer/MethodComparator.php b/src/Psalm/Internal/Analyzer/MethodComparator.php
index 82e1c6c4863..1a4b01f5fbd 100644
--- a/src/Psalm/Internal/Analyzer/MethodComparator.php
+++ b/src/Psalm/Internal/Analyzer/MethodComparator.php
@@ -1,5 +1,7 @@
name,
@@ -252,7 +254,7 @@ private static function checkForObviousMethodMismatches(
bool $prevent_abstract_override,
bool $trait_mismatches_are_fatal,
CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): void {
if ($implementer_visibility > $guide_visibility) {
if ($trait_mismatches_are_fatal
@@ -349,7 +351,7 @@ private static function compareMethodParams(
string $cased_implementer_method_id,
bool $prevent_method_signature_mismatch,
CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): void {
if ($prevent_method_signature_mismatch) {
if (!$guide_classlike_storage->user_defined
@@ -557,7 +559,7 @@ private static function compareMethodSignatureParams(
string $cased_guide_method_id,
string $cased_implementer_method_id,
CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): void {
$guide_param_signature_type = $guide_param->signature_type
? TypeExpander::expandUnion(
@@ -677,7 +679,7 @@ private static function compareMethodDocblockParams(
Union $guide_param_type,
Union $implementer_param_type,
CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): void {
$implementer_method_storage_param_type = TypeExpander::expandUnion(
$codebase,
@@ -843,7 +845,7 @@ private static function compareMethodSignatureReturnTypes(
string $implementer_called_class_name,
string $cased_implementer_method_id,
CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): void {
$guide_signature_return_type = TypeExpander::expandUnion(
$codebase,
@@ -930,7 +932,7 @@ private static function compareMethodDocblockReturnTypes(
string $implementer_called_class_name,
?MethodIdentifier $implementer_declaring_method_id,
CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): void {
$implementer_method_storage_return_type = TypeExpander::expandUnion(
$codebase,
@@ -1055,7 +1057,7 @@ private static function transformTemplates(
array $template_extended_params,
string $base_class_name,
Union &$templated_type,
- Codebase $codebase
+ Codebase $codebase,
): void {
if (isset($template_extended_params[$base_class_name])) {
$map = $template_extended_params[$base_class_name];
diff --git a/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php b/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php
index c76b8a12057..6974a4c45e9 100644
--- a/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php
@@ -1,5 +1,7 @@
codebase->alter_code = true;
$this->codebase->infer_types_from_usage = true;
@@ -1273,7 +1275,7 @@ public function getMethodMutations(
MethodIdentifier $original_method_id,
Context $this_context,
string $root_file_path,
- string $root_file_name
+ string $root_file_name,
): void {
$fq_class_name = $original_method_id->fq_class_name;
@@ -1320,7 +1322,7 @@ public function getMethodMutations(
public function getFunctionLikeAnalyzer(
MethodIdentifier $method_id,
- string $file_path
+ string $file_path,
): ?FunctionLikeAnalyzer {
$file_analyzer = new FileAnalyzer(
$this,
diff --git a/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php b/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php
index 4b8946623b5..bca1b1aa895 100644
--- a/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php
@@ -1,5 +1,7 @@
break_types[] = 'loop';
@@ -172,7 +174,7 @@ private static function analyzeDoNaively(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Stmt\Do_ $stmt,
Context $context,
- LoopScope $loop_scope
+ LoopScope $loop_scope,
): void {
$do_context = clone $context;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/ForAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/ForAnalyzer.php
index 4c0dd4ee16f..ad1b5a601de 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/ForAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/ForAnalyzer.php
@@ -1,5 +1,7 @@
assigned_var_ids;
$context->assigned_var_ids = [];
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php
index 263f445af7e..54fd5391bcd 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php
@@ -1,5 +1,7 @@
isNull()) {
IssueBuffer::maybeAdd(
@@ -727,7 +729,7 @@ public static function handleIterable(
Context $context,
?Union &$key_type,
?Union &$value_type,
- bool &$has_valid_iterator
+ bool &$has_valid_iterator,
): void {
if ($iterator_atomic_type->extra_types) {
$iterator_atomic_types = array_merge(
@@ -950,7 +952,7 @@ public static function getKeyValueParamsForTraversableObject(
Atomic $iterator_atomic_type,
Codebase $codebase,
?Union &$key_type,
- ?Union &$value_type
+ ?Union &$value_type,
): void {
if ($iterator_atomic_type instanceof TIterable
|| ($iterator_atomic_type instanceof TGenericObject
@@ -1027,7 +1029,7 @@ private static function getFakeMethodCallType(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr $foreach_expr,
Context $context,
- string $method_name
+ string $method_name,
): ?Union {
$old_data_provider = $statements_analyzer->node_data;
@@ -1086,7 +1088,7 @@ private static function getExtendedType(
string $calling_class,
array $template_extended_params,
?array $class_template_types = null,
- ?array $calling_type_params = null
+ ?array $calling_type_params = null,
): ?Union {
if ($calling_class === $template_class) {
if (isset($class_template_types[$template_name]) && $calling_type_params) {
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php
index e1c5e5e4024..843bbbce0de 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php
@@ -1,5 +1,7 @@
node_data->getType($stmt);
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseAnalyzer.php
index 31fca6dc0f7..f33293ca9bc 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php
index f55d1d0a63e..4a7769247b2 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php
@@ -1,5 +1,7 @@
$pre_assignment_else_redefined_vars
@@ -59,7 +61,7 @@ public static function analyze(
IfConditionalScope $if_conditional_scope,
Context $if_context,
Context $outer_context,
- array $pre_assignment_else_redefined_vars
+ array $pre_assignment_else_redefined_vars,
): ?bool {
$cond_referenced_var_ids = $if_conditional_scope->cond_referenced_var_ids;
@@ -336,7 +338,7 @@ public static function addConditionallyAssignedVarsToContext(
PhpParser\Node\Expr $cond,
Context $post_leaving_if_context,
Context $post_if_context,
- array $assigned_in_conditional_var_ids
+ array $assigned_in_conditional_var_ids,
): void {
// this filters out coercions to expected types in ArgumentAnalyzer
$assigned_in_conditional_var_ids = array_filter($assigned_in_conditional_var_ids);
@@ -440,7 +442,7 @@ public static function updateIfScope(
array $assigned_var_ids,
array $possibly_assigned_var_ids,
array $newly_reconciled_var_ids,
- bool $update_new_vars = true
+ bool $update_new_vars = true,
): void {
$redefined_vars = $if_context->getRedefinedVars($outer_context->vars_in_scope);
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php
index a5a006a0b31..273842a3722 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php
index f1f5ad61fca..c3a7648aafc 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php
@@ -1,5 +1,7 @@
final_actions, true)) {
$loop_context->vars_in_scope = $pre_outer_context->vars_in_scope;
@@ -570,7 +572,7 @@ private static function applyPreConditionToLoopContext(
array $pre_condition_clauses,
Context $loop_context,
Context $outer_context,
- bool $is_do
+ bool $is_do,
): array {
$pre_referenced_var_ids = $loop_context->cond_referenced_var_ids;
$loop_context->cond_referenced_var_ids = [];
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchAnalyzer.php
index a0d9d48200c..e5dfacd83d7 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php
index e116f1173f7..7e1dbdd3da0 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php
@@ -1,5 +1,7 @@
cond
&& $switch_var_id
@@ -653,7 +655,7 @@ private static function handleNonReturningCase(
private static function simplifyCaseEqualityExpression(
PhpParser\Node\Expr $case_equality_expr,
- PhpParser\Node\Expr\Variable $var
+ PhpParser\Node\Expr\Variable $var,
): ?PhpParser\Node\Expr\FuncCall {
if ($case_equality_expr instanceof PhpParser\Node\Expr\BinaryOp\BooleanOr) {
$nested_or_options = self::getOptionsFromNestedOr($case_equality_expr, $var);
@@ -697,7 +699,7 @@ private static function simplifyCaseEqualityExpression(
private static function getOptionsFromNestedOr(
PhpParser\Node\Expr $case_equality_expr,
PhpParser\Node\Expr\Variable $var,
- array $in_array_values = []
+ array $in_array_values = [],
): ?array {
if ($case_equality_expr instanceof PhpParser\Node\Expr\BinaryOp\Identical
&& $case_equality_expr->left instanceof PhpParser\Node\Expr\Variable
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php
index 18536b49394..9222f3109a7 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php
@@ -1,5 +1,7 @@
cond instanceof PhpParser\Node\Expr\ConstFetch
&& $stmt->cond->name->getParts() === ['true'])
@@ -121,7 +123,7 @@ public static function analyze(
* @return list
*/
public static function getAndExpressions(
- PhpParser\Node\Expr $expr
+ PhpParser\Node\Expr $expr,
): array {
if ($expr instanceof PhpParser\Node\Expr\BinaryOp\BooleanAnd) {
return [...self::getAndExpressions($expr->left), ...self::getAndExpressions($expr->right)];
diff --git a/src/Psalm/Internal/Analyzer/Statements/BreakAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/BreakAnalyzer.php
index cbf9be6c0ea..330918a9559 100644
--- a/src/Psalm/Internal/Analyzer/Statements/BreakAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/BreakAnalyzer.php
@@ -1,5 +1,7 @@
loop_scope;
diff --git a/src/Psalm/Internal/Analyzer/Statements/ContinueAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ContinueAnalyzer.php
index 9e04d165440..b5b0de71f9f 100644
--- a/src/Psalm/Internal/Analyzer/Statements/ContinueAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/ContinueAnalyzer.php
@@ -1,5 +1,7 @@
num instanceof PhpParser\Node\Scalar\LNumber? $stmt->num->value : 1;
diff --git a/src/Psalm/Internal/Analyzer/Statements/DeclareAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/DeclareAnalyzer.php
index fed7eb3e1f1..2eb42eb876b 100644
--- a/src/Psalm/Internal/Analyzer/Statements/DeclareAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/DeclareAnalyzer.php
@@ -1,5 +1,7 @@
declares as $declaration) {
$declaration_key = (string) $declaration->key;
@@ -55,7 +57,7 @@ public static function analyze(
private static function analyzeStrictTypesDeclaration(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Stmt\DeclareDeclare $declaration,
- Context $context
+ Context $context,
): void {
if (!$declaration->value instanceof PhpParser\Node\Scalar\LNumber
|| !in_array($declaration->value->value, [0, 1], true)
@@ -78,7 +80,7 @@ private static function analyzeStrictTypesDeclaration(
private static function analyzeTicksDeclaration(
StatementsAnalyzer $statements_analyzer,
- PhpParser\Node\Stmt\DeclareDeclare $declaration
+ PhpParser\Node\Stmt\DeclareDeclare $declaration,
): void {
if (!$declaration->value instanceof PhpParser\Node\Scalar\LNumber) {
IssueBuffer::maybeAdd(
@@ -93,7 +95,7 @@ private static function analyzeTicksDeclaration(
private static function analyzeEncodingDeclaration(
StatementsAnalyzer $statements_analyzer,
- PhpParser\Node\Stmt\DeclareDeclare $declaration
+ PhpParser\Node\Stmt\DeclareDeclare $declaration,
): void {
if (!$declaration->value instanceof PhpParser\Node\Scalar\String_) {
IssueBuffer::maybeAdd(
diff --git a/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php
index 300b8fe02aa..f04d8c131e8 100644
--- a/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php
@@ -1,5 +1,7 @@
items) === 0) {
@@ -241,7 +243,7 @@ private static function analyzeArrayItem(
Context $context,
ArrayCreationInfo $array_creation_info,
PhpParser\Node\Expr\ArrayItem $item,
- Codebase $codebase
+ Codebase $codebase,
): void {
if ($item->unpack) {
if (ExpressionAnalyzer::analyze($statements_analyzer, $item->value, $context) === false) {
@@ -519,7 +521,7 @@ private static function handleUnpackedArray(
ArrayCreationInfo $array_creation_info,
PhpParser\Node\Expr\ArrayItem $item,
Union $unpacked_array_type,
- Codebase $codebase
+ Codebase $codebase,
): void {
$all_non_empty = true;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayCreationInfo.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayCreationInfo.php
index 43161d22f3b..f96db30833b 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayCreationInfo.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayCreationInfo.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php
index 0c37cd0a7ff..16ea3e83561 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php
@@ -1,5 +1,7 @@
0) will be turned into an assertion to make psalm understand that in the
* if block, $a is a positive-int
*/
-class AssertionFinder
+final class AssertionFinder
{
public const ASSIGNMENT_TO_RIGHT = 1;
public const ASSIGNMENT_TO_LEFT = -1;
@@ -136,7 +138,7 @@ public static function scrapeAssertions(
?Codebase $codebase = null,
bool $inside_negation = false,
bool $cache = true,
- bool $inside_conditional = true
+ bool $inside_conditional = true,
): array {
$if_types = [];
@@ -367,7 +369,7 @@ private static function scrapeEqualityAssertions(
FileSource $source,
?Codebase $codebase = null,
bool $cache = true,
- bool $inside_conditional = true
+ bool $inside_conditional = true,
): array {
$null_position = self::hasNullVariable($conditional, $source);
@@ -588,7 +590,7 @@ private static function scrapeInequalityAssertions(
FileSource $source,
?Codebase $codebase = null,
bool $cache = true,
- bool $inside_conditional = true
+ bool $inside_conditional = true,
): array {
$null_position = self::hasNullVariable($conditional, $source);
@@ -754,7 +756,7 @@ public static function processFunctionCall(
?string $this_class_name,
FileSource $source,
?Codebase $codebase = null,
- bool $negate = false
+ bool $negate = false,
): array {
$first_var_name = isset($expr->getArgs()[0]->value)
? ExpressionIdentifier::getExtendedVarId(
@@ -863,7 +865,7 @@ private static function processIrreconcilableFunctionCall(
PhpParser\Node\Expr $expr,
StatementsAnalyzer $source,
Codebase $codebase,
- bool $negate
+ bool $negate,
): void {
if ($first_var_type->hasMixed()) {
return;
@@ -927,7 +929,7 @@ private static function processIrreconcilableFunctionCall(
protected static function processCustomAssertion(
PhpParser\Node\Expr $expr,
?string $this_class_name,
- FileSource $source
+ FileSource $source,
): array {
if (!$source instanceof StatementsAnalyzer) {
return [];
@@ -1229,7 +1231,7 @@ protected static function processCustomAssertion(
protected static function getInstanceOfAssertions(
PhpParser\Node\Expr\Instanceof_ $stmt,
?string $this_class_name,
- FileSource $source
+ FileSource $source,
): array {
if ($stmt->class instanceof PhpParser\Node\Name) {
if (!in_array(strtolower($stmt->class->getFirst()), ['self', 'static', 'parent'], true)) {
@@ -1293,7 +1295,7 @@ protected static function getInstanceOfAssertions(
*/
protected static function hasNullVariable(
PhpParser\Node\Expr\BinaryOp $conditional,
- FileSource $source
+ FileSource $source,
): ?int {
if ($conditional->right instanceof PhpParser\Node\Expr\ConstFetch
&& strtolower($conditional->right->name->getFirst()) === 'null'
@@ -1321,7 +1323,7 @@ protected static function hasNullVariable(
* @param Identical|Equal|NotIdentical|NotEqual $conditional
*/
public static function hasFalseVariable(
- PhpParser\Node\Expr\BinaryOp $conditional
+ PhpParser\Node\Expr\BinaryOp $conditional,
): ?int {
if ($conditional->right instanceof PhpParser\Node\Expr\ConstFetch
&& strtolower($conditional->right->name->getFirst()) === 'false'
@@ -1342,7 +1344,7 @@ public static function hasFalseVariable(
* @param Identical|Equal|NotIdentical|NotEqual $conditional
*/
public static function hasTrueVariable(
- PhpParser\Node\Expr\BinaryOp $conditional
+ PhpParser\Node\Expr\BinaryOp $conditional,
): ?int {
if ($conditional->right instanceof PhpParser\Node\Expr\ConstFetch
&& strtolower($conditional->right->name->getFirst()) === 'true'
@@ -1363,7 +1365,7 @@ public static function hasTrueVariable(
* @param Identical|Equal|NotIdentical|NotEqual $conditional
*/
protected static function hasEmptyArrayVariable(
- PhpParser\Node\Expr\BinaryOp $conditional
+ PhpParser\Node\Expr\BinaryOp $conditional,
): ?int {
if ($conditional->right instanceof PhpParser\Node\Expr\Array_
&& !$conditional->right->items
@@ -1382,11 +1384,10 @@ protected static function hasEmptyArrayVariable(
/**
* @param Identical|Equal|NotIdentical|NotEqual $conditional
- * @return false|int
*/
protected static function hasGetTypeCheck(
- PhpParser\Node\Expr\BinaryOp $conditional
- ) {
+ PhpParser\Node\Expr\BinaryOp $conditional,
+ ): false|int {
if ($conditional->right instanceof PhpParser\Node\Expr\FuncCall
&& $conditional->right->name instanceof PhpParser\Node\Name
&& strtolower($conditional->right->name->getFirst()) === 'gettype'
@@ -1410,11 +1411,10 @@ protected static function hasGetTypeCheck(
/**
* @param Identical|Equal|NotIdentical|NotEqual $conditional
- * @return false|int
*/
protected static function hasGetDebugTypeCheck(
- PhpParser\Node\Expr\BinaryOp $conditional
- ) {
+ PhpParser\Node\Expr\BinaryOp $conditional,
+ ): false|int {
if ($conditional->right instanceof PhpParser\Node\Expr\FuncCall
&& $conditional->right->name instanceof PhpParser\Node\Name
&& strtolower($conditional->right->name->getFirst()) === 'get_debug_type'
@@ -1440,12 +1440,11 @@ protected static function hasGetDebugTypeCheck(
/**
* @param Identical|Equal|NotIdentical|NotEqual $conditional
- * @return false|int
*/
protected static function hasGetClassCheck(
PhpParser\Node\Expr\BinaryOp $conditional,
- FileSource $source
- ) {
+ FileSource $source,
+ ): false|int {
if (!$source instanceof StatementsAnalyzer) {
return false;
}
@@ -1533,12 +1532,11 @@ protected static function hasGetClassCheck(
/**
* @param Greater|GreaterOrEqual|Smaller|SmallerOrEqual $conditional
- * @return false|int
*/
protected static function hasNonEmptyCountEqualityCheck(
PhpParser\Node\Expr\BinaryOp $conditional,
- ?int &$min_count
- ) {
+ ?int &$min_count,
+ ): false|int {
if ($conditional->left instanceof PhpParser\Node\Expr\FuncCall
&& $conditional->left->name instanceof PhpParser\Node\Name
&& in_array(strtolower($conditional->left->name->getFirst()), ['count', 'sizeof'])
@@ -1575,12 +1573,11 @@ protected static function hasNonEmptyCountEqualityCheck(
/**
* @param Greater|GreaterOrEqual|Smaller|SmallerOrEqual $conditional
- * @return false|int
*/
protected static function hasLessThanCountEqualityCheck(
PhpParser\Node\Expr\BinaryOp $conditional,
- ?int &$max_count
- ) {
+ ?int &$max_count,
+ ): false|int {
$left_count = $conditional->left instanceof PhpParser\Node\Expr\FuncCall
&& $conditional->left->name instanceof PhpParser\Node\Name
&& in_array(strtolower($conditional->left->name->getFirst()), ['count', 'sizeof'])
@@ -1624,12 +1621,11 @@ protected static function hasLessThanCountEqualityCheck(
/**
* @param Equal|Identical|NotEqual|NotIdentical $conditional
- * @return false|int
*/
protected static function hasCountEqualityCheck(
PhpParser\Node\Expr\BinaryOp $conditional,
- ?int &$count
- ) {
+ ?int &$count,
+ ): false|int {
$left_count = $conditional->left instanceof PhpParser\Node\Expr\FuncCall
&& $conditional->left->name instanceof PhpParser\Node\Name
&& in_array(strtolower($conditional->left->name->getFirst()), ['count', 'sizeof'])
@@ -1657,13 +1653,12 @@ protected static function hasCountEqualityCheck(
/**
* @param PhpParser\Node\Expr\BinaryOp\Greater|PhpParser\Node\Expr\BinaryOp\GreaterOrEqual $conditional
- * @return false|int
*/
protected static function hasSuperiorNumberCheck(
FileSource $source,
PhpParser\Node\Expr\BinaryOp $conditional,
- ?int &$literal_value_comparison
- ) {
+ ?int &$literal_value_comparison,
+ ): false|int {
$right_assignment = false;
$value_right = null;
if ($source instanceof StatementsAnalyzer
@@ -1717,13 +1712,12 @@ protected static function hasSuperiorNumberCheck(
/**
* @param PhpParser\Node\Expr\BinaryOp\Smaller|PhpParser\Node\Expr\BinaryOp\SmallerOrEqual $conditional
- * @return false|int
*/
protected static function hasInferiorNumberCheck(
FileSource $source,
PhpParser\Node\Expr\BinaryOp $conditional,
- ?int &$literal_value_comparison
- ) {
+ ?int &$literal_value_comparison,
+ ): false|int {
$right_assignment = false;
$value_right = null;
if ($source instanceof StatementsAnalyzer
@@ -1777,11 +1771,10 @@ protected static function hasInferiorNumberCheck(
/**
* @param PhpParser\Node\Expr\BinaryOp\Greater|PhpParser\Node\Expr\BinaryOp\GreaterOrEqual $conditional
- * @return false|int
*/
protected static function hasReconcilableNonEmptyCountEqualityCheck(
- PhpParser\Node\Expr\BinaryOp $conditional
- ) {
+ PhpParser\Node\Expr\BinaryOp $conditional,
+ ): false|int {
$left_count = $conditional->left instanceof PhpParser\Node\Expr\FuncCall
&& $conditional->left->name instanceof PhpParser\Node\Name
&& in_array(strtolower($conditional->left->name->getFirst()), ['count', 'sizeof']);
@@ -1799,12 +1792,11 @@ protected static function hasReconcilableNonEmptyCountEqualityCheck(
/**
* @param Identical|Equal|NotIdentical|NotEqual $conditional
- * @return false|int
*/
protected static function hasTypedValueComparison(
PhpParser\Node\Expr\BinaryOp $conditional,
- FileSource $source
- ) {
+ FileSource $source,
+ ): false|int {
if (!$source instanceof StatementsAnalyzer) {
return false;
}
@@ -1837,7 +1829,7 @@ protected static function hasTypedValueComparison(
protected static function hasIsACheck(
PhpParser\Node\Expr\FuncCall $stmt,
- StatementsAnalyzer $source
+ StatementsAnalyzer $source,
): bool {
if ($stmt->name instanceof PhpParser\Node\Name
&& (strtolower($stmt->name->getFirst()) === 'is_a'
@@ -1915,7 +1907,7 @@ private static function handleIsTypeCheck(
?string $first_var_name,
?Union $first_var_type,
PhpParser\Node\Expr\FuncCall $expr,
- bool $negate
+ bool $negate,
): array {
$if_types = [];
if ($stmt->name instanceof PhpParser\Node\Name
@@ -2061,7 +2053,7 @@ private static function getNullInequalityAssertions(
FileSource $source,
?string $this_class_name,
?Codebase $codebase,
- int $null_position
+ int $null_position,
): array {
$if_types = [];
@@ -2144,7 +2136,7 @@ private static function getFalseInequalityAssertions(
?Codebase $codebase,
int $false_position,
bool $cache,
- bool $inside_conditional
+ bool $inside_conditional,
): array {
$if_types = [];
@@ -2264,7 +2256,7 @@ private static function getTrueInequalityAssertions(
?Codebase $codebase,
int $true_position,
bool $cache,
- bool $inside_conditional
+ bool $inside_conditional,
): array {
$if_types = [];
@@ -2416,7 +2408,7 @@ private static function getEmptyInequalityAssertions(
?string $this_class_name,
FileSource $source,
?Codebase $codebase,
- int $empty_array_position
+ int $empty_array_position,
): array {
$if_types = [];
@@ -2492,7 +2484,7 @@ private static function getGettypeInequalityAssertions(
PhpParser\Node\Expr\BinaryOp $conditional,
?string $this_class_name,
FileSource $source,
- int $gettype_position
+ int $gettype_position,
): array {
$if_types = [];
@@ -2558,7 +2550,7 @@ private static function getGetdebugTypeInequalityAssertions(
PhpParser\Node\Expr\BinaryOp $conditional,
?string $this_class_name,
FileSource $source,
- int $get_debug_type_position
+ int $get_debug_type_position,
): array {
$if_types = [];
@@ -2615,7 +2607,7 @@ private static function getGetclassInequalityAssertions(
PhpParser\Node\Expr\BinaryOp $conditional,
?string $this_class_name,
StatementsAnalyzer $source,
- int $getclass_position
+ int $getclass_position,
): array {
$if_types = [];
@@ -2709,7 +2701,7 @@ private static function getTypedValueInequalityAssertions(
?string $this_class_name,
StatementsAnalyzer $source,
?Codebase $codebase,
- int $typed_value_position
+ int $typed_value_position,
): array {
$if_types = [];
@@ -2783,7 +2775,7 @@ private static function getNullEqualityAssertions(
?string $this_class_name,
FileSource $source,
?Codebase $codebase,
- int $null_position
+ int $null_position,
): array {
$if_types = [];
@@ -2865,7 +2857,7 @@ private static function getTrueEqualityAssertions(
?Codebase $codebase,
int $true_position,
bool $cache,
- bool $inside_conditional
+ bool $inside_conditional,
): array {
$if_types = [];
@@ -2993,7 +2985,7 @@ private static function getFalseEqualityAssertions(
?Codebase $codebase,
int $false_position,
bool $cache,
- bool $inside_conditional
+ bool $inside_conditional,
): array {
$if_types = [];
@@ -3144,7 +3136,7 @@ private static function getEmptyArrayEqualityAssertions(
?string $this_class_name,
FileSource $source,
?Codebase $codebase,
- int $empty_array_position
+ int $empty_array_position,
): array {
$if_types = [];
@@ -3215,7 +3207,7 @@ private static function getGettypeEqualityAssertions(
PhpParser\Node\Expr\BinaryOp $conditional,
?string $this_class_name,
FileSource $source,
- int $gettype_position
+ int $gettype_position,
): array {
$if_types = [];
@@ -3277,7 +3269,7 @@ private static function getGetdebugtypeEqualityAssertions(
PhpParser\Node\Expr\BinaryOp $conditional,
?string $this_class_name,
FileSource $source,
- int $get_debug_type_position
+ int $get_debug_type_position,
): array {
$if_types = [];
@@ -3340,7 +3332,7 @@ private static function getGetclassEqualityAssertions(
PhpParser\Node\Expr\BinaryOp $conditional,
?string $this_class_name,
StatementsAnalyzer $source,
- int $getclass_position
+ int $getclass_position,
): array {
$if_types = [];
@@ -3436,7 +3428,7 @@ private static function getTypedValueEqualityAssertions(
?string $this_class_name,
StatementsAnalyzer $source,
?Codebase $codebase,
- int $typed_value_position
+ int $typed_value_position,
): array {
$if_types = [];
@@ -3541,7 +3533,7 @@ private static function getIsaAssertions(
PhpParser\Node\Expr\FuncCall $expr,
StatementsAnalyzer $source,
?string $this_class_name,
- ?string $first_var_name
+ ?string $first_var_name,
): array {
$if_types = [];
@@ -3644,7 +3636,7 @@ private static function getIsaAssertions(
private static function getInarrayAssertions(
PhpParser\Node\Expr\FuncCall $expr,
StatementsAnalyzer $source,
- ?string $first_var_name
+ ?string $first_var_name,
): array {
$if_types = [];
@@ -3720,7 +3712,7 @@ private static function getArrayKeyExistsAssertions(
?Union $first_var_type,
?string $first_var_name,
FileSource $source,
- ?string $this_class_name
+ ?string $this_class_name,
): array {
$if_types = [];
@@ -3840,7 +3832,7 @@ private static function getArrayKeyExistsAssertions(
private static function getGreaterAssertions(
PhpParser\Node\Expr $conditional,
FileSource $source,
- ?string $this_class_name
+ ?string $this_class_name,
): array {
$if_types = [];
@@ -3953,7 +3945,7 @@ private static function getGreaterAssertions(
private static function getSmallerAssertions(
PhpParser\Node\Expr $conditional,
FileSource $source,
- ?string $this_class_name
+ ?string $this_class_name,
): array {
$if_types = [];
$min_count = null;
@@ -4063,7 +4055,7 @@ private static function getAndCheckInstanceofAssertions(
?Codebase $codebase,
FileSource $source,
?string $this_class_name,
- bool $inside_negation
+ bool $inside_negation,
): array {
$if_types = [];
@@ -4145,7 +4137,7 @@ private static function handleParadoxicalAssertions(
?string $this_class_name,
Union $other_type,
Codebase $codebase,
- PhpParser\Node\Expr\BinaryOp $conditional
+ PhpParser\Node\Expr\BinaryOp $conditional,
): void {
$parent_source = $source->getSource();
@@ -4198,7 +4190,7 @@ public static function isPropertyImmutableOnArgument(
string $property,
NodeDataProvider $node_provider,
ClassLikeStorageProvider $class_provider,
- PhpParser\Node\Expr\Variable $arg_expr
+ PhpParser\Node\Expr\Variable $arg_expr,
): ?string {
$type = $node_provider->getType($arg_expr);
/** @var string $name */
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php
index a8c50bb3d90..3a47c43d894 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php
@@ -1,5 +1,7 @@
data_flow_graph
&& ($statements_analyzer->data_flow_graph instanceof VariableUseGraph
@@ -454,7 +456,7 @@ private static function updateArrayAssignmentChildType(
Union $value_type,
Union $root_type,
bool $offset_already_existed,
- ?string $parent_var_id
+ ?string $parent_var_id,
): Union {
$templated_assignment = false;
@@ -750,7 +752,7 @@ private static function analyzeNestedArrayAssignment(
Union &$root_type,
Union &$current_type,
?PhpParser\Node\Expr &$current_dim,
- bool &$offset_already_existed
+ bool &$offset_already_existed,
): void {
$var_id_additions = [];
@@ -1020,7 +1022,7 @@ private static function analyzeNestedArrayAssignment(
*/
private static function getDimKeyValues(
StatementsAnalyzer $statements_analyzer,
- PhpParser\Node\Expr $dim
+ PhpParser\Node\Expr $dim,
): array {
$key_values = [];
@@ -1061,7 +1063,7 @@ private static function getDimKeyValues(
private static function getArrayAssignmentOffsetType(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr\ArrayDimFetch $child_stmt,
- Union $child_stmt_dim_type
+ Union $child_stmt_dim_type,
): array {
if ($child_stmt->dim instanceof PhpParser\Node\Scalar\String_
|| (($child_stmt->dim instanceof PhpParser\Node\Expr\ConstFetch
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/AssignedProperty.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/AssignedProperty.php
index a49249992b5..7a35ff2c069 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/AssignedProperty.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/AssignedProperty.php
@@ -1,5 +1,7 @@
property_type = $property_type;
$this->id = $id;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php
index 127bab853f6..88a2bf6b511 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
@@ -360,7 +362,7 @@ public static function trackPropertyImpurity(
string $property_id,
PropertyStorage $property_storage,
ClassLikeStorage $declaring_class_storage,
- Context $context
+ Context $context,
): void {
$codebase = $statements_analyzer->getCodebase();
@@ -412,7 +414,7 @@ public static function trackPropertyImpurity(
public static function analyzeStatement(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Stmt\Property $stmt,
- Context $context
+ Context $context,
): void {
foreach ($stmt->props as $prop) {
if ($prop->default) {
@@ -448,7 +450,7 @@ private static function taintProperty(
string $property_id,
ClassLikeStorage $class_storage,
Union &$assignment_value_type,
- Context $context
+ Context $context,
): void {
if (!$statements_analyzer->data_flow_graph) {
return;
@@ -565,7 +567,7 @@ public static function taintUnspecializedProperty(
ClassLikeStorage $class_storage,
Union $assignment_value_type,
Context $context,
- ?string $var_property_id
+ ?string $var_property_id,
): void {
$codebase = $statements_analyzer->getCodebase();
@@ -662,7 +664,7 @@ private static function analyzeRegularAssignment(
Codebase $codebase,
Union $assignment_value_type,
string $prop_name,
- ?string &$var_id
+ ?string &$var_id,
): array {
$was_inside_general_use = $context->inside_general_use;
$context->inside_general_use = true;
@@ -882,7 +884,7 @@ private static function analyzeAtomicAssignment(
Union $assignment_value_type,
?string $lhs_var_id,
bool &$has_valid_assignment_type,
- bool &$has_regular_setter
+ bool &$has_regular_setter,
): ?AssignedProperty {
if ($lhs_type_part instanceof TNull) {
return null;
@@ -1430,7 +1432,7 @@ private static function handlePropertyRenames(
string $declaring_property_class,
string $prop_name,
PropertyFetch $stmt,
- string $file_path
+ string $file_path,
): void {
if (!$codebase->properties_to_rename) {
return;
@@ -1460,7 +1462,7 @@ public static function getExpandedPropertyType(
Codebase $codebase,
string $fq_class_name,
string $property_name,
- ClassLikeStorage $storage
+ ClassLikeStorage $storage,
): ?Union {
$property_class_name = $codebase->properties->getDeclaringClassForProperty(
$fq_class_name . '::$' . $property_name,
@@ -1528,7 +1530,7 @@ private static function analyzeSetCall(
StatementsAnalyzer $statements_analyzer,
PropertyFetch $stmt,
string $prop_name,
- Expr $assignment_value
+ Expr $assignment_value,
): void {
if ($var_id) {
$context->removeVarFromConflictingClauses(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/StaticPropertyAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/StaticPropertyAssignmentAnalyzer.php
index e307f514644..990aed4dfdb 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/StaticPropertyAssignmentAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/StaticPropertyAssignmentAnalyzer.php
@@ -1,5 +1,7 @@
getFQCLN(),
@@ -618,7 +619,7 @@ private static function analyzeAssignment(
?Doc $doc_comment,
?string $extended_var_id,
array $var_comments,
- array $removed_taints
+ array $removed_taints,
): ?bool {
if ($assign_var instanceof PhpParser\Node\Expr\Variable) {
self::analyzeAssignmentToVariable(
@@ -698,7 +699,7 @@ public static function assignTypeFromVarDocblock(
?Union &$comment_type = null,
?DocblockTypeLocation &$comment_type_location = null,
array $not_ignored_docblock_var_ids = [],
- bool $by_ref = false
+ bool $by_ref = false,
): void {
if (!$var_comment->type) {
return;
@@ -812,7 +813,7 @@ private static function taintAssignment(
string $var_id,
CodeLocation $var_location,
array $removed_taints,
- array $added_taints
+ array $added_taints,
): void {
$parent_nodes = $type->parent_nodes;
@@ -836,7 +837,7 @@ private static function taintAssignment(
public static function analyzeAssignmentOperation(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr\AssignOp $stmt,
- Context $context
+ Context $context,
): bool {
if ($stmt instanceof PhpParser\Node\Expr\AssignOp\BitwiseAnd) {
$operation = new VirtualBitwiseAnd($stmt->var, $stmt->expr, $stmt->getAttributes());
@@ -895,7 +896,7 @@ public static function analyzeAssignmentOperation(
public static function analyzeAssignmentRef(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr\AssignRef $stmt,
- Context $context
+ Context $context,
): bool {
ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context, false, null, false, null, true);
@@ -1032,7 +1033,7 @@ public static function assignByRefParam(
Union $by_ref_out_type,
Context $context,
bool $constrain_type = true,
- bool $prevent_null = false
+ bool $prevent_null = false,
): void {
if ($stmt instanceof PhpParser\Node\Expr\PropertyFetch && $stmt->name instanceof PhpParser\Node\Identifier) {
$prop_name = $stmt->name->name;
@@ -1168,7 +1169,7 @@ private static function analyzeDestructuringAssignment(
?PhpParser\Comment\Doc $doc_comment,
?string $extended_var_id,
array $var_comments,
- array $removed_taints
+ array $removed_taints,
): void {
if (!$assign_value_type->hasArray()
&& !$assign_value_type->isMixed()
@@ -1590,7 +1591,7 @@ private static function analyzePropertyAssignment(
Context $context,
?PhpParser\Node\Expr $assign_value,
Union $assign_value_type,
- ?string $var_id
+ ?string $var_id,
): void {
if (!$assign_var->name instanceof PhpParser\Node\Identifier) {
$was_inside_general_use = $context->inside_general_use;
@@ -1695,7 +1696,7 @@ private static function analyzeAssignmentToVariable(
?PhpParser\Node\Expr $assign_value,
Union $assign_value_type,
?string $var_id,
- Context $context
+ Context $context,
): void {
if (is_string($assign_var->name)) {
if ($var_id) {
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php
index 1f5f90309e6..911827f2c4a 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase() : null;
@@ -276,10 +278,7 @@ public static function analyze(
}
}
- /**
- * @param int|float $result
- */
- private static function getNumericalType($result): Union
+ private static function getNumericalType(int|float $result): Union
{
if (is_int($result)) {
return Type::getInt(false, $result);
@@ -308,7 +307,7 @@ private static function analyzeOperands(
bool &$has_valid_left_operand,
bool &$has_valid_right_operand,
bool &$has_string_increment,
- Union &$result_type = null
+ Union &$result_type = null,
): ?Union {
if (($left_type_part instanceof TLiteralInt || $left_type_part instanceof TLiteralFloat)
&& ($right_type_part instanceof TLiteralInt || $right_type_part instanceof TLiteralFloat)
@@ -921,15 +920,11 @@ private static function analyzeOperands(
return null;
}
- /**
- * @param float|int $operand1
- * @param float|int $operand2
- */
public static function arithmeticOperation(
PhpParser\Node $operation,
- $operand1,
- $operand2,
- bool $allow_float_result
+ float|int $operand1,
+ float|int $operand2,
+ bool $allow_float_result,
): ?Union {
if ($operation instanceof PhpParser\Node\Expr\BinaryOp\Plus) {
$result = $operand1 + $operand2;
@@ -977,7 +972,7 @@ private static function analyzeOperandsBetweenIntRange(
PhpParser\Node $parent,
?Union &$result_type,
TIntRange $left_type_part,
- TIntRange $right_type_part
+ TIntRange $right_type_part,
): void {
if ($parent instanceof PhpParser\Node\Expr\BinaryOp\Div) {
//can't assume an int range will stay int after division
@@ -1079,7 +1074,7 @@ private static function analyzeOperandsBetweenIntRangeAndInt(
PhpParser\Node $parent,
?Union &$result_type,
Atomic $left_type_part,
- Atomic $right_type_part
+ Atomic $right_type_part,
): void {
if (!$left_type_part instanceof TIntRange) {
$left_type_part = TIntRange::convertToIntRange($left_type_part);
@@ -1095,7 +1090,7 @@ private static function analyzeMulBetweenIntRange(
PhpParser\Node\Expr\BinaryOp\Mul $parent,
?Union &$result_type,
TIntRange $left_type_part,
- TIntRange $right_type_part
+ TIntRange $right_type_part,
): void {
//Mul is a special case because of double negatives. We can only infer when we know both signs strictly
if ($right_type_part->min_bound !== null
@@ -1271,7 +1266,7 @@ private static function analyzeMulBetweenIntRange(
private static function analyzePowBetweenIntRange(
?Union &$result_type,
TIntRange $left_type_part,
- TIntRange $right_type_part
+ TIntRange $right_type_part,
): void {
//If Pow first operand is negative, the result could be positive or negative, else it will be positive
//If Pow second operand is negative, the result will be float, if it's 0, it will be 1/-1, else positive
@@ -1344,7 +1339,7 @@ private static function analyzePowBetweenIntRange(
private static function analyzeModBetweenIntRange(
?Union &$result_type,
TIntRange $left_type_part,
- TIntRange $right_type_part
+ TIntRange $right_type_part,
): void {
//result of Mod is not directly dependant on the bounds of the range
if ($right_type_part->min_bound !== null && $right_type_part->min_bound === $right_type_part->max_bound) {
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php
index 8a0eed58346..364a9ec7ef5 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php
@@ -1,5 +1,7 @@
left;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php
index fa05aef2178..b3f7a03e5ed 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
@@ -309,7 +311,7 @@ private static function analyzeOperand(
PhpParser\Node\Expr $operand,
Union $operand_type,
string $side,
- Context $context
+ Context $context,
): void {
$codebase = $statements_analyzer->getCodebase();
$config = Config::getInstance();
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php
index 7f3e7f5391f..9b3b804d7b2 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php
@@ -1,5 +1,7 @@
node_data->getType($stmt->left);
$stmt_right_type = $statements_analyzer->node_data->getType($stmt->right);
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php
index d315e36f900..eaf715bfa37 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php
@@ -1,5 +1,7 @@
100) {
$statements_analyzer->node_data->setType($stmt, Type::getString());
@@ -373,7 +375,7 @@ public static function addDataFlow(
PhpParser\Node\Expr $stmt,
PhpParser\Node\Expr $left,
PhpParser\Node\Expr $right,
- string $type = 'binaryop'
+ string $type = 'binaryop',
): void {
if ($stmt->getLine() === -1) {
throw new UnexpectedValueException('bad');
@@ -455,7 +457,7 @@ private static function checkForImpureEqualityComparison(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr\BinaryOp\Equal $stmt,
Union $stmt_left_type,
- Union $stmt_right_type
+ Union $stmt_right_type,
): void {
$codebase = $statements_analyzer->getCodebase();
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BitwiseNotAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BitwiseNotAnalyzer.php
index 3efa5c6ce69..23d0256c389 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/BitwiseNotAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BitwiseNotAnalyzer.php
@@ -1,5 +1,7 @@
expr, $context) === false) {
return false;
@@ -104,7 +106,7 @@ public static function analyze(
private static function addDataFlow(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr $stmt,
- PhpParser\Node\Expr $value
+ PhpParser\Node\Expr $value,
): void {
$result_type = $statements_analyzer->node_data->getType($stmt);
if ($statements_analyzer->data_flow_graph instanceof VariableUseGraph && $result_type) {
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BooleanNotAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BooleanNotAnalyzer.php
index fa053702791..09bfb35f877 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/BooleanNotAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BooleanNotAnalyzer.php
@@ -1,5 +1,7 @@
> $class_generic_params
@@ -101,7 +103,7 @@ public static function checkArgumentMatches(
array $class_generic_params,
?TemplateResult $template_result,
bool $specialize_taint,
- bool $in_call_map
+ bool $in_call_map,
): ?bool {
$codebase = $statements_analyzer->getCodebase();
@@ -239,7 +241,7 @@ private static function checkFunctionLikeTypeMatches(
?array $class_generic_params,
?TemplateResult $template_result,
bool $specialize_taint,
- bool $in_call_map
+ bool $in_call_map,
): ?bool {
if (!$function_param->type) {
if (!$codebase->infer_types_from_usage && !$statements_analyzer->data_flow_graph) {
@@ -671,7 +673,7 @@ public static function verifyType(
?Atomic $unpacked_atomic_array,
bool $specialize_taint,
bool $in_call_map,
- CodeLocation $function_call_location
+ CodeLocation $function_call_location,
): ?bool {
$codebase = $statements_analyzer->getCodebase();
@@ -1161,7 +1163,7 @@ private static function verifyExplicitParam(
Union $param_type,
CodeLocation $arg_location,
PhpParser\Node\Expr $input_expr,
- Context $context
+ Context $context,
): void {
$codebase = $statements_analyzer->getCodebase();
@@ -1336,12 +1338,22 @@ private static function coerceValueAfterGatekeeperArgument(
?Union $signature_param_type,
Context $context,
bool $unpack,
- ?Atomic $unpacked_atomic_array
+ ?Atomic $unpacked_atomic_array,
): void {
if ($param_type->hasMixed()) {
return;
}
+ $var_id = ExpressionIdentifier::getVarId(
+ $input_expr,
+ $statements_analyzer->getFQCLN(),
+ $statements_analyzer,
+ );
+
+ if (!$var_id) {
+ return;
+ }
+
if (!$input_type_changed && $param_type->from_docblock && !$input_type->hasMixed()) {
$types = $input_type->getAtomicTypes();
foreach ($param_type->getAtomicTypes() as $param_atomic_type) {
@@ -1380,74 +1392,67 @@ private static function coerceValueAfterGatekeeperArgument(
$input_type = new Union($types);
}
- $var_id = ExpressionIdentifier::getVarId(
- $input_expr,
- $statements_analyzer->getFQCLN(),
- $statements_analyzer,
- );
- if ($var_id) {
- $was_cloned = false;
+ $was_cloned = false;
- if ($input_type->isNullable() && !$param_type->isNullable()) {
- $input_type = $input_type->getBuilder();
- $was_cloned = true;
- $input_type->removeType('null');
- $input_type = $input_type->freeze();
- }
-
- if ($input_type->getId() === $param_type->getId()) {
- if ($input_type->from_docblock) {
- $input_type = $input_type->setFromDocblock(false);
- }
- } elseif ($input_type->hasMixed() && $signature_param_type) {
- $was_cloned = true;
- $parent_nodes = $input_type->parent_nodes;
- $by_ref = $input_type->by_ref;
- $input_type = $signature_param_type->setProperties([
- 'ignore_nullable_issues' => $signature_param_type->isNullable(),
- 'parent_nodes' => $parent_nodes,
- 'by_ref' => $by_ref,
- ]);
- }
+ if ($input_type->isNullable() && !$param_type->isNullable()) {
+ $input_type = $input_type->getBuilder();
+ $was_cloned = true;
+ $input_type->removeType('null');
+ $input_type = $input_type->freeze();
+ }
- if ($context->inside_conditional && !isset($context->assigned_var_ids[$var_id])) {
- $context->assigned_var_ids[$var_id] = 0;
+ if ($input_type->getId() === $param_type->getId()) {
+ if ($input_type->from_docblock) {
+ $input_type = $input_type->setFromDocblock(false);
}
+ } elseif ($input_type->hasMixed() && $signature_param_type) {
+ $was_cloned = true;
+ $parent_nodes = $input_type->parent_nodes;
+ $by_ref = $input_type->by_ref;
+ $input_type = $signature_param_type->setProperties([
+ 'ignore_nullable_issues' => $signature_param_type->isNullable(),
+ 'parent_nodes' => $parent_nodes,
+ 'by_ref' => $by_ref,
+ ]);
+ }
- if ($was_cloned) {
- $context->removeVarFromConflictingClauses($var_id, null, $statements_analyzer);
- }
+ if ($context->inside_conditional && !isset($context->assigned_var_ids[$var_id])) {
+ $context->assigned_var_ids[$var_id] = 0;
+ }
- if ($unpack) {
- if ($unpacked_atomic_array instanceof TArray) {
- $unpacked_atomic_array = $unpacked_atomic_array->setTypeParams([
- $unpacked_atomic_array->type_params[0],
- $input_type,
- ]);
+ if ($was_cloned) {
+ $context->removeVarFromConflictingClauses($var_id, null, $statements_analyzer);
+ }
- $context->vars_in_scope[$var_id] = new Union([$unpacked_atomic_array]);
- } elseif ($unpacked_atomic_array instanceof TKeyedArray
- && $unpacked_atomic_array->is_list
- ) {
- if ($unpacked_atomic_array->isNonEmpty()) {
- $unpacked_atomic_array = Type::getNonEmptyListAtomic($input_type);
- } else {
- $unpacked_atomic_array = Type::getListAtomic($input_type);
- }
+ if ($unpack) {
+ if ($unpacked_atomic_array instanceof TArray) {
+ $unpacked_atomic_array = $unpacked_atomic_array->setTypeParams([
+ $unpacked_atomic_array->type_params[0],
+ $input_type,
+ ]);
- $context->vars_in_scope[$var_id] = new Union([$unpacked_atomic_array]);
+ $context->vars_in_scope[$var_id] = new Union([$unpacked_atomic_array]);
+ } elseif ($unpacked_atomic_array instanceof TKeyedArray
+ && $unpacked_atomic_array->is_list
+ ) {
+ if ($unpacked_atomic_array->isNonEmpty()) {
+ $unpacked_atomic_array = Type::getNonEmptyListAtomic($input_type);
} else {
- $context->vars_in_scope[$var_id] = new Union([
- new TArray([
- Type::getInt(),
- $input_type,
- ]),
- ]);
+ $unpacked_atomic_array = Type::getListAtomic($input_type);
}
+
+ $context->vars_in_scope[$var_id] = new Union([$unpacked_atomic_array]);
} else {
- $context->vars_in_scope[$var_id] = $input_type;
+ $context->vars_in_scope[$var_id] = new Union([
+ new TArray([
+ Type::getInt(),
+ $input_type,
+ ]),
+ ]);
}
+ } else {
+ $context->vars_in_scope[$var_id] = $input_type;
}
}
@@ -1462,7 +1467,7 @@ private static function processTaintedness(
Union $input_type,
PhpParser\Node\Expr $expr,
Context $context,
- bool $specialize_taint
+ bool $specialize_taint,
): void {
$codebase = $statements_analyzer->getCodebase();
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentMapPopulator.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentMapPopulator.php
index fbbc5e24ea6..a63d17f988e 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentMapPopulator.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentMapPopulator.php
@@ -1,5 +1,7 @@
file_provider->getContents($statements_analyzer->getFilePath());
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php
index cebfd09dd1e..15eb539d662 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php
@@ -1,5 +1,7 @@
$args
@@ -78,7 +80,7 @@ public static function analyze(
?string $method_id,
bool $allow_named_args,
Context $context,
- ?TemplateResult $template_result = null
+ ?TemplateResult $template_result = null,
): ?bool {
$last_param = $function_params
? $function_params[count($function_params) - 1]
@@ -310,7 +312,7 @@ private static function handleArrayMapFilterArrayArg(
int $argument_offset,
PhpParser\Node\Arg $arg,
Context $context,
- ?TemplateResult &$template_result
+ ?TemplateResult &$template_result,
): void {
$codebase = $statements_analyzer->getCodebase();
@@ -365,7 +367,7 @@ private static function handleClosureArg(
TemplateResult $template_result,
int $argument_offset,
PhpParser\Node\Arg $arg,
- FunctionLikeParameter $param
+ FunctionLikeParameter $param,
): void {
if (!$param->type) {
return;
@@ -526,7 +528,6 @@ 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
@@ -534,13 +535,13 @@ private static function handleClosureArg(
public static function checkArgumentsMatch(
StatementsAnalyzer $statements_analyzer,
array $args,
- $method_id,
+ string|MethodIdentifier|null $method_id,
array $function_params,
?FunctionLikeStorage $function_storage,
?ClassLikeStorage $class_storage,
TemplateResult $template_result,
CodeLocation $code_location,
- Context $context
+ Context $context,
): ?bool {
$in_call_map = $method_id ? InternalCallMapHandler::inCallMap((string) $method_id) : false;
@@ -983,7 +984,7 @@ private static function handlePossiblyMatchingByRefParam(
int $argument_offset,
PhpParser\Node\Arg $arg,
Context $context,
- ?TemplateResult $template_result
+ ?TemplateResult $template_result,
): ?bool {
if ($arg->value instanceof PhpParser\Node\Scalar
|| $arg->value instanceof PhpParser\Node\Expr\Cast
@@ -1128,7 +1129,7 @@ private static function handlePossiblyMatchingByRefParam(
private static function evaluateArbitraryParam(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Arg $arg,
- Context $context
+ Context $context,
): ?bool {
// there are a bunch of things we want to evaluate even when we don't
// know what function/method is being called
@@ -1239,7 +1240,7 @@ private static function handleByRefFunctionArg(
?string $method_id,
int $argument_offset,
PhpParser\Node\Arg $arg,
- Context $context
+ Context $context,
): ?bool {
$var_id = ExpressionIdentifier::getVarId(
$arg->value,
@@ -1376,7 +1377,7 @@ private static function getProvisionalTemplateResultForFunctionLike(
?TemplateResult $template_result,
array $args,
array $function_params,
- ?FunctionLikeParameter $last_param
+ ?FunctionLikeParameter $last_param,
): ?TemplateResult {
$template_types = CallAnalyzer::getTemplateTypesForCall(
$codebase,
@@ -1456,7 +1457,6 @@ private static function getProvisionalTemplateResultForFunctionLike(
/**
* @param array $args
- * @param string|MethodIdentifier|null $method_id
* @param array $function_params
*/
private static function checkArgCount(
@@ -1469,9 +1469,9 @@ private static function checkArgCount(
array $args,
array $function_params,
bool $in_call_map,
- $method_id,
+ string|MethodIdentifier|null $method_id,
?string $cased_method_id,
- CodeLocation $code_location
+ CodeLocation $code_location,
): void {
if (!$is_variadic
&& count($args) > count($function_params)
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php
index 7f09b6a9a8c..f252f93bde6 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php
@@ -1,5 +1,7 @@
$args
@@ -66,7 +68,7 @@ public static function checkArgumentsMatch(
Context $context,
array $args,
string $method_id,
- bool $check_functions
+ bool $check_functions,
): void {
$closure_index = $method_id === 'array_map' ? 0 : 1;
@@ -142,7 +144,7 @@ public static function handleAddition(
StatementsAnalyzer $statements_analyzer,
array $args,
Context $context,
- string $method_id
+ string $method_id,
): ?bool {
$array_arg = $args[0]->value;
$nb_args = count($args);
@@ -335,7 +337,7 @@ public static function handleAddition(
public static function handleSplice(
StatementsAnalyzer $statements_analyzer,
array $args,
- Context $context
+ Context $context,
): ?bool {
$context->inside_call = true;
$array_arg = $args[0]->value;
@@ -619,7 +621,7 @@ public static function handleByRefArrayAdjustment(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Arg $arg,
Context $context,
- bool $is_array_shift
+ bool $is_array_shift,
): void {
$var_id = ExpressionIdentifier::getVarId(
$arg->value,
@@ -738,7 +740,7 @@ private static function checkClosureType(
int $min_closure_param_count,
int $max_closure_param_count,
array $array_arg_types,
- bool $check_functions
+ bool $check_functions,
): void {
$codebase = $statements_analyzer->getCodebase();
@@ -903,7 +905,7 @@ private static function checkClosureTypeArgs(
PhpParser\Node\Arg $closure_arg,
int $min_closure_param_count,
int $max_closure_param_count,
- array $array_arg_types
+ array $array_arg_types,
): void {
$codebase = $statements_analyzer->getCodebase();
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php
index c3bbd2995b7..7a9f34f9fdf 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php
@@ -1,5 +1,7 @@
is_trait
? $static_class_storage
@@ -185,7 +187,7 @@ private static function resolveTemplateParam(
Union $input_type_extends,
ClassLikeStorage $static_class_storage,
TGenericObject $lhs_type_part,
- ?TemplateResult $template_result = null
+ ?TemplateResult $template_result = null,
): ?Union {
$output_type_extends = null;
foreach ($input_type_extends->getAtomicTypes() as $type_extends_atomic) {
@@ -259,7 +261,7 @@ private static function expandType(
Union $input_type_extends,
array $e,
string $static_fq_class_name,
- ?array $static_template_types
+ ?array $static_template_types,
): array {
$output_type_extends = [];
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php
index 08184c41ccc..77a6d7d6118 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php
@@ -1,5 +1,7 @@
name;
@@ -432,7 +434,7 @@ private static function handleNamedFunction(
PhpParser\Node\Expr\FuncCall $stmt,
PhpParser\Node\Name $function_name,
Context $context,
- CodeLocation $code_location
+ CodeLocation $code_location,
): FunctionCallInfo {
$function_call_info = new FunctionCallInfo();
@@ -611,7 +613,7 @@ private static function getAnalyzeNamedExpression(
PhpParser\Node\Expr\FuncCall $stmt,
PhpParser\Node\Expr\FuncCall $real_stmt,
PhpParser\Node\Expr $function_name,
- Context $context
+ Context $context,
): FunctionCallInfo {
$function_call_info = new FunctionCallInfo();
@@ -884,7 +886,7 @@ private static function analyzeInvokeCall(
PhpParser\Node\Expr\FuncCall $real_stmt,
PhpParser\Node\Expr $function_name,
Context $context,
- Atomic $atomic_type
+ Atomic $atomic_type,
): void {
$old_data_provider = $statements_analyzer->node_data;
@@ -940,7 +942,7 @@ private static function processAssertFunctionEffects(
Codebase $codebase,
PhpParser\Node\Expr\FuncCall $stmt,
PhpParser\Node\Arg $first_arg,
- Context $context
+ Context $context,
): void {
$first_arg_value_id = spl_object_id($first_arg->value);
@@ -1032,7 +1034,7 @@ private static function checkFunctionCallPurity(
PhpParser\Node\Expr\FuncCall $stmt,
PhpParser\Node $function_name,
FunctionCallInfo $function_call_info,
- Context $context
+ Context $context,
): void {
$config = $codebase->config;
@@ -1120,7 +1122,7 @@ private static function checkFunctionCallPurity(
private static function callUsesByReferenceArguments(
FunctionCallInfo $function_call_info,
- PhpParser\Node\Expr\FuncCall $stmt
+ PhpParser\Node\Expr\FuncCall $stmt,
): bool {
// If the function doesn't have any by-reference parameters
// we shouldn't look any further.
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallInfo.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallInfo.php
index c2e38864d5b..0af657998bf 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallInfo.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallInfo.php
@@ -1,5 +1,7 @@
config;
@@ -312,7 +314,7 @@ private static function getReturnTypeFromCallMapWithArgs(
string $function_id,
array $call_args,
TCallable $callmap_callable,
- Context $context
+ Context $context,
): Union {
$call_map_key = strtolower($function_id);
@@ -533,7 +535,7 @@ private static function taintReturnType(
FunctionLikeStorage $function_storage,
Union &$stmt_type,
TemplateResult $template_result,
- Context $context
+ Context $context,
): ?DataFlowNode {
if (!$statements_analyzer->data_flow_graph) {
return null;
@@ -695,7 +697,7 @@ public static function taintUsingFlows(
CodeLocation $node_location,
DataFlowNode $function_call_node,
array $removed_taints,
- array $added_taints = []
+ array $added_taints = [],
): void {
foreach ($function_storage->return_source_params as $i => $path_type) {
if (!isset($args[$i])) {
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/HighOrderFunctionArgHandler.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/HighOrderFunctionArgHandler.php
index 1f43ee90312..ff627e40f54 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/HighOrderFunctionArgHandler.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/HighOrderFunctionArgHandler.php
@@ -59,7 +59,7 @@ public static function remapLowerBounds(
StatementsAnalyzer $statements_analyzer,
TemplateResult $inferred_template_result,
HighOrderFunctionArgInfo $input_function,
- Union $container_function_type
+ Union $container_function_type,
): TemplateResult {
// Try to infer container callable by $inferred_template_result
$container_type = TemplateInferredTypeReplacer::replace(
@@ -116,7 +116,7 @@ public static function enhanceCallableArgType(
PhpParser\Node\Expr $arg_expr,
StatementsAnalyzer $statements_analyzer,
HighOrderFunctionArgInfo $high_order_callable_info,
- TemplateResult $high_order_template_result
+ TemplateResult $high_order_template_result,
): void {
// Psalm can infer simple callable/closure.
// But can't infer first-class-callable or high-order function.
@@ -152,7 +152,7 @@ public static function getCallableArgInfo(
Context $context,
PhpParser\Node\Expr $input_arg_expr,
StatementsAnalyzer $statements_analyzer,
- FunctionLikeParameter $container_param
+ FunctionLikeParameter $container_param,
): ?HighOrderFunctionArgInfo {
if (!self::isSupported($container_param)) {
return null;
@@ -304,7 +304,7 @@ private static function isSupported(FunctionLikeParameter $container_param): boo
private static function fromLiteralString(
Union $constant,
- StatementsAnalyzer $statements_analyzer
+ StatementsAnalyzer $statements_analyzer,
): ?HighOrderFunctionArgInfo {
$literal = $constant->isSingle() ? $constant->getSingleAtomic() : null;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/HighOrderFunctionArgInfo.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/HighOrderFunctionArgInfo.php
index 526e6ee1141..c7cb62a05a3 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/HighOrderFunctionArgInfo.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/HighOrderFunctionArgInfo.php
@@ -35,7 +35,7 @@ final class HighOrderFunctionArgInfo
public function __construct(
string $type,
FunctionLikeStorage $function_storage,
- ClassLikeStorage $class_storage = null
+ ClassLikeStorage $class_storage = null,
) {
$this->type = $type;
$this->function_storage = $function_storage;
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 7e033b36f1d..131ca47c79e 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicCallContext.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicCallContext.php
@@ -1,5 +1,7 @@
as->isMixed()
@@ -536,7 +538,7 @@ private static function getIntersectionReturnType(
Atomic $lhs_type_part,
?string $lhs_var_id,
AtomicMethodCallAnalysisResult $result,
- array $intersection_types
+ array $intersection_types,
): array {
$all_intersection_return_type = null;
$all_intersection_existent_method_ids = [];
@@ -593,7 +595,7 @@ private static function updateResultReturnType(
AtomicMethodCallAnalysisResult $result,
Union $return_type_candidate,
?Union $all_intersection_return_type,
- Codebase $codebase
+ Codebase $codebase,
): void {
if ($all_intersection_return_type) {
$return_type_candidate = Type::intersectUnionTypes(
@@ -615,7 +617,7 @@ private static function handleInvalidClass(
?string $lhs_var_id,
Context $context,
bool $is_intersection,
- AtomicMethodCallAnalysisResult $result
+ AtomicMethodCallAnalysisResult $result,
): void {
switch (get_class($lhs_type_part)) {
case TNull::class:
@@ -735,7 +737,7 @@ private static function handleTemplatedMixins(
StatementsSource $source,
PhpParser\Node\Expr\MethodCall $stmt,
StatementsAnalyzer $statements_analyzer,
- string $fq_class_name
+ string $fq_class_name,
): array {
$naive_method_exists = false;
@@ -824,7 +826,7 @@ private static function handleRegularMixins(
PhpParser\Node\Expr\MethodCall $stmt,
StatementsAnalyzer $statements_analyzer,
string $fq_class_name,
- ?string $lhs_var_id
+ ?string $lhs_var_id,
): array {
$naive_method_exists = false;
@@ -912,7 +914,7 @@ private static function handleCallableObject(
Context $context,
?TCallable $lhs_type_part_callable,
AtomicMethodCallAnalysisResult $result,
- ?TemplateResult $inferred_template_result = null
+ ?TemplateResult $inferred_template_result = null,
): void {
$method_id = 'object::__invoke';
$result->existent_method_ids[] = $method_id;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/ExistingAtomicMethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/ExistingAtomicMethodCallAnalyzer.php
index 35fda473155..d0de3e5995a 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/ExistingAtomicMethodCallAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/ExistingAtomicMethodCallAnalyzer.php
@@ -1,5 +1,7 @@
config;
@@ -542,7 +544,7 @@ private static function getMagicGetterOrSetterProperty(
PhpParser\Node\Expr\MethodCall $stmt,
PhpParser\Node\Identifier $stmt_name,
Context $context,
- string $fq_class_name
+ string $fq_class_name,
): ?Union {
$method_name = strtolower($stmt_name->name);
if (!in_array($method_name, ['__get', '__set'], true)) {
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 d3d42a95ef3..3953e4908ae 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallProhibitionAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallProhibitionAnalyzer.php
@@ -1,5 +1,7 @@
methods;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallPurityAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallPurityAnalyzer.php
index 760adf93590..9da3c08543c 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallPurityAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallPurityAnalyzer.php
@@ -1,5 +1,7 @@
external_mutation_free
&& $statements_analyzer->node_data->isPureCompatible($stmt->var);
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php
index a3bd4b3b493..a04104107b2 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php
@@ -1,5 +1,7 @@
data_flow_graph
|| !$declaring_method_id
@@ -560,7 +562,7 @@ public static function replaceTemplateTypes(
TemplateResult $template_result,
MethodIdentifier $method_id,
int $arg_count,
- Codebase $codebase
+ Codebase $codebase,
): Union {
if ($template_result->template_types) {
$bindable_template_types = $return_type_candidate->getTemplateTypes();
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 2cc632a35e3..abfe8c080d1 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodVisibilityAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodVisibilityAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
$codebase_methods = $codebase->methods;
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 8e9346d803d..efa26eba6e4 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php
@@ -1,5 +1,7 @@
fq_class_name;
$method_name_lc = $method_id->method_name;
@@ -250,7 +252,7 @@ public static function handleMissingOrMagicMethod(
?string $intersection_method_id,
string $cased_method_id,
AtomicMethodCallAnalysisResult $result,
- ?Atomic $lhs_type_part
+ ?Atomic $lhs_type_part,
): void {
$fq_class_name = $method_id->fq_class_name;
$method_name_lc = $method_id->method_name;
@@ -417,7 +419,7 @@ private static function createFirstClassCallableReturnType(?MethodStorage $metho
private static function findPseudoMethodAndClassStorages(
Codebase $codebase,
ClassLikeStorage $static_class_storage,
- string $method_name_lc
+ string $method_name_lc,
): ?array {
if (isset($static_class_storage->declaring_pseudo_method_ids[$method_name_lc])) {
$method_id = $static_class_storage->declaring_pseudo_method_ids[$method_name_lc];
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php
index 437f65d7510..0635bbafb32 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php
@@ -1,5 +1,7 @@
inside_call;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php
index 874f0618172..a4f0c47d864 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php
@@ -1,5 +1,7 @@
getArgs()[0] ?? null;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php
index 45476ca22b6..b32b19373cb 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php
@@ -1,5 +1,7 @@
classlike_storage_provider->get($fq_class_name);
@@ -627,7 +629,7 @@ private static function analyzeConstructorExpression(
PhpParser\Node\Expr $stmt_class,
Config $config,
?string &$fq_class_name,
- bool &$can_extend
+ bool &$can_extend,
): void {
$was_inside_general_use = $context->inside_general_use;
$context->inside_general_use = true;
@@ -734,7 +736,7 @@ private static function getNewType(
PhpParser\Node\Expr\New_ $stmt,
Union $stmt_class_type,
Config $config,
- bool &$can_extend
+ bool &$can_extend,
): ?Union {
$new_types = [];
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php
index fa7cc498184..5b5cc622874 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php
@@ -1,5 +1,7 @@
data_flow_graph) {
return;
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 b0839345418..cfc1fedaacc 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
@@ -907,7 +909,7 @@ private static function checkPseudoMethod(
array $args,
ClassLikeStorage $class_storage,
MethodStorage $pseudo_method_storage,
- Context $context
+ Context $context,
): ?bool {
if (ArgumentsAnalyzer::analyze(
$statements_analyzer,
@@ -1010,7 +1012,7 @@ public static function handleNonObjectCall(
PhpParser\Node\Expr\StaticCall $stmt,
Context $context,
Atomic $lhs_type_part,
- bool $ignore_nullable_issues
+ bool $ignore_nullable_issues,
): void {
$codebase = $statements_analyzer->getCodebase();
$config = $codebase->config;
@@ -1085,7 +1087,7 @@ public static function handleNonObjectCall(
private static function findPseudoMethodAndClassStorages(
Codebase $codebase,
ClassLikeStorage $static_class_storage,
- string $method_name_lc
+ string $method_name_lc,
): ?array {
if ($pseudo_method_storage = $static_class_storage->pseudo_static_methods[$method_name_lc] ?? null) {
return [$pseudo_method_storage, $static_class_storage];
@@ -1122,7 +1124,7 @@ private static function forwardCallToInstanceMethod(
PhpParser\Node\Identifier $stmt_name,
Context $context,
string $virtual_var_name = 'this',
- bool $always_set_node_type = false
+ bool $always_set_node_type = false,
): bool {
$old_data_provider = $statements_analyzer->node_data;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php
index a8c916534ea..c87fa0f8462 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php
@@ -1,5 +1,7 @@
$args
@@ -66,7 +68,7 @@ public static function analyze(
string $cased_method_id,
ClassLikeStorage $class_storage,
bool &$moved_call,
- ?TemplateResult $inferred_template_result = null
+ ?TemplateResult $inferred_template_result = null,
): void {
$fq_class_name = $method_id->fq_class_name;
$method_name_lc = $method_id->method_name;
@@ -482,7 +484,7 @@ private static function getMethodReturnType(
Context $context,
string $fq_class_name,
ClassLikeStorage $class_storage,
- Config $config
+ Config $config,
): ?Union {
$return_type_candidate = $codebase->methods->getMethodReturnType(
$method_id,
@@ -623,7 +625,7 @@ private static function resolveTemplateResultLowerBound(
StaticCall $stmt,
ClassLikeStorage $class_storage,
MethodIdentifier $method_id,
- TTemplateParam $template_type
+ TTemplateParam $template_type,
): array {
if ($template_type->param_name === 'TFunctionArgCount') {
return [
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
index b82ff146a3d..666ccbc7d8a 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
@@ -1,5 +1,7 @@
getFQCLN();
@@ -278,7 +280,7 @@ public static function checkMethodArgs(
TemplateResult $template_result,
Context $context,
CodeLocation $code_location,
- StatementsAnalyzer $statements_analyzer
+ StatementsAnalyzer $statements_analyzer,
): bool {
$codebase = $statements_analyzer->getCodebase();
@@ -393,7 +395,7 @@ public static function getTemplateTypesForCall(
?string $appearing_class_name,
?ClassLikeStorage $calling_class_storage,
array $existing_template_types = [],
- array $class_template_params = []
+ array $class_template_params = [],
): array {
$template_types = $existing_template_types;
@@ -465,7 +467,7 @@ public static function getGenericParamForOffset(
string $fq_class_name,
string $template_name,
array $template_extended_params,
- array $found_generic_params
+ array $found_generic_params,
): Union {
if (isset($found_generic_params[$template_name][$fq_class_name])) {
return $found_generic_params[$template_name][$fq_class_name];
@@ -498,7 +500,7 @@ public static function getGenericParamForOffset(
*/
public static function getFunctionIdsFromCallableArg(
FileSource $file_source,
- PhpParser\Node\Expr $callable_arg
+ PhpParser\Node\Expr $callable_arg,
): array {
if ($callable_arg instanceof PhpParser\Node\Expr\BinaryOp\Concat) {
if ($callable_arg->left instanceof PhpParser\Node\Expr\ClassConstFetch
@@ -603,7 +605,7 @@ public static function checkFunctionExists(
StatementsAnalyzer $statements_analyzer,
string &$function_id,
CodeLocation $code_location,
- bool $can_be_in_root_scope
+ bool $can_be_in_root_scope,
): bool {
$cased_function_id = $function_id;
$function_id = strtolower($function_id);
@@ -648,7 +650,7 @@ public static function applyAssertionsToContext(
array $args,
TemplateResult $template_result,
Context $context,
- StatementsAnalyzer $statements_analyzer
+ StatementsAnalyzer $statements_analyzer,
): void {
$type_assertions = [];
@@ -973,7 +975,7 @@ public static function checkTemplateResult(
StatementsAnalyzer $statements_analyzer,
TemplateResult $template_result,
CodeLocation $code_location,
- ?string $function_id
+ ?string $function_id,
): void {
if ($template_result->lower_bounds && $template_result->upper_bounds) {
foreach ($template_result->upper_bounds as $template_name => $defining_map) {
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php
index 32b6276b1d2..3856f18a1ad 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php
@@ -1,5 +1,7 @@
expr, $context) === false) {
@@ -310,7 +312,7 @@ public static function castIntAttempt(
StatementsAnalyzer $statements_analyzer,
Union $stmt_type,
PhpParser\Node\Expr $stmt,
- bool $explicit_cast = false
+ bool $explicit_cast = false,
): Union {
$codebase = $statements_analyzer->getCodebase();
@@ -496,7 +498,7 @@ public static function castFloatAttempt(
StatementsAnalyzer $statements_analyzer,
Union $stmt_type,
PhpParser\Node\Expr $stmt,
- bool $explicit_cast = false
+ bool $explicit_cast = false,
): Union {
$codebase = $statements_analyzer->getCodebase();
@@ -682,7 +684,7 @@ public static function castStringAttempt(
Context $context,
Union $stmt_type,
PhpParser\Node\Expr $stmt,
- bool $explicit_cast = false
+ bool $explicit_cast = false,
): Union {
$codebase = $statements_analyzer->getCodebase();
@@ -873,7 +875,7 @@ public static function castStringAttempt(
private static function checkExprGeneralUse(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr\Cast $stmt,
- Context $context
+ Context $context,
): bool {
$was_inside_general_use = $context->inside_general_use;
$context->inside_general_use = true;
@@ -885,7 +887,7 @@ private static function checkExprGeneralUse(
private static function handleRedundantCast(
Union $maybe_type,
StatementsAnalyzer $statements_analyzer,
- PhpParser\Node\Expr\Cast $stmt
+ PhpParser\Node\Expr\Cast $stmt,
): void {
$codebase = $statements_analyzer->getCodebase();
$project_analyzer = $statements_analyzer->getProjectAnalyzer();
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ClassConstAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ClassConstAnalyzer.php
index 2dec200fc9c..15723ccb0e5 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/ClassConstAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ClassConstAnalyzer.php
@@ -1,5 +1,7 @@
class and
@@ -65,7 +67,7 @@ class ClassConstAnalyzer
public static function analyzeFetch(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr\ClassConstFetch $stmt,
- Context $context
+ Context $context,
): bool {
$codebase = $statements_analyzer->getCodebase();
@@ -688,7 +690,7 @@ public static function analyzeFetch(
public static function analyzeAssignment(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Stmt\ClassConst $stmt,
- Context $context
+ Context $context,
): void {
assert($context->self !== null);
$class_storage = $statements_analyzer->getCodebase()->classlike_storage_provider->get($context->self);
@@ -724,7 +726,7 @@ public static function analyzeAssignment(
public static function analyze(
ClassLikeStorage $class_storage,
- Codebase $codebase
+ Codebase $codebase,
): void {
foreach ($class_storage->constants as $const_name => $const_storage) {
[$parent_classlike_storage, $parent_const_storage] = self::getOverriddenConstant(
@@ -822,7 +824,7 @@ private static function getOverriddenConstant(
ClassLikeStorage $class_storage,
ClassConstantStorage $const_storage,
string $const_name,
- Codebase $codebase
+ Codebase $codebase,
): ?array {
$parent_classlike_storage = $interface_const_storage = $parent_const_storage = null;
$interface_overrides = [];
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CloneAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CloneAnalyzer.php
index 7f1927951d2..f29dbba37e1 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/CloneAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CloneAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
$codebase_methods = $codebase->methods;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php
index 9728d331397..8b3e6990a9e 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php
@@ -1,5 +1,7 @@
expr, $context);
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php
index 9792a91c87e..3499c6c244e 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php
@@ -1,5 +1,7 @@
inside_call;
$context->inside_call = true;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php
index 36d6be84b95..17d5827e742 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php
@@ -1,5 +1,7 @@
name)) {
return '$' . $stmt->name;
@@ -75,7 +77,7 @@ public static function getVarId(
public static function getRootVarId(
PhpParser\Node\Expr $stmt,
?string $this_class_name,
- ?FileSource $source = null
+ ?FileSource $source = null,
): ?string {
if ($stmt instanceof PhpParser\Node\Expr\Variable
|| $stmt instanceof PhpParser\Node\Expr\StaticPropertyFetch
@@ -101,7 +103,7 @@ public static function getRootVarId(
public static function getExtendedVarId(
PhpParser\Node\Expr $stmt,
?string $this_class_name,
- ?FileSource $source = null
+ ?FileSource $source = null,
): ?string {
if ($stmt instanceof PhpParser\Node\Expr\Assign) {
return self::getExtendedVarId($stmt->var, $this_class_name, $source);
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php
index 0d005204a95..a57510665e4 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php
@@ -1,5 +1,7 @@
var,
@@ -364,7 +366,7 @@ public static function taintArrayFetch(
?string $keyed_array_var_id,
Union &$stmt_type,
Union &$offset_type,
- ?Context $context = null
+ ?Context $context = null,
): void {
if ($statements_analyzer->data_flow_graph
&& ($stmt_var_type = $statements_analyzer->node_data->getType($var))
@@ -465,7 +467,7 @@ public static function getArrayAccessTypeGivenOffset(
?string $extended_var_id,
Context $context,
PhpParser\Node\Expr $assign_value = null,
- Union $replacement_type = null
+ Union $replacement_type = null,
): Union {
$offset_type = $offset_type_original->getBuilder();
@@ -891,7 +893,7 @@ private static function checkLiteralIntArrayOffset(
?string $extended_var_id,
PhpParser\Node\Expr\ArrayDimFetch $stmt,
Context $context,
- StatementsAnalyzer $statements_analyzer
+ StatementsAnalyzer $statements_analyzer,
): void {
if ($context->inside_isset || $context->inside_unset) {
return;
@@ -939,7 +941,7 @@ private static function checkLiteralStringArrayOffset(
?string $extended_var_id,
PhpParser\Node\Expr\ArrayDimFetch $stmt,
Context $context,
- StatementsAnalyzer $statements_analyzer
+ StatementsAnalyzer $statements_analyzer,
): void {
if ($context->inside_isset || $context->inside_unset) {
return;
@@ -1023,7 +1025,7 @@ public static function handleMixedArrayAccess(
?string $extended_var_id,
PhpParser\Node\Expr\ArrayDimFetch $stmt,
?Union $array_access_type,
- Atomic $type
+ Atomic $type,
): Union {
if (!$context->collect_initializations
&& !$context->collect_mutations
@@ -1111,7 +1113,7 @@ private static function handleArrayAccessOnArray(
array &$expected_offset_types,
?Union &$array_access_type,
bool &$has_array_access,
- bool &$has_valid_offset
+ bool &$has_valid_offset,
): void {
$has_array_access = true;
@@ -1242,7 +1244,7 @@ private static function handleArrayAccessOnTArray(
array &$expected_offset_types,
?Union &$array_access_type,
Atomic $original_type,
- bool &$has_valid_offset
+ bool &$has_valid_offset,
): void {
// if we're assigning to an empty array with a key offset, refashion that array
if ($in_assignment) {
@@ -1406,7 +1408,7 @@ private static function handleArrayAccessOnClassStringMap(
TClassStringMap &$type,
MutableUnion $offset_type,
?Union $replacement_type,
- ?Union &$array_access_type
+ ?Union &$array_access_type,
): void {
$offset_type_parts = array_values($offset_type->getAtomicTypes());
@@ -1516,7 +1518,7 @@ private static function handleArrayAccessOnKeyedArray(
TKeyedArray &$type,
bool $hasMixed,
array &$expected_offset_types,
- bool &$has_valid_offset
+ bool &$has_valid_offset,
): void {
$generic_key_type = $type->getGenericKeyType();
@@ -1741,7 +1743,7 @@ private static function handleArrayAccessOnNamedObject(
bool $in_assignment,
?PhpParser\Node\Expr $assign_value,
?Union &$array_access_type,
- bool &$has_array_access
+ bool &$has_array_access,
): void {
$codebase = $statements_analyzer->getCodebase();
if (strtolower($type->value) === 'simplexmlelement'
@@ -1894,7 +1896,7 @@ private static function handleArrayAccessOnString(
MutableUnion $offset_type,
array &$expected_offset_types,
?Union &$array_access_type,
- bool &$has_valid_offset
+ bool &$has_valid_offset,
): void {
if ($in_assignment && $replacement_type) {
if ($replacement_type->hasMixed()) {
@@ -1977,7 +1979,7 @@ private static function handleArrayAccessOnString(
private static function checkArrayOffsetType(
MutableUnion $offset_type,
array $offset_types,
- Codebase $codebase
+ Codebase $codebase,
): bool {
$has_valid_absolute_offset = false;
foreach ($offset_types as $atomic_offset_type) {
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php
index 758a3d22ca6..44d61115739 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php
@@ -1,5 +1,7 @@
$invalid_fetch_types $invalid_fetch_types
@@ -91,7 +93,7 @@ public static function analyze(
string $prop_name,
bool &$has_valid_fetch_type,
array &$invalid_fetch_types,
- bool $is_static_access = false
+ bool $is_static_access = false,
): void {
if ($lhs_type_part instanceof TNull) {
return;
@@ -545,7 +547,7 @@ public static function checkPropertyDeprecation(
string $prop_name,
string $declaring_property_class,
PhpParser\Node\Expr $stmt,
- StatementsAnalyzer $statements_analyzer
+ StatementsAnalyzer $statements_analyzer,
): void {
$property_id = $declaring_property_class . '::$' . $prop_name;
$codebase = $statements_analyzer->getCodebase();
@@ -586,7 +588,7 @@ private static function propertyFetchCanBeAnalyzed(
?string $declaring_property_class,
ClassLikeStorage $class_storage,
MethodIdentifier $get_method_id,
- bool $in_assignment
+ bool $in_assignment,
): bool {
if ((!$naive_property_exists
|| ($stmt_var_id !== '$this'
@@ -740,7 +742,7 @@ public static function localizePropertyType(
Union $class_property_type,
TGenericObject $lhs_type_part,
ClassLikeStorage $property_class_storage,
- ClassLikeStorage $property_declaring_class_storage
+ ClassLikeStorage $property_declaring_class_storage,
): Union {
$template_types = CallAnalyzer::getTemplateTypesForCall(
$codebase,
@@ -813,7 +815,7 @@ public static function processTaints(
string $property_id,
ClassLikeStorage $class_storage,
bool $in_assignment,
- ?Context $context = null
+ ?Context $context = null,
): void {
if (!$statements_analyzer->data_flow_graph) {
return;
@@ -920,7 +922,7 @@ public static function processUnspecialTaints(
string $property_id,
bool $in_assignment,
?array $added_taints,
- ?array $removed_taints
+ ?array $removed_taints,
): void {
if (!$statements_analyzer->data_flow_graph) {
return;
@@ -977,7 +979,7 @@ private static function handleEnumName(
StatementsAnalyzer $statements_analyzer,
PropertyFetch $stmt,
Union $stmt_var_type,
- ClassLikeStorage $class_storage
+ ClassLikeStorage $class_storage,
): void {
$relevant_enum_cases = array_filter(
$stmt_var_type->getAtomicTypes(),
@@ -1007,7 +1009,7 @@ private static function handleEnumValue(
StatementsAnalyzer $statements_analyzer,
PropertyFetch $stmt,
Union $stmt_var_type,
- ClassLikeStorage $class_storage
+ ClassLikeStorage $class_storage,
): void {
$relevant_enum_cases = array_filter(
$stmt_var_type->getAtomicTypes(),
@@ -1048,7 +1050,7 @@ private static function handleUndefinedProperty(
?string $stmt_var_id,
string $property_id,
bool $has_magic_getter,
- ?string $var_id
+ ?string $var_id,
): void {
if ($context->inside_isset || $context->collect_initializations) {
if ($context->pure) {
@@ -1122,7 +1124,7 @@ private static function handleNonExistentClass(
bool &$class_exists,
bool &$interface_exists,
string &$fq_class_name,
- bool &$override_property_visibility
+ bool &$override_property_visibility,
): void {
if ($codebase->interfaceExists($lhs_type_part->value)) {
$interface_exists = true;
@@ -1200,7 +1202,7 @@ private static function handleNonExistentProperty(
?string $stmt_var_id,
bool $has_magic_getter,
?string $var_id,
- bool &$has_valid_fetch_type
+ bool &$has_valid_fetch_type,
): void {
if (($config->use_phpdoc_property_without_magic_or_parent
|| $class_storage->hasAttributeIncludingParents('AllowDynamicProperties', $codebase))
@@ -1267,7 +1269,7 @@ private static function getClassPropertyType(
string $property_id,
string $fq_class_name,
string $prop_name,
- TNamedObject $lhs_type_part
+ TNamedObject $lhs_type_part,
): Union {
$class_property_type = $codebase->properties->getPropertyType(
$property_id,
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php
index 8b30a60fc91..cce8934324e 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php
@@ -1,5 +1,7 @@
name->toString();
@@ -103,7 +105,7 @@ public static function analyze(
public static function getGlobalConstType(
Codebase $codebase,
string $fq_const_name,
- string $const_name
+ string $const_name,
): ?Union {
if ($const_name === 'STDERR'
|| $const_name === 'STDOUT'
@@ -196,7 +198,7 @@ public static function getConstType(
StatementsAnalyzer $statements_analyzer,
string $const_name,
bool $is_fully_qualified,
- ?Context $context
+ ?Context $context,
): ?Union {
$aliased_constants = $statements_analyzer->getAliases()->constants;
@@ -253,7 +255,7 @@ public static function setConstType(
StatementsAnalyzer $statements_analyzer,
string $const_name,
Union $const_type,
- Context $context
+ Context $context,
): void {
$context->vars_in_scope[$const_name] = $const_type;
$context->constants[$const_name] = $const_type;
@@ -269,7 +271,7 @@ public static function getConstName(
PhpParser\Node\Expr $first_arg_value,
NodeDataProvider $type_provider,
Codebase $codebase,
- Aliases $aliases
+ Aliases $aliases,
): ?string {
$const_name = null;
@@ -293,7 +295,7 @@ public static function getConstName(
public static function analyzeConstAssignment(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Stmt\Const_ $stmt,
- Context $context
+ Context $context,
): void {
foreach ($stmt->consts as $const) {
ExpressionAnalyzer::analyze($statements_analyzer, $const->value, $context);
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php
index 528acd0609d..1502fca7282 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php
@@ -1,5 +1,7 @@
inside_general_use;
$context->inside_general_use = true;
@@ -311,7 +313,7 @@ private static function handleScopedProperty(
PhpParser\Node\Expr\PropertyFetch $stmt,
Codebase $codebase,
?string $stmt_var_id,
- bool $in_assignment
+ bool $in_assignment,
): void {
$stmt_type = $context->vars_in_scope[$var_id];
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php
index 46a4cf0f414..4402a27c048 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php
@@ -1,5 +1,7 @@
class instanceof PhpParser\Node\Name) {
self::analyzeVariableStaticPropertyFetch($statements_analyzer, $stmt->class, $stmt, $context);
@@ -418,7 +420,7 @@ private static function analyzeVariableStaticPropertyFetch(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr $stmt_class,
PhpParser\Node\Expr\StaticPropertyFetch $stmt,
- Context $context
+ Context $context,
): void {
$was_inside_general_use = $context->inside_general_use;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php
index 80ad5e0e97f..b690b0af42a 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php
@@ -1,5 +1,7 @@
getFileAnalyzer()->project_analyzer;
$codebase = $statements_analyzer->getCodebase();
@@ -431,7 +433,7 @@ private static function addDataFlowToVariable(
PhpParser\Node\Expr\Variable $stmt,
string $var_name,
Union &$stmt_type,
- Context $context
+ Context $context,
): void {
$codebase = $statements_analyzer->getCodebase();
@@ -505,7 +507,7 @@ private static function taintVariable(
StatementsAnalyzer $statements_analyzer,
string $var_name,
Union &$type,
- PhpParser\Node\Expr\Variable $stmt
+ PhpParser\Node\Expr\Variable $stmt,
): void {
if ($statements_analyzer->data_flow_graph instanceof TaintFlowGraph
&& !in_array('TaintedInput', $statements_analyzer->getSuppressedIssues())
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/IncDecExpressionAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/IncDecExpressionAnalyzer.php
index 1526bb6a59f..08abb627c4c 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/IncDecExpressionAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/IncDecExpressionAnalyzer.php
@@ -1,5 +1,7 @@
inside_assignment;
$context->inside_assignment = true;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php
index 47241edcffd..83123189023 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
$config = $codebase->config;
@@ -283,7 +285,7 @@ public static function getPathTo(
?NodeDataProvider $type_provider,
?StatementsAnalyzer $statements_analyzer,
string $file_name,
- Config $config
+ Config $config,
): ?string {
if (DIRECTORY_SEPARATOR === '/') {
$is_path_relative = $file_name[0] !== DIRECTORY_SEPARATOR;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/InstanceofAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/InstanceofAnalyzer.php
index 83b04cd9478..c504be5dda2 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/InstanceofAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/InstanceofAnalyzer.php
@@ -1,5 +1,7 @@
inside_general_use;
$context->inside_general_use = true;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/IssetAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/IssetAnalyzer.php
index a9db2fead9e..3d21d156087 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/IssetAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/IssetAnalyzer.php
@@ -1,5 +1,7 @@
vars as $isset_var) {
if ($isset_var instanceof PhpParser\Node\Expr\PropertyFetch
@@ -53,7 +55,7 @@ public static function analyze(
public static function analyzeIssetVar(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr $stmt,
- Context $context
+ Context $context,
): void {
$context->inside_isset = true;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/MagicConstAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/MagicConstAnalyzer.php
index 129266f95d2..948147bb0cc 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/MagicConstAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/MagicConstAnalyzer.php
@@ -1,5 +1,7 @@
node_data->setType($stmt, Type::getIntRange(1, null));
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php
index a76a199089a..38ab1befc28 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php
@@ -1,5 +1,7 @@
inside_call;
@@ -320,7 +322,7 @@ public static function analyze(
private static function convertCondsToConditional(
array $conds,
PhpParser\Node\Expr $match_condition,
- array $attributes
+ array $attributes,
): PhpParser\Node\Expr {
if (count($conds) === 1) {
return new VirtualIdentical(
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/NullsafeAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/NullsafeAnalyzer.php
index 739bb5b7ba2..c6bf23c4f09 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/NullsafeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/NullsafeAnalyzer.php
@@ -1,5 +1,7 @@
var instanceof PhpParser\Node\Expr\Variable) {
$was_inside_general_use = $context->inside_general_use;
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php
index 64cebbc80d4..25f06a23ce7 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/SimpleTypeInferer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/SimpleTypeInferer.php
index 68129233b37..f12b0ebc553 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/SimpleTypeInferer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/SimpleTypeInferer.php
@@ -1,5 +1,7 @@
$existing_class_constants
@@ -56,7 +58,7 @@ public static function infer(
Aliases $aliases,
FileSource $file_source = null,
?array $existing_class_constants = null,
- ?string $fq_classlike_name = null
+ ?string $fq_classlike_name = null,
): ?Union {
if ($stmt instanceof PhpParser\Node\Expr\BinaryOp) {
if ($stmt instanceof PhpParser\Node\Expr\BinaryOp\Concat) {
@@ -516,7 +518,7 @@ private static function inferArrayType(
Aliases $aliases,
FileSource $file_source = null,
?array $existing_class_constants = null,
- ?string $fq_classlike_name = null
+ ?string $fq_classlike_name = null,
): ?Union {
if (count($stmt->items) === 0) {
return Type::getEmptyArray();
@@ -600,7 +602,7 @@ private static function handleArrayItem(
Aliases $aliases,
FileSource $file_source = null,
?array $existing_class_constants = null,
- ?string $fq_classlike_name = null
+ ?string $fq_classlike_name = null,
): bool {
if ($item->unpack) {
$unpacked_array_type = self::infer(
@@ -752,7 +754,7 @@ private static function handleArrayItem(
private static function handleUnpackedArray(
ArrayCreationInfo $array_creation_info,
- Union $unpacked_array_type
+ Union $unpacked_array_type,
): bool {
foreach ($unpacked_array_type->getAtomicTypes() as $unpacked_atomic_type) {
if ($unpacked_atomic_type instanceof TKeyedArray) {
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php
index 7d990eaf1dd..814568e4fdc 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/UnaryPlusMinusAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/UnaryPlusMinusAnalyzer.php
index eb4f256f444..e5d6becf49d 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/UnaryPlusMinusAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/UnaryPlusMinusAnalyzer.php
@@ -1,5 +1,7 @@
expr, $context) === false) {
return false;
@@ -113,7 +115,7 @@ private static function addDataFlow(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr $stmt,
PhpParser\Node\Expr $value,
- string $type
+ string $type,
): void {
$result_type = $statements_analyzer->node_data->getType($stmt);
if ($statements_analyzer->data_flow_graph instanceof VariableUseGraph && $result_type) {
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/YieldAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/YieldAnalyzer.php
index d5e6174b230..c76f52b77c4 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/YieldAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/YieldAnalyzer.php
@@ -1,5 +1,7 @@
getDocComment();
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/YieldFromAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/YieldFromAnalyzer.php
index 03f63c637f3..765f13bd2dd 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/YieldFromAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/YieldFromAnalyzer.php
@@ -1,5 +1,7 @@
inside_call;
diff --git a/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php
index 7cdb1b54a05..870201bc289 100644
--- a/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
@@ -577,7 +579,7 @@ private static function dispatchBeforeExpressionAnalysis(
private static function dispatchAfterExpressionAnalysis(
PhpParser\Node\Expr $expr,
Context $context,
- StatementsAnalyzer $statements_analyzer
+ StatementsAnalyzer $statements_analyzer,
): ?bool {
$codebase = $statements_analyzer->getCodebase();
diff --git a/src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php
index 4eb29ca7b62..bcb7f693304 100644
--- a/src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php
@@ -1,5 +1,7 @@
collect_initializations && !$global_context) {
IssueBuffer::maybeAdd(
diff --git a/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php
index e8724e93969..945dfd60d1f 100644
--- a/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php
@@ -1,5 +1,7 @@
getDocComment();
@@ -564,7 +566,7 @@ private static function handleTaints(
PhpParser\Node\Stmt\Return_ $stmt,
string $cased_method_id,
Union $inferred_type,
- FunctionLikeStorage $storage
+ FunctionLikeStorage $storage,
): void {
if (!$statements_analyzer->data_flow_graph instanceof TaintFlowGraph
|| !$stmt->expr
@@ -604,7 +606,7 @@ private static function handleTaints(
private static function potentiallyInferTypesOnClosureFromParentReturnType(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\FunctionLike $expr,
- Context $context
+ Context $context,
): void {
// if not returning from inside of a function, return
if (!$context->calling_method_id && !$context->calling_function_id) {
@@ -669,7 +671,7 @@ private static function potentiallyInferTypesOnClosureFromParentReturnType(
private static function inferInnerClosureTypeFromParent(
Codebase $codebase,
?Union $return_type,
- ?Union $parent_return_type
+ ?Union $parent_return_type,
): ?Union {
if (!$parent_return_type) {
return $return_type;
diff --git a/src/Psalm/Internal/Analyzer/Statements/StaticAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/StaticAnalyzer.php
index eecb5b84284..02b411bc3d4 100644
--- a/src/Psalm/Internal/Analyzer/Statements/StaticAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/StaticAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
diff --git a/src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php
index c0d1b0b2a45..890c0637204 100644
--- a/src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php
@@ -1,5 +1,7 @@
inside_throw = true;
if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) {
diff --git a/src/Psalm/Internal/Analyzer/Statements/UnsetAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/UnsetAnalyzer.php
index 47180961335..51df9a31c27 100644
--- a/src/Psalm/Internal/Analyzer/Statements/UnsetAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/UnsetAnalyzer.php
@@ -1,5 +1,7 @@
inside_unset = true;
diff --git a/src/Psalm/Internal/Analyzer/Statements/UnusedAssignmentRemover.php b/src/Psalm/Internal/Analyzer/Statements/UnusedAssignmentRemover.php
index 188ad00bb3c..a6fdbdf707a 100644
--- a/src/Psalm/Internal/Analyzer/Statements/UnusedAssignmentRemover.php
+++ b/src/Psalm/Internal/Analyzer/Statements/UnusedAssignmentRemover.php
@@ -1,5 +1,7 @@
@@ -38,7 +40,7 @@ public function findUnusedAssignment(
array $stmts,
array $var_loc_map,
string $var_id,
- CodeLocation $original_location
+ CodeLocation $original_location,
): void {
$search_result = $this->findAssignStmt($stmts, $var_id, $original_location);
[$assign_stmt, $assign_exp] = $search_result;
@@ -122,7 +124,7 @@ private static function getPartialRemovalBounds(
Codebase $codebase,
CodeLocation $var_loc,
int $end_bound,
- bool $assign_ref = false
+ bool $assign_ref = false,
): FileManipulation {
$var_start_loc= $var_loc->raw_file_start;
$stmt_content = $codebase->file_provider->getContents(
@@ -328,7 +330,7 @@ private function findAssignExp(
PhpParser\Node\Expr $current_node,
string $var_id,
int $var_start_loc,
- int $search_level = 1
+ int $search_level = 1,
): array {
if ($current_node instanceof PhpParser\Node\Expr\Assign
|| $current_node instanceof PhpParser\Node\Expr\AssignOp
diff --git a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php
index c944b3bcbd4..183255e19ee 100644
--- a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php
@@ -1,5 +1,7 @@
getCodebase();
@@ -340,7 +342,7 @@ private static function analyzeStatement(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Stmt $stmt,
Context $context,
- ?Context $global_context
+ ?Context $global_context,
): ?bool {
if (self::dispatchBeforeStatementAnalysis($stmt, $context, $statements_analyzer) === false) {
return false;
@@ -715,7 +717,7 @@ private static function analyzeStatement(
private static function dispatchAfterStatementAnalysis(
PhpParser\Node\Stmt $stmt,
Context $context,
- StatementsAnalyzer $statements_analyzer
+ StatementsAnalyzer $statements_analyzer,
): ?bool {
$codebase = $statements_analyzer->getCodebase();
@@ -741,7 +743,7 @@ private static function dispatchAfterStatementAnalysis(
private static function dispatchBeforeStatementAnalysis(
PhpParser\Node\Stmt $stmt,
Context $context,
- StatementsAnalyzer $statements_analyzer
+ StatementsAnalyzer $statements_analyzer,
): ?bool {
$codebase = $statements_analyzer->getCodebase();
@@ -767,7 +769,7 @@ private static function dispatchBeforeStatementAnalysis(
private function parseStatementDocblock(
PhpParser\Comment\Doc $docblock,
PhpParser\Node\Stmt $stmt,
- Context $context
+ Context $context,
): void {
$codebase = $this->getCodebase();
@@ -965,7 +967,7 @@ public function getUnusedVarLocations(): array
public function registerPossiblyUndefinedVariable(
string $undefined_var_id,
- PhpParser\Node\Expr\Variable $stmt
+ PhpParser\Node\Expr\Variable $stmt,
): void {
if (!$this->data_flow_graph) {
return;
diff --git a/src/Psalm/Internal/Analyzer/TraitAnalyzer.php b/src/Psalm/Internal/Analyzer/TraitAnalyzer.php
index c6192a666a5..6f8d4b86c3a 100644
--- a/src/Psalm/Internal/Analyzer/TraitAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/TraitAnalyzer.php
@@ -1,5 +1,7 @@
source = $source;
$this->file_analyzer = $source->getFileAnalyzer();
diff --git a/src/Psalm/Internal/Analyzer/TypeAnalyzer.php b/src/Psalm/Internal/Analyzer/TypeAnalyzer.php
index 0c871fe2200..10267b7568f 100644
--- a/src/Psalm/Internal/Analyzer/TypeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/TypeAnalyzer.php
@@ -1,5 +1,7 @@
use_igbinary = $config->use_igbinary;
}
- /**
- * @return array|object|string|null
- */
- public function getItem(string $path)
+ public function getItem(string $path): array|object|string|null
{
if (!file_exists($path)) {
return null;
@@ -92,10 +91,7 @@ public function deleteItem(string $path): void
}
}
- /**
- * @param array|object|string $item
- */
- public function saveItem(string $path, $item): void
+ public function saveItem(string $path, array|object|string $item): void
{
if ($this->use_igbinary) {
$serialized = (string) igbinary_serialize($item);
diff --git a/src/Psalm/Internal/Clause.php b/src/Psalm/Internal/Clause.php
index 99a6352f7c5..1482bbe736b 100644
--- a/src/Psalm/Internal/Clause.php
+++ b/src/Psalm/Internal/Clause.php
@@ -1,5 +1,7 @@
hash = ($wedge ? 'w' : '') . $creating_object_id;
diff --git a/src/Psalm/Internal/Cli/LanguageServer.php b/src/Psalm/Internal/Cli/LanguageServer.php
index 69a21e5a71f..837e23c82b9 100644
--- a/src/Psalm/Internal/Cli/LanguageServer.php
+++ b/src/Psalm/Internal/Cli/LanguageServer.php
@@ -1,5 +1,7 @@
use_color = !array_key_exists('m', $options);
@@ -812,8 +814,7 @@ private static function initStdoutReportOptions(
return $stdout_report_options;
}
- /** @return never */
- private static function clearGlobalCache(Config $config): void
+ private static function clearGlobalCache(Config $config): never
{
$cache_directory = $config->getGlobalCacheDirectory();
@@ -825,8 +826,7 @@ private static function clearGlobalCache(Config $config): void
exit;
}
- /** @return never */
- private static function clearCache(Config $config): void
+ private static function clearCache(Config $config): never
{
$cache_directory = $config->getCacheDirectory();
@@ -1008,7 +1008,7 @@ private static function initConfig(
?string $path_to_config,
string $output_format,
bool $run_taint_analysis,
- array $options
+ array $options,
): array {
$init_source_dir = null;
if (isset($options['i'])) {
@@ -1043,7 +1043,7 @@ private static function initBaseline(
Config $config,
string $current_dir,
?string $path_to_config,
- ?array $paths_to_check
+ ?array $paths_to_check,
): array {
$issue_baseline = [];
@@ -1118,7 +1118,7 @@ private static function storeFlowGraph(array $options, ProjectAnalyzer $project_
}
/** @return false|'always'|'auto' */
- private static function shouldFindUnusedCode(array $options, Config $config)
+ private static function shouldFindUnusedCode(array $options, Config $config): false|string
{
$find_unused_code = false;
if (isset($options['find-dead-code'])) {
@@ -1146,17 +1146,16 @@ private static function shouldRunTaintAnalysis(array $options): bool
}
/**
- * @param string|bool|null $find_references_to
* @param false|'always'|'auto' $find_unused_code
*/
private static function configureProjectAnalyzer(
array $options,
Config $config,
ProjectAnalyzer $project_analyzer,
- $find_references_to,
- $find_unused_code,
+ string|bool|null $find_references_to,
+ false|string $find_unused_code,
bool $find_unused_variables,
- bool $run_taint_analysis
+ bool $run_taint_analysis,
): void {
if (isset($options['generate-json-map']) && is_string($options['generate-json-map'])) {
$project_analyzer->getCodebase()->store_node_types = true;
@@ -1217,7 +1216,7 @@ private static function configureShepherd(Config $config, array $options, array
private static function generateStubs(
array $options,
Providers $providers,
- ProjectAnalyzer $project_analyzer
+ ProjectAnalyzer $project_analyzer,
): void {
if (isset($options['generate-stubs']) && is_string($options['generate-stubs'])) {
$stubs_location = $options['generate-stubs'];
diff --git a/src/Psalm/Internal/Cli/Psalter.php b/src/Psalm/Internal/Cli/Psalter.php
index d38bd9b3d07..242a27a967b 100644
--- a/src/Psalm/Internal/Cli/Psalter.php
+++ b/src/Psalm/Internal/Cli/Psalter.php
@@ -1,5 +1,7 @@
|null
*/
- public static function getPathsToCheck($f_paths): ?array
+ public static function getPathsToCheck(string|array|false|null $f_paths): ?array
{
$paths_to_check = [];
@@ -341,7 +342,7 @@ public static function initializeConfig(
string $current_dir,
string $output_format,
?ClassLoader $first_autoloader,
- bool $create_if_non_existent = false
+ bool $create_if_non_existent = false,
): Config {
try {
if ($path_to_config) {
diff --git a/src/Psalm/Internal/Codebase/Analyzer.php b/src/Psalm/Internal/Codebase/Analyzer.php
index 66f6f15c323..e7eb49e1c15 100644
--- a/src/Psalm/Internal/Codebase/Analyzer.php
+++ b/src/Psalm/Internal/Codebase/Analyzer.php
@@ -1,5 +1,7 @@
config = $config;
$this->file_provider = $file_provider;
@@ -233,7 +235,7 @@ public function canReportIssues(string $file_path): bool
private function getFileAnalyzer(
ProjectAnalyzer $project_analyzer,
string $file_path,
- array $filetype_analyzers
+ array $filetype_analyzers,
): FileAnalyzer {
$extension = pathinfo($file_path, PATHINFO_EXTENSION);
@@ -254,7 +256,7 @@ public function analyzeFiles(
ProjectAnalyzer $project_analyzer,
int $pool_size,
bool $alter_code,
- bool $consolidate_analyzed_data = false
+ bool $consolidate_analyzed_data = false,
): void {
$this->loadCachedResults($project_analyzer);
@@ -1188,7 +1190,7 @@ public function addNodeType(
string $file_path,
PhpParser\Node $node,
string $node_type,
- PhpParser\Node $parent_node = null
+ PhpParser\Node $parent_node = null,
): void {
if ($node_type === '') {
throw new UnexpectedValueException('non-empty node_type expected');
@@ -1205,7 +1207,7 @@ public function addNodeArgument(
int $start_position,
int $end_position,
string $reference,
- int $argument_number
+ int $argument_number,
): void {
if ($reference === '') {
throw new UnexpectedValueException('non-empty reference expected');
diff --git a/src/Psalm/Internal/Codebase/AssertionsFromInheritanceResolver.php b/src/Psalm/Internal/Codebase/AssertionsFromInheritanceResolver.php
index aa42e2a8942..397633c5e19 100644
--- a/src/Psalm/Internal/Codebase/AssertionsFromInheritanceResolver.php
+++ b/src/Psalm/Internal/Codebase/AssertionsFromInheritanceResolver.php
@@ -22,7 +22,7 @@ final class AssertionsFromInheritanceResolver
private Codebase $codebase;
public function __construct(
- Codebase $codebase
+ Codebase $codebase,
) {
$this->codebase = $codebase;
}
@@ -32,7 +32,7 @@ public function __construct(
*/
public function resolve(
MethodStorage $method_storage,
- ClassLikeStorage $called_class
+ ClassLikeStorage $called_class,
): array {
$method_name_lc = strtolower($method_storage->cased_name ?? '');
diff --git a/src/Psalm/Internal/Codebase/ClassLikes.php b/src/Psalm/Internal/Codebase/ClassLikes.php
index 09fb0ed8d85..e7af2f4a19b 100644
--- a/src/Psalm/Internal/Codebase/ClassLikes.php
+++ b/src/Psalm/Internal/Codebase/ClassLikes.php
@@ -1,5 +1,7 @@
config = $config;
$this->classlike_storage_provider = $storage_provider;
@@ -325,7 +327,7 @@ public function hasFullyQualifiedClassName(
string $fq_class_name,
?CodeLocation $code_location = null,
?string $calling_fq_class_name = null,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
$fq_class_name_lc = strtolower($this->getUnAliasedName($fq_class_name));
@@ -392,7 +394,7 @@ public function hasFullyQualifiedInterfaceName(
string $fq_class_name,
?CodeLocation $code_location = null,
?string $calling_fq_class_name = null,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
$fq_class_name_lc = strtolower($this->getUnAliasedName($fq_class_name));
@@ -459,7 +461,7 @@ public function hasFullyQualifiedEnumName(
string $fq_class_name,
?CodeLocation $code_location = null,
?string $calling_fq_class_name = null,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
$fq_class_name_lc = strtolower($this->getUnAliasedName($fq_class_name));
@@ -549,7 +551,7 @@ public function classOrInterfaceExists(
string $fq_class_name,
?CodeLocation $code_location = null,
?string $calling_fq_class_name = null,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
return $this->classExists($fq_class_name, $code_location, $calling_fq_class_name, $calling_method_id)
|| $this->interfaceExists($fq_class_name, $code_location, $calling_fq_class_name, $calling_method_id);
@@ -562,7 +564,7 @@ public function classOrInterfaceOrEnumExists(
string $fq_class_name,
?CodeLocation $code_location = null,
?string $calling_fq_class_name = null,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
return $this->classExists($fq_class_name, $code_location, $calling_fq_class_name, $calling_method_id)
|| $this->interfaceExists($fq_class_name, $code_location, $calling_fq_class_name, $calling_method_id)
@@ -576,7 +578,7 @@ public function classExists(
string $fq_class_name,
?CodeLocation $code_location = null,
?string $calling_fq_class_name = null,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
if (isset(ClassLikeAnalyzer::SPECIAL_TYPES[$fq_class_name])) {
return false;
@@ -676,7 +678,7 @@ public function interfaceExists(
string $fq_interface_name,
?CodeLocation $code_location = null,
?string $calling_fq_class_name = null,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
if (isset(ClassLikeAnalyzer::SPECIAL_TYPES[strtolower($fq_interface_name)])) {
return false;
@@ -694,7 +696,7 @@ public function enumExists(
string $fq_enum_name,
?CodeLocation $code_location = null,
?string $calling_fq_class_name = null,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
if (isset(ClassLikeAnalyzer::SPECIAL_TYPES[strtolower($fq_enum_name)])) {
return false;
@@ -918,7 +920,7 @@ public function consolidateAnalyzedData(Methods $methods, ?Progress $progress, b
public static function makeImmutable(
PhpParser\Node\Stmt\Class_ $class_stmt,
ProjectAnalyzer $project_analyzer,
- string $file_path
+ string $file_path,
): void {
$manipulator = ClassDocblockManipulator::getForClass(
$project_analyzer,
@@ -1194,7 +1196,7 @@ public function handleClassLikeReferenceInMigration(
string $fq_class_name,
?string $calling_method_id,
bool $force_change = false,
- bool $was_self = false
+ bool $was_self = false,
): bool {
if ($class_name_node instanceof VirtualNode) {
return false;
@@ -1376,7 +1378,7 @@ public function handleDocblockTypeInMigration(
StatementsSource $source,
Union $type,
CodeLocation $type_location,
- ?string $calling_method_id
+ ?string $calling_method_id,
): void {
$calling_fq_class_name = $source->getFQCLN();
$fq_class_name_lc = strtolower($calling_fq_class_name ?? '');
@@ -1506,7 +1508,7 @@ public function airliftClassLikeReference(
int $source_start,
int $source_end,
bool $add_class_constant = false,
- bool $allow_self = false
+ bool $allow_self = false,
): void {
$project_analyzer = ProjectAnalyzer::getInstance();
$codebase = $project_analyzer->getCodebase();
@@ -1542,7 +1544,7 @@ public function airliftClassDefinedDocblockType(
string $destination_fq_class_name,
string $source_file_path,
int $source_start,
- int $source_end
+ int $source_end,
): void {
$project_analyzer = ProjectAnalyzer::getInstance();
$codebase = $project_analyzer->getCodebase();
@@ -1616,7 +1618,7 @@ public function getClassConstantType(
?StatementsAnalyzer $statements_analyzer = null,
array $visited_constant_ids = [],
bool $late_static_binding = false,
- bool $in_value_of_context = false
+ bool $in_value_of_context = false,
): ?Union {
$class_name = strtolower($class_name);
@@ -2394,7 +2396,7 @@ private function getConstantType(
int $visibility,
?StatementsAnalyzer $statements_analyzer,
array $visited_constant_ids,
- bool $late_static_binding
+ bool $late_static_binding,
): ?Union {
$constant_resolver = new StorageByPatternResolver();
$resolved_constants = $constant_resolver->resolveConstants(
@@ -2456,7 +2458,7 @@ private function getConstantType(
private function getEnumType(
ClassLikeStorage $class_like_storage,
- string $constant_name
+ string $constant_name,
): ?Union {
$constant_resolver = new StorageByPatternResolver();
$resolved_enums = $constant_resolver->resolveEnums(
@@ -2478,7 +2480,7 @@ private function getEnumType(
private function filterConstantNameByVisibility(
ClassConstantStorage $constant_storage,
- int $visibility
+ int $visibility,
): bool {
if ($visibility === ReflectionProperty::IS_PUBLIC
diff --git a/src/Psalm/Internal/Codebase/ConstantTypeResolver.php b/src/Psalm/Internal/Codebase/ConstantTypeResolver.php
index 97ced9bfe62..2d826dc0891 100644
--- a/src/Psalm/Internal/Codebase/ConstantTypeResolver.php
+++ b/src/Psalm/Internal/Codebase/ConstantTypeResolver.php
@@ -1,5 +1,7 @@
id;
$to_id = $to->id;
@@ -63,7 +65,7 @@ public function addPath(
protected static function shouldIgnoreFetch(
string $path_type,
string $expression_type,
- array $previous_path_types
+ array $previous_path_types,
): bool {
$el = strlen($expression_type);
diff --git a/src/Psalm/Internal/Codebase/Functions.php b/src/Psalm/Internal/Codebase/Functions.php
index 122534b1301..2cb3ffefd88 100644
--- a/src/Psalm/Internal/Codebase/Functions.php
+++ b/src/Psalm/Internal/Codebase/Functions.php
@@ -1,5 +1,7 @@
existence_provider->has($function_id)) {
$function_exists = $this->existence_provider->doesFunctionExist($statements_analyzer, $function_id);
@@ -265,7 +267,7 @@ public function getMatchingFunctionNames(
string $stub,
int $offset,
string $file_path,
- Codebase $codebase
+ Codebase $codebase,
): array {
if ($stub[0] === '*') {
$stub = substr($stub, 1);
@@ -390,7 +392,7 @@ public function isCallMapFunctionPure(
?NodeTypeProvider $type_provider,
string $function_id,
?array $args,
- bool &$must_use = true
+ bool &$must_use = true,
): bool {
if (ImpureFunctionsList::isImpure($function_id)) {
return false;
diff --git a/src/Psalm/Internal/Codebase/ImpureFunctionsList.php b/src/Psalm/Internal/Codebase/ImpureFunctionsList.php
index 386598af477..80c1817b149 100644
--- a/src/Psalm/Internal/Codebase/ImpureFunctionsList.php
+++ b/src/Psalm/Internal/Codebase/ImpureFunctionsList.php
@@ -1,5 +1,7 @@
classlike_storage_provider = $storage_provider;
$this->file_reference_provider = $file_reference_provider;
@@ -99,7 +101,7 @@ public function methodExists(
?StatementsSource $source = null,
?string $source_file_path = null,
bool $use_method_existence_provider = true,
- bool $is_used = false
+ bool $is_used = false,
): bool {
$fq_class_name = $method_id->fq_class_name;
$method_name = $method_id->method_name;
@@ -346,7 +348,7 @@ public function getMethodParams(
MethodIdentifier $method_id,
?StatementsSource $source = null,
?array $args = null,
- ?Context $context = null
+ ?Context $context = null,
): array {
$fq_class_name = $method_id->fq_class_name;
$method_name = $method_id->method_name;
@@ -492,7 +494,7 @@ public static function localizeType(
Codebase $codebase,
Union $type,
string $appearing_fq_class_name,
- string $base_fq_class_name
+ string $base_fq_class_name,
): Union {
$class_storage = $codebase->classlike_storage_provider->get($appearing_fq_class_name);
$extends = $class_storage->template_extended_params;
@@ -515,7 +517,7 @@ public static function localizeType(
*/
public static function getExtendedTemplatedTypes(
TTemplateParam $atomic_type,
- array $extends
+ array $extends,
): array {
$extra_added_types = [];
@@ -558,7 +560,7 @@ public function getMethodReturnType(
?string &$self_class,
?SourceAnalyzer $source_analyzer = null,
?array $args = null,
- ?TemplateResult $template_result = null
+ ?TemplateResult $template_result = null,
): ?Union {
$original_fq_class_name = $method_id->fq_class_name;
$original_method_name = $method_id->method_name;
@@ -935,7 +937,7 @@ public function getMethodReturnsByRef(MethodIdentifier $method_id): bool
public function getMethodReturnTypeLocation(
MethodIdentifier $method_id,
- CodeLocation &$defined_location = null
+ CodeLocation &$defined_location = null,
): ?CodeLocation {
$method_id = $this->getDeclaringMethodId($method_id);
@@ -975,7 +977,7 @@ public function setDeclaringMethodId(
string $fq_class_name,
string $method_name_lc,
string $declaring_fq_class_name,
- string $declaring_method_name_lc
+ string $declaring_method_name_lc,
): void {
$class_storage = $this->classlike_storage_provider->get($fq_class_name);
@@ -993,7 +995,7 @@ public function setAppearingMethodId(
string $fq_class_name,
string $method_name_lc,
string $appearing_fq_class_name,
- string $appearing_method_name_lc
+ string $appearing_method_name_lc,
): void {
$class_storage = $this->classlike_storage_provider->get($fq_class_name);
@@ -1005,7 +1007,7 @@ public function setAppearingMethodId(
/** @psalm-mutation-free */
public function getDeclaringMethodId(
- MethodIdentifier $method_id
+ MethodIdentifier $method_id,
): ?MethodIdentifier {
$fq_class_name = $this->classlikes->getUnAliasedName($method_id->fq_class_name);
@@ -1030,7 +1032,7 @@ public function getDeclaringMethodId(
* Get the class this method appears in (vs is declared in, which could give a trait
*/
public function getAppearingMethodId(
- MethodIdentifier $method_id
+ MethodIdentifier $method_id,
): ?MethodIdentifier {
$fq_class_name = $this->classlikes->getUnAliasedName($method_id->fq_class_name);
diff --git a/src/Psalm/Internal/Codebase/Populator.php b/src/Psalm/Internal/Codebase/Populator.php
index 022cc684e46..37688a034ea 100644
--- a/src/Psalm/Internal/Codebase/Populator.php
+++ b/src/Psalm/Internal/Codebase/Populator.php
@@ -1,5 +1,7 @@
classlike_storage_provider = $classlike_storage_provider;
$this->file_storage_provider = $file_storage_provider;
@@ -273,7 +275,7 @@ private function populateClassLikeStorage(ClassLikeStorage $storage, array $depe
private function populateOverriddenMethods(
ClassLikeStorage $storage,
- ClassLikeStorageProvider $storage_provider
+ ClassLikeStorageProvider $storage_provider,
): void {
$interface_method_implementers = [];
foreach ($storage->class_implements as $interface) {
@@ -426,7 +428,7 @@ private function populateDataFromTrait(
ClassLikeStorage $storage,
ClassLikeStorageProvider $storage_provider,
array $dependent_classlikes,
- string $used_trait_lc
+ string $used_trait_lc,
): void {
try {
$used_trait_lc = strtolower(
@@ -456,7 +458,7 @@ private function populateDataFromTrait(
private static function extendType(
Union $type,
- ClassLikeStorage $storage
+ ClassLikeStorage $storage,
): Union {
$extended_types = [];
@@ -489,7 +491,7 @@ private function populateDataFromParentClass(
ClassLikeStorage $storage,
ClassLikeStorageProvider $storage_provider,
array $dependent_classlikes,
- string $parent_storage_class
+ string $parent_storage_class,
): void {
$parent_storage_class = strtolower(
$this->classlikes->getUnAliasedName(
@@ -568,7 +570,7 @@ private function populateInterfaceData(
ClassLikeStorage $storage,
ClassLikeStorage $interface_storage,
ClassLikeStorageProvider $storage_provider,
- array $dependent_classlikes
+ array $dependent_classlikes,
): void {
$this->populateClassLikeStorage($interface_storage, $dependent_classlikes);
@@ -610,7 +612,7 @@ private function populateInterfaceData(
private static function extendTemplateParams(
ClassLikeStorage $storage,
ClassLikeStorage $parent_storage,
- bool $from_direct_parent
+ bool $from_direct_parent,
): void {
if ($parent_storage->yield && !$storage->yield) {
$storage->yield = $parent_storage->yield;
@@ -670,7 +672,7 @@ private function populateInterfaceDataFromParentInterface(
ClassLikeStorage $storage,
ClassLikeStorageProvider $storage_provider,
array $dependent_classlikes,
- string $parent_interface_lc
+ string $parent_interface_lc,
): void {
try {
$parent_interface_lc = strtolower(
@@ -716,7 +718,7 @@ private function populateDataFromImplementedInterface(
ClassLikeStorage $storage,
ClassLikeStorageProvider $storage_provider,
array $dependent_classlikes,
- string $implemented_interface_lc
+ string $implemented_interface_lc,
): void {
try {
$implemented_interface_lc = strtolower(
@@ -879,7 +881,7 @@ private function populateFileStorage(FileStorage $storage, array $dependent_file
private function inheritConstantsFromTrait(
ClassLikeStorage $storage,
- ClassLikeStorage $trait_storage
+ ClassLikeStorage $trait_storage,
): void {
if (!$trait_storage->is_trait) {
throw new Exception('Class like storage is not for a trait.');
@@ -915,7 +917,7 @@ private function inheritConstantsFromTrait(
protected function inheritMethodsFromParent(
ClassLikeStorage $storage,
- ClassLikeStorage $parent_storage
+ ClassLikeStorage $parent_storage,
): void {
$fq_class_name = $storage->name;
$fq_class_name_lc = strtolower($fq_class_name);
@@ -1030,7 +1032,7 @@ protected function inheritMethodsFromParent(
private function inheritPropertiesFromParent(
ClassLikeStorage $storage,
- ClassLikeStorage $parent_storage
+ ClassLikeStorage $parent_storage,
): void {
if ($parent_storage->sealed_properties !== null) {
$storage->sealed_properties = $parent_storage->sealed_properties;
diff --git a/src/Psalm/Internal/Codebase/Properties.php b/src/Psalm/Internal/Codebase/Properties.php
index ac7c8add999..4547721fe1b 100644
--- a/src/Psalm/Internal/Codebase/Properties.php
+++ b/src/Psalm/Internal/Codebase/Properties.php
@@ -1,5 +1,7 @@
classlike_storage_provider = $storage_provider;
$this->file_reference_provider = $file_reference_provider;
@@ -61,7 +63,7 @@ public function propertyExists(
bool $read_mode,
?StatementsSource $source = null,
?Context $context = null,
- ?CodeLocation $code_location = null
+ ?CodeLocation $code_location = null,
): bool {
// remove leading backslash if it exists
$property_id = ltrim($property_id, '\\');
@@ -168,7 +170,7 @@ public function propertyExists(
public function getDeclaringClassForProperty(
string $property_id,
bool $read_mode,
- ?StatementsSource $source = null
+ ?StatementsSource $source = null,
): ?string {
[$fq_class_name, $property_name] = explode('::$', $property_id);
@@ -199,7 +201,7 @@ public function getDeclaringClassForProperty(
public function getAppearingClassForProperty(
string $property_id,
bool $read_mode,
- ?StatementsSource $source = null
+ ?StatementsSource $source = null,
): ?string {
[$fq_class_name, $property_name] = explode('::$', $property_id);
@@ -269,7 +271,7 @@ public function getPropertyType(
string $property_id,
bool $property_set,
?StatementsSource $source = null,
- ?Context $context = null
+ ?Context $context = null,
): ?Union {
// remove leading backslash if it exists
$property_id = ltrim($property_id, '\\');
diff --git a/src/Psalm/Internal/Codebase/PropertyMap.php b/src/Psalm/Internal/Codebase/PropertyMap.php
index d66c58c4579..384bdea4705 100644
--- a/src/Psalm/Internal/Codebase/PropertyMap.php
+++ b/src/Psalm/Internal/Codebase/PropertyMap.php
@@ -1,5 +1,7 @@
>|null
diff --git a/src/Psalm/Internal/Codebase/ReferenceMapGenerator.php b/src/Psalm/Internal/Codebase/ReferenceMapGenerator.php
index 1421846bc1d..acacc918ed0 100644
--- a/src/Psalm/Internal/Codebase/ReferenceMapGenerator.php
+++ b/src/Psalm/Internal/Codebase/ReferenceMapGenerator.php
@@ -1,5 +1,7 @@
*/
public static function getReferenceMap(
ClassLikeStorageProvider $classlike_storage_provider,
- array $expected_references
+ array $expected_references,
): array {
$reference_dictionary = [];
diff --git a/src/Psalm/Internal/Codebase/Reflection.php b/src/Psalm/Internal/Codebase/Reflection.php
index 06f6178844b..d4c083641f5 100644
--- a/src/Psalm/Internal/Codebase/Reflection.php
+++ b/src/Psalm/Internal/Codebase/Reflection.php
@@ -1,5 +1,7 @@
storage_provider->get($parent_class);
$storage = $this->storage_provider->get($fq_class_name);
@@ -472,7 +474,7 @@ private function registerInheritedMethods(
*/
private function registerInheritedProperties(
string $fq_class_name,
- string $parent_class
+ string $parent_class,
): void {
$parent_storage = $this->storage_provider->get($parent_class);
$storage = $this->storage_provider->get($fq_class_name);
diff --git a/src/Psalm/Internal/Codebase/Scanner.php b/src/Psalm/Internal/Codebase/Scanner.php
index 2d90f765b68..aaa5e5c6aea 100644
--- a/src/Psalm/Internal/Codebase/Scanner.php
+++ b/src/Psalm/Internal/Codebase/Scanner.php
@@ -1,5 +1,7 @@
codebase = $codebase;
$this->reflection = $reflection;
@@ -226,7 +228,7 @@ public function queueClassLikeForScanning(
string $fq_classlike_name,
bool $analyze_too = false,
bool $store_failure = true,
- array $phantom_classes = []
+ array $phantom_classes = [],
): void {
if ($fq_classlike_name[0] === '\\') {
$fq_classlike_name = substr($fq_classlike_name, 1);
@@ -524,7 +526,7 @@ private function convertClassesToFilePaths(ClassLikes $classlikes): void
private function scanFile(
string $file_path,
array $filetype_scanners,
- bool $will_analyze = false
+ bool $will_analyze = false,
): void {
$file_scanner = $this->getScannerForPath($file_path, $filetype_scanners, $will_analyze);
@@ -618,7 +620,7 @@ private function scanFile(
private function getScannerForPath(
string $file_path,
array $filetype_scanners,
- bool $will_analyze = false
+ bool $will_analyze = false,
): FileScanner {
$path_parts = explode(DIRECTORY_SEPARATOR, $file_path);
$file_name_parts = explode('.', array_pop($path_parts));
diff --git a/src/Psalm/Internal/Codebase/StorageByPatternResolver.php b/src/Psalm/Internal/Codebase/StorageByPatternResolver.php
index ed5baed6dba..f075fd81895 100644
--- a/src/Psalm/Internal/Codebase/StorageByPatternResolver.php
+++ b/src/Psalm/Internal/Codebase/StorageByPatternResolver.php
@@ -26,7 +26,7 @@ final class StorageByPatternResolver
*/
public function resolveConstants(
ClassLikeStorage $class_like_storage,
- string $pattern
+ string $pattern,
): array {
$constants = $class_like_storage->constants;
@@ -59,7 +59,7 @@ public function resolveConstants(
*/
public function resolveEnums(
ClassLikeStorage $class_like_storage,
- string $pattern
+ string $pattern,
): array {
$enum_cases = $class_like_storage->enum_cases;
if (strpos($pattern, '*') === false) {
diff --git a/src/Psalm/Internal/Codebase/TaintFlowGraph.php b/src/Psalm/Internal/Codebase/TaintFlowGraph.php
index 548e95cf50e..5c5f72173eb 100644
--- a/src/Psalm/Internal/Codebase/TaintFlowGraph.php
+++ b/src/Psalm/Internal/Codebase/TaintFlowGraph.php
@@ -1,5 +1,7 @@
*/
private array $sources = [];
@@ -247,7 +249,7 @@ private function getChildNodes(
DataFlowNode $generated_source,
array $source_taints,
array $sinks,
- array $visited_source_ids
+ array $visited_source_ids,
): array {
$new_sources = [];
diff --git a/src/Psalm/Internal/Codebase/VariableUseGraph.php b/src/Psalm/Internal/Codebase/VariableUseGraph.php
index 22069bca81f..711dc6882d3 100644
--- a/src/Psalm/Internal/Codebase/VariableUseGraph.php
+++ b/src/Psalm/Internal/Codebase/VariableUseGraph.php
@@ -1,5 +1,7 @@
> */
protected array $backward_edges = [];
@@ -38,7 +40,7 @@ public function addPath(
DataFlowNode $to,
string $path_type,
?array $added_taints = null,
- ?array $removed_taints = null
+ ?array $removed_taints = null,
): void {
$from_id = $from->id;
$to_id = $to->id;
@@ -146,7 +148,7 @@ public function getOriginLocations(DataFlowNode $assignment_node): array
*/
private function getChildNodes(
DataFlowNode $generated_source,
- array $visited_source_ids
+ array $visited_source_ids,
): ?array {
$new_child_nodes = [];
@@ -202,7 +204,7 @@ private function getChildNodes(
*/
private function getParentNodes(
DataFlowNode $destination,
- array $visited_source_ids
+ array $visited_source_ids,
): array {
$new_parent_nodes = [];
diff --git a/src/Psalm/Internal/Composer.php b/src/Psalm/Internal/Composer.php
index 52ac9350ac3..5810e643907 100644
--- a/src/Psalm/Internal/Composer.php
+++ b/src/Psalm/Internal/Composer.php
@@ -1,5 +1,7 @@
id = $id;
@@ -67,7 +69,7 @@ final public static function getForMethodArgument(
string $cased_method_id,
int $argument_offset,
?CodeLocation $arg_location,
- ?CodeLocation $code_location = null
+ ?CodeLocation $code_location = null,
): self {
$arg_id = strtolower($method_id) . '#' . ($argument_offset + 1);
@@ -93,7 +95,7 @@ final public static function getForMethodArgument(
final public static function getForAssignment(
string $var_id,
CodeLocation $assignment_location,
- ?string $specialization_key = null
+ ?string $specialization_key = null,
): self {
$id = $var_id
. '-' . $assignment_location->file_name
@@ -110,7 +112,7 @@ final public static function getForMethodReturn(
string $method_id,
string $cased_method_id,
?CodeLocation $code_location,
- ?CodeLocation $function_location = null
+ ?CodeLocation $function_location = null,
): self {
$specialization_key = null;
diff --git a/src/Psalm/Internal/DataFlow/Path.php b/src/Psalm/Internal/DataFlow/Path.php
index a6de16c95ee..6e233f66e0d 100644
--- a/src/Psalm/Internal/DataFlow/Path.php
+++ b/src/Psalm/Internal/DataFlow/Path.php
@@ -1,5 +1,7 @@
type = $type;
$this->length = $length;
diff --git a/src/Psalm/Internal/DataFlow/TaintSink.php b/src/Psalm/Internal/DataFlow/TaintSink.php
index 2d89b628d3c..42a75b2f4c8 100644
--- a/src/Psalm/Internal/DataFlow/TaintSink.php
+++ b/src/Psalm/Internal/DataFlow/TaintSink.php
@@ -1,10 +1,12 @@
type = $type;
$this->old = $old;
diff --git a/src/Psalm/Internal/Diff/FileDiffer.php b/src/Psalm/Internal/Diff/FileDiffer.php
index 668c6456bc5..e6812050b3d 100644
--- a/src/Psalm/Internal/Diff/FileDiffer.php
+++ b/src/Psalm/Internal/Diff/FileDiffer.php
@@ -23,7 +23,7 @@
*
* @internal
*/
-class FileDiffer
+final class FileDiffer
{
/**
* @param list $a
@@ -33,7 +33,7 @@ class FileDiffer
*/
private static function calculateTrace(
array $a,
- array $b
+ array $b,
): array {
$n = count($a);
$m = count($b);
diff --git a/src/Psalm/Internal/Diff/FileStatementsDiffer.php b/src/Psalm/Internal/Diff/FileStatementsDiffer.php
index 5c51a8f0c82..c5928ae0a15 100644
--- a/src/Psalm/Internal/Diff/FileStatementsDiffer.php
+++ b/src/Psalm/Internal/Diff/FileStatementsDiffer.php
@@ -1,5 +1,7 @@
* @internal
*/
-class BuildInfoCollector
+final class BuildInfoCollector
{
/**
* Environment variables.
diff --git a/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php b/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php
index d9ec447db52..5111b381d0b 100644
--- a/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php
+++ b/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php
@@ -1,5 +1,7 @@
* @internal
*/
-class GitInfoCollector
+final class GitInfoCollector
{
/**
* Git command.
diff --git a/src/Psalm/Internal/ExecutionEnvironment/SystemCommandExecutor.php b/src/Psalm/Internal/ExecutionEnvironment/SystemCommandExecutor.php
index 20aa0383bd0..8db721f4e34 100644
--- a/src/Psalm/Internal/ExecutionEnvironment/SystemCommandExecutor.php
+++ b/src/Psalm/Internal/ExecutionEnvironment/SystemCommandExecutor.php
@@ -1,5 +1,7 @@
>
@@ -37,7 +39,7 @@ class ClassDocblockManipulator
public static function getForClass(
ProjectAnalyzer $project_analyzer,
string $file_path,
- Class_ $stmt
+ Class_ $stmt,
): self {
if (isset(self::$manipulators[$file_path][$stmt->getLine()])) {
return self::$manipulators[$file_path][$stmt->getLine()];
@@ -53,7 +55,7 @@ public static function getForClass(
private function __construct(
ProjectAnalyzer $project_analyzer,
Class_ $stmt,
- string $file_path
+ string $file_path,
) {
$this->stmt = $stmt;
$docblock = $stmt->getDocComment();
diff --git a/src/Psalm/Internal/FileManipulation/CodeMigration.php b/src/Psalm/Internal/FileManipulation/CodeMigration.php
index 641e6aaf5d1..9c703dea506 100644
--- a/src/Psalm/Internal/FileManipulation/CodeMigration.php
+++ b/src/Psalm/Internal/FileManipulation/CodeMigration.php
@@ -1,5 +1,7 @@
source_file_path = $source_file_path;
$this->source_start = $source_start;
diff --git a/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php b/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php
index 7bd147c06ec..6d411f01839 100644
--- a/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php
+++ b/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php
@@ -1,5 +1,7 @@
*/
private static array $file_manipulations = [];
@@ -53,7 +55,7 @@ public static function addCodeMigrations(array $code_migrations): void
private static function getCodeOffsets(
string $source_file_path,
int $source_start,
- int $source_end
+ int $source_end,
): array {
if (!isset(self::$file_manipulations[$source_file_path])) {
return [0, 0];
@@ -81,7 +83,7 @@ private static function getCodeOffsets(
public static function addForCodeLocation(
CodeLocation $code_location,
string $replacement_text,
- bool $swallow_newlines = false
+ bool $swallow_newlines = false,
): void {
$bounds = $code_location->getSnippetBounds();
diff --git a/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php b/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php
index b04952c0581..12ac9be6ea4 100644
--- a/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php
+++ b/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php
@@ -1,5 +1,7 @@
getLine()])) {
return self::$manipulators[$file_path][$stmt->getLine()];
@@ -273,7 +274,7 @@ public function setReturnType(
string $new_type,
string $phpdoc_type,
bool $is_php_compatible,
- ?string $description
+ ?string $description,
): void {
$new_type = str_replace(['', ''], '', $new_type);
@@ -291,7 +292,7 @@ public function setParamType(
string $param_name,
?string $php_type,
string $new_type,
- string $phpdoc_type
+ string $phpdoc_type,
): void {
$new_type = str_replace(['', '', ''], '', $new_type);
diff --git a/src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php b/src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php
index 3894e4edf81..3f00530e5bb 100644
--- a/src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php
+++ b/src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php
@@ -1,5 +1,7 @@
>
@@ -58,7 +60,7 @@ class PropertyDocblockManipulator
public static function getForProperty(
ProjectAnalyzer $project_analyzer,
string $file_path,
- Property $stmt
+ Property $stmt,
): self {
if (isset(self::$manipulators[$file_path][$stmt->getLine()])) {
return self::$manipulators[$file_path][$stmt->getLine()];
@@ -74,7 +76,7 @@ public static function getForProperty(
private function __construct(
ProjectAnalyzer $project_analyzer,
Property $stmt,
- string $file_path
+ string $file_path,
) {
$this->stmt = $stmt;
$docblock = $stmt->getDocComment();
@@ -139,7 +141,7 @@ public function setType(
string $new_type,
string $phpdoc_type,
bool $is_php_compatible,
- ?string $description = null
+ ?string $description = null,
): void {
$new_type = str_replace(['', '', ''], '', $new_type);
diff --git a/src/Psalm/Internal/Fork/ForkMessage.php b/src/Psalm/Internal/Fork/ForkMessage.php
index bd1e1460a78..5672c7a6554 100644
--- a/src/Psalm/Internal/Fork/ForkMessage.php
+++ b/src/Psalm/Internal/Fork/ForkMessage.php
@@ -1,5 +1,7 @@
data = $data;
}
diff --git a/src/Psalm/Internal/Fork/ForkProcessErrorMessage.php b/src/Psalm/Internal/Fork/ForkProcessErrorMessage.php
index 6bf9acb2c12..1c59bac6793 100644
--- a/src/Psalm/Internal/Fork/ForkProcessErrorMessage.php
+++ b/src/Psalm/Internal/Fork/ForkProcessErrorMessage.php
@@ -1,5 +1,7 @@
data = $data;
}
diff --git a/src/Psalm/Internal/Fork/Pool.php b/src/Psalm/Internal/Fork/Pool.php
index a206eb4d711..6a4145aaac1 100644
--- a/src/Psalm/Internal/Fork/Pool.php
+++ b/src/Psalm/Internal/Fork/Pool.php
@@ -1,5 +1,7 @@
task_done_closure = $task_done_closure;
diff --git a/src/Psalm/Internal/Fork/PsalmRestarter.php b/src/Psalm/Internal/Fork/PsalmRestarter.php
index a0d0ff3366e..4350badbff6 100644
--- a/src/Psalm/Internal/Fork/PsalmRestarter.php
+++ b/src/Psalm/Internal/Fork/PsalmRestarter.php
@@ -1,5 +1,7 @@
true,
diff --git a/src/Psalm/Internal/IncludeCollector.php b/src/Psalm/Internal/IncludeCollector.php
index ba37946d8c9..9b336ecc1a2 100644
--- a/src/Psalm/Internal/IncludeCollector.php
+++ b/src/Psalm/Internal/IncludeCollector.php
@@ -1,5 +1,7 @@
status === self::STATUS_ACTIVE) {
throw new LogicException('Progress has already been started');
diff --git a/src/Psalm/Internal/LanguageServer/Client/Progress/ProgressInterface.php b/src/Psalm/Internal/LanguageServer/Client/Progress/ProgressInterface.php
index 78f045c2c53..8760e0b4c2e 100644
--- a/src/Psalm/Internal/LanguageServer/Client/Progress/ProgressInterface.php
+++ b/src/Psalm/Internal/LanguageServer/Client/Progress/ProgressInterface.php
@@ -1,5 +1,7 @@
hideWarnings = $hideWarnings;
$this->provideCompletion = $provideCompletion;
diff --git a/src/Psalm/Internal/LanguageServer/ClientHandler.php b/src/Psalm/Internal/LanguageServer/ClientHandler.php
index d935bef2358..29d2cce6914 100644
--- a/src/Psalm/Internal/LanguageServer/ClientHandler.php
+++ b/src/Psalm/Internal/LanguageServer/ClientHandler.php
@@ -13,7 +13,7 @@
/**
* @internal
*/
-class ClientHandler
+final class ClientHandler
{
public ProtocolReader $protocolReader;
@@ -35,7 +35,7 @@ public function __construct(ProtocolReader $protocolReader, ProtocolWriter $prot
* @param array|object $params The method parameters
* @return mixed Resolved with the result of the request or rejected with an error
*/
- public function request(string $method, $params)
+ public function request(string $method, array|object $params): mixed
{
$id = $this->idGenerator->generate();
@@ -77,7 +77,7 @@ function (Message $msg) use ($id, $deferred, &$listener): void {
* @param string $method The method to call
* @param array|object $params The method parameters
*/
- public function notify(string $method, $params): void
+ public function notify(string $method, array|object $params): void
{
$this->protocolWriter->write(
new Message(
diff --git a/src/Psalm/Internal/LanguageServer/EmitterInterface.php b/src/Psalm/Internal/LanguageServer/EmitterInterface.php
index e331456fd11..35d66388a1b 100644
--- a/src/Psalm/Internal/LanguageServer/EmitterInterface.php
+++ b/src/Psalm/Internal/LanguageServer/EmitterInterface.php
@@ -47,7 +47,7 @@ public function on(string $eventName, callable $callBack, int $priority = 100):
public function emit(
string $eventName,
array $arguments = [],
- ?callable $continueCallBack = null
+ ?callable $continueCallBack = null,
): void;
/**
diff --git a/src/Psalm/Internal/LanguageServer/EmitterTrait.php b/src/Psalm/Internal/LanguageServer/EmitterTrait.php
index c20ebe3b812..03f06a5b3d1 100644
--- a/src/Psalm/Internal/LanguageServer/EmitterTrait.php
+++ b/src/Psalm/Internal/LanguageServer/EmitterTrait.php
@@ -77,7 +77,7 @@ public function on(string $eventName, callable $callBack, int $priority = 100):
public function emit(
string $eventName,
array $arguments = [],
- ?callable $continueCallBack = null
+ ?callable $continueCallBack = null,
): void {
if ($continueCallBack === null) {
foreach ($this->listeners($eventName) as $listener) {
diff --git a/src/Psalm/Internal/LanguageServer/IdGenerator.php b/src/Psalm/Internal/LanguageServer/IdGenerator.php
index 330015db5e7..29540b62625 100644
--- a/src/Psalm/Internal/LanguageServer/IdGenerator.php
+++ b/src/Psalm/Internal/LanguageServer/IdGenerator.php
@@ -9,7 +9,7 @@
*
* @internal
*/
-class IdGenerator
+final class IdGenerator
{
public int $counter = 1;
diff --git a/src/Psalm/Internal/LanguageServer/LanguageClient.php b/src/Psalm/Internal/LanguageServer/LanguageClient.php
index 8f403307e28..f23985592bd 100644
--- a/src/Psalm/Internal/LanguageServer/LanguageClient.php
+++ b/src/Psalm/Internal/LanguageServer/LanguageClient.php
@@ -22,7 +22,7 @@
/**
* @internal
*/
-class LanguageClient
+final class LanguageClient
{
/**
* Handles textDocument/* methods
@@ -53,7 +53,7 @@ public function __construct(
ProtocolReader $reader,
ProtocolWriter $writer,
LanguageServer $server,
- ClientConfiguration $clientConfiguration
+ ClientConfiguration $clientConfiguration,
) {
$this->handler = new ClientHandler($reader, $writer);
$this->server = $server;
diff --git a/src/Psalm/Internal/LanguageServer/LanguageServer.php b/src/Psalm/Internal/LanguageServer/LanguageServer.php
index 50c70c3f56f..e155881c860 100644
--- a/src/Psalm/Internal/LanguageServer/LanguageServer.php
+++ b/src/Psalm/Internal/LanguageServer/LanguageServer.php
@@ -94,7 +94,7 @@
* @psalm-api
* @internal
*/
-class LanguageServer extends Dispatcher
+final class LanguageServer extends Dispatcher
{
/**
* Handles textDocument/* method calls
@@ -146,7 +146,7 @@ public function __construct(
Codebase $codebase,
ClientConfiguration $clientConfiguration,
Progress $progress,
- PathMapper $path_mapper
+ PathMapper $path_mapper,
) {
parent::__construct($this, '/');
@@ -239,7 +239,7 @@ public static function run(
ClientConfiguration $clientConfiguration,
string $base_dir,
PathMapper $path_mapper,
- bool $inMemory = false
+ bool $inMemory = false,
): void {
$progress = new Progress();
@@ -371,7 +371,7 @@ public function initialize(
?ClientInfo $clientInfo = null,
?string $rootUri = null,
?string $trace = null,
- ?string $workDoneToken = null
+ ?string $workDoneToken = null,
): InitializeResult {
$this->clientInfo = $clientInfo;
$this->clientCapabilities = $capabilities;
diff --git a/src/Psalm/Internal/LanguageServer/Message.php b/src/Psalm/Internal/LanguageServer/Message.php
index 56b46c23350..400cf9d0dbb 100644
--- a/src/Psalm/Internal/LanguageServer/Message.php
+++ b/src/Psalm/Internal/LanguageServer/Message.php
@@ -13,7 +13,7 @@
/**
* @internal
*/
-class Message
+final class Message
{
public ?MessageBody $body = null;
diff --git a/src/Psalm/Internal/LanguageServer/PHPMarkdownContent.php b/src/Psalm/Internal/LanguageServer/PHPMarkdownContent.php
index 3290ea5cd4c..a6141a98536 100644
--- a/src/Psalm/Internal/LanguageServer/PHPMarkdownContent.php
+++ b/src/Psalm/Internal/LanguageServer/PHPMarkdownContent.php
@@ -15,7 +15,7 @@
* @psalm-api
* @internal
*/
-class PHPMarkdownContent extends MarkupContent implements JsonSerializable
+final class PHPMarkdownContent extends MarkupContent implements JsonSerializable
{
public string $code;
@@ -38,18 +38,16 @@ public function __construct(string $code, ?string $title = null, ?string $descri
}
parent::__construct(
MarkupKind::MARKDOWN,
- "$markdown```php\n */
private array $cache = [];
@@ -29,7 +31,7 @@ public function writeToCache(ClassLikeStorage $storage, ?string $file_path, ?str
public function getLatestFromCache(
string $fq_classlike_name_lc,
?string $file_path,
- ?string $file_contents
+ ?string $file_contents,
): ClassLikeStorage {
$cached_value = $this->loadFromCache($fq_classlike_name_lc);
diff --git a/src/Psalm/Internal/LanguageServer/Provider/FileReferenceCacheProvider.php b/src/Psalm/Internal/LanguageServer/Provider/FileReferenceCacheProvider.php
index ca12912ec0a..434013020c6 100644
--- a/src/Psalm/Internal/LanguageServer/Provider/FileReferenceCacheProvider.php
+++ b/src/Psalm/Internal/LanguageServer/Provider/FileReferenceCacheProvider.php
@@ -1,5 +1,7 @@
*/
private array $cache = [];
diff --git a/src/Psalm/Internal/LanguageServer/Provider/ParserCacheProvider.php b/src/Psalm/Internal/LanguageServer/Provider/ParserCacheProvider.php
index 0b30a2dda57..47861abe470 100644
--- a/src/Psalm/Internal/LanguageServer/Provider/ParserCacheProvider.php
+++ b/src/Psalm/Internal/LanguageServer/Provider/ParserCacheProvider.php
@@ -1,5 +1,7 @@
@@ -39,7 +41,7 @@ public function __construct()
public function loadStatementsFromCache(
string $file_path,
int $file_modified_time,
- string $file_content_hash
+ string $file_content_hash,
): ?array {
if (isset($this->statements_cache[$file_path])
&& $this->statements_cache_time[$file_path] >= $file_modified_time
@@ -70,7 +72,7 @@ public function saveStatementsToCache(
string $file_path,
string $file_content_hash,
array $stmts,
- bool $touch_only
+ bool $touch_only,
): void {
$this->statements_cache[$file_path] = $stmts;
$this->statements_cache_time[$file_path] = microtime(true);
diff --git a/src/Psalm/Internal/LanguageServer/Provider/ProjectCacheProvider.php b/src/Psalm/Internal/LanguageServer/Provider/ProjectCacheProvider.php
index ed210fa0ae2..ed85e5f4107 100644
--- a/src/Psalm/Internal/LanguageServer/Provider/ProjectCacheProvider.php
+++ b/src/Psalm/Internal/LanguageServer/Provider/ProjectCacheProvider.php
@@ -1,5 +1,7 @@
server = $server;
$this->codebase = $codebase;
diff --git a/src/Psalm/Internal/LanguageServer/Server/Workspace.php b/src/Psalm/Internal/LanguageServer/Server/Workspace.php
index 129fa4e5b9c..2ce097eb0eb 100644
--- a/src/Psalm/Internal/LanguageServer/Server/Workspace.php
+++ b/src/Psalm/Internal/LanguageServer/Server/Workspace.php
@@ -23,7 +23,7 @@
*
* @internal
*/
-class Workspace
+final class Workspace
{
protected LanguageServer $server;
@@ -34,7 +34,7 @@ class Workspace
public function __construct(
LanguageServer $server,
Codebase $codebase,
- ProjectAnalyzer $project_analyzer
+ ProjectAnalyzer $project_analyzer,
) {
$this->server = $server;
$this->codebase = $codebase;
@@ -106,9 +106,9 @@ public function didChangeWatchedFiles(array $changes): void
/**
* A notification sent from the client to the server to signal the change of configuration settings.
*
- * @psalm-suppress PossiblyUnusedMethod
+ * @psalm-suppress PossiblyUnusedMethod, UnusedParam
*/
- public function didChangeConfiguration(): void
+ public function didChangeConfiguration(mixed $settings): void
{
$this->server->logDebug(
'workspace/didChangeConfiguration',
@@ -120,10 +120,9 @@ public function didChangeConfiguration(): void
* The workspace/executeCommand request is sent from the client to the server to
* trigger command execution on the server.
*
- * @param mixed $arguments
* @psalm-suppress PossiblyUnusedMethod
*/
- public function executeCommand(string $command, $arguments): void
+ public function executeCommand(string $command, mixed $arguments): void
{
$this->server->logDebug(
'workspace/executeCommand',
diff --git a/src/Psalm/Internal/MethodIdentifier.php b/src/Psalm/Internal/MethodIdentifier.php
index ad519202430..c41a4b8ba9e 100644
--- a/src/Psalm/Internal/MethodIdentifier.php
+++ b/src/Psalm/Internal/MethodIdentifier.php
@@ -1,5 +1,7 @@
>
diff --git a/src/Psalm/Internal/PhpVisitor/CheckTrivialExprVisitor.php b/src/Psalm/Internal/PhpVisitor/CheckTrivialExprVisitor.php
index c3289c5e3c4..9c1bfa9de3f 100644
--- a/src/Psalm/Internal/PhpVisitor/CheckTrivialExprVisitor.php
+++ b/src/Psalm/Internal/PhpVisitor/CheckTrivialExprVisitor.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/PhpVisitor/CloningVisitor.php b/src/Psalm/Internal/PhpVisitor/CloningVisitor.php
index f6a089b1f87..1005caee248 100644
--- a/src/Psalm/Internal/PhpVisitor/CloningVisitor.php
+++ b/src/Psalm/Internal/PhpVisitor/CloningVisitor.php
@@ -14,7 +14,7 @@
*
* @internal
*/
-class CloningVisitor extends NodeVisitorAbstract
+final class CloningVisitor extends NodeVisitorAbstract
{
public function enterNode(Node $node): Node
{
diff --git a/src/Psalm/Internal/PhpVisitor/ConditionCloningVisitor.php b/src/Psalm/Internal/PhpVisitor/ConditionCloningVisitor.php
index b1e4018a1b0..c0c4d3e3f5a 100644
--- a/src/Psalm/Internal/PhpVisitor/ConditionCloningVisitor.php
+++ b/src/Psalm/Internal/PhpVisitor/ConditionCloningVisitor.php
@@ -12,7 +12,7 @@
/**
* @internal
*/
-class ConditionCloningVisitor extends NodeVisitorAbstract
+final class ConditionCloningVisitor extends NodeVisitorAbstract
{
private NodeDataProvider $type_provider;
diff --git a/src/Psalm/Internal/PhpVisitor/NodeCleanerVisitor.php b/src/Psalm/Internal/PhpVisitor/NodeCleanerVisitor.php
index 2342123c24c..fc60185ab27 100644
--- a/src/Psalm/Internal/PhpVisitor/NodeCleanerVisitor.php
+++ b/src/Psalm/Internal/PhpVisitor/NodeCleanerVisitor.php
@@ -1,5 +1,7 @@
*/
private array $offset_map;
@@ -54,7 +56,7 @@ public function __construct(
Collecting $error_handler,
array $offset_map,
string $a_file_contents,
- string $b_file_contents
+ string $b_file_contents,
) {
$this->parser = $parser;
$this->error_handler = $error_handler;
@@ -65,10 +67,7 @@ public function __construct(
$this->non_method_changes = count($offset_map);
}
- /**
- * @return null|int|PhpParser\Node
- */
- public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true)
+ public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true): int|PhpParser\Node|null
{
/** @var array{startFilePos: int, endFilePos: int, startLine: int} */
$attrs = $node->getAttributes();
diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php b/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php
index 339d86229d0..db63d7e2ddc 100644
--- a/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php
+++ b/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php
@@ -1,5 +1,7 @@
name instanceof PhpParser\Node\Name\FullyQualified) {
$fq_type_string = (string)$stmt->name;
diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php
index ce32fbcd8ba..6e9f8715852 100644
--- a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php
+++ b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php
@@ -1,5 +1,7 @@
getCodebase();
@@ -529,7 +531,7 @@ protected static function addMagicPropertyToInfo(
Doc $comment,
ClassLikeDocblockComment $info,
array $specials,
- string $property_tag
+ string $property_tag,
): void {
$magic_property_comments = $specials[$property_tag] ?? [];
diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php
index b39a8c394b3..49958adcd0b 100644
--- a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php
+++ b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php
@@ -1,5 +1,7 @@
codebase = $codebase;
$this->file_storage = $file_storage;
@@ -959,7 +961,7 @@ public function handleTraitUse(PhpParser\Node\Stmt\TraitUse $node): void
private function extendTemplatedType(
ClassLikeStorage $storage,
PhpParser\Node\Stmt\ClassLike $node,
- string $extended_class_name
+ string $extended_class_name,
): void {
if (trim($extended_class_name) === '') {
$storage->docblock_issues[] = new InvalidDocblock(
@@ -1043,7 +1045,7 @@ private function extendTemplatedType(
private function implementTemplatedType(
ClassLikeStorage $storage,
PhpParser\Node\Stmt\ClassLike $node,
- string $implemented_class_name
+ string $implemented_class_name,
): void {
if (trim($implemented_class_name) === '') {
$storage->docblock_issues[] = new InvalidDocblock(
@@ -1129,7 +1131,7 @@ private function implementTemplatedType(
private function useTemplatedType(
ClassLikeStorage $storage,
PhpParser\Node\Stmt\TraitUse $node,
- string $used_class_name
+ string $used_class_name,
): void {
if (trim($used_class_name) === '') {
$storage->docblock_issues[] = new InvalidDocblock(
@@ -1245,7 +1247,7 @@ private static function registerEmptyConstructor(ClassLikeStorage $class_storage
private function visitClassConstDeclaration(
PhpParser\Node\Stmt\ClassConst $stmt,
ClassLikeStorage $storage,
- string $fq_classlike_name
+ string $fq_classlike_name,
): void {
if ($storage->is_trait && $this->codebase->analysis_php_version_id < 8_02_00) {
IssueBuffer::maybeAdd(new ConstantDeclarationInTrait(
@@ -1409,7 +1411,7 @@ private function visitClassConstDeclaration(
private function visitEnumDeclaration(
PhpParser\Node\Stmt\EnumCase $stmt,
ClassLikeStorage $storage,
- string $fq_classlike_name
+ string $fq_classlike_name,
): void {
if (isset($storage->constants[$stmt->name->name])) {
IssueBuffer::maybeAdd(new DuplicateConstant(
@@ -1509,7 +1511,7 @@ private function getAttributeStorageFromStatement(
FileStorage $file_storage,
Aliases $aliases,
PhpParser\Node\Stmt $stmt,
- ?string $fq_classlike_name
+ ?string $fq_classlike_name,
): array {
$storages = [];
foreach ($stmt->attrGroups as $attr_group) {
@@ -1534,7 +1536,7 @@ private function visitPropertyDeclaration(
PhpParser\Node\Stmt\Property $stmt,
Config $config,
ClassLikeStorage $storage,
- string $fq_classlike_name
+ string $fq_classlike_name,
): void {
$comment = $stmt->getDocComment();
$var_comment = null;
@@ -1868,7 +1870,7 @@ public static function getTypeAliasesFromComment(
PhpParser\Comment\Doc $comment,
Aliases $aliases,
?array $type_aliases,
- ?string $self_fqcln
+ ?string $self_fqcln,
): array {
$parsed_docblock = DocComment::parsePreservingLength($comment);
@@ -1899,7 +1901,7 @@ private static function getTypeAliasesFromCommentLines(
array $type_alias_comment_lines,
Aliases $aliases,
?array $type_aliases,
- ?string $self_fqcln
+ ?string $self_fqcln,
): array {
$type_alias_tokens = [];
diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php b/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php
index ac05615b4fe..0255eef98c7 100644
--- a/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php
+++ b/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php
@@ -1,5 +1,7 @@
expr);
@@ -404,7 +406,7 @@ public static function enterConditional(
private static function functionEvaluatesToTrue(
Codebase $codebase,
string $file_path,
- PhpParser\Node\Expr\FuncCall $function
+ PhpParser\Node\Expr\FuncCall $function,
): ?bool {
if (!$function->name instanceof PhpParser\Node\Name) {
return null;
diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php
index 696b7497d70..bf5ac885de6 100644
--- a/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php
+++ b/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php
@@ -1,5 +1,7 @@
$return_block) {
$return_lines = explode("\n", $return_block);
@@ -709,7 +711,7 @@ private static function extractAllParamNames(array $lines): array
private static function checkUnexpectedTags(
ParsedDocblock $parsed_docblock,
FunctionDocblockComment $info,
- PhpParser\Comment\Doc $comment
+ PhpParser\Comment\Doc $comment,
): void {
if (isset($parsed_docblock->tags['psalm-import-type'])) {
$info->unexpected_tags['psalm-import-type']['lines'] = self::tagOffsetsToLines(
diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php
index 5514169c401..0d9bc183cba 100644
--- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php
+++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php
@@ -1,5 +1,7 @@
> $existing_function_template_types
@@ -88,7 +90,7 @@ public static function addDocblockInfo(
FunctionDocblockComment $docblock_info,
bool $is_functionlike_override,
bool $fake_method,
- string $cased_function_id
+ string $cased_function_id,
): void {
self::handleUnexpectedTags($docblock_info, $storage, $stmt, $file_scanner, $cased_function_id);
@@ -441,7 +443,7 @@ private static function getConditionalSanitizedTypeTokens(
FunctionLikeStorage $storage,
?ClassLikeStorage $classlike_storage,
string $cased_function_id,
- array $function_template_types
+ array $function_template_types,
): array {
$fixed_type_tokens = TypeTokenizer::getFullyQualifiedTokens(
$docblock_return_type,
@@ -568,7 +570,7 @@ private static function getAssertionParts(
array $class_template_types,
array $function_template_types,
array $type_aliases,
- ?string $self_fqcln
+ ?string $self_fqcln,
): ?array {
$is_negation = false;
$is_loose_equality = false;
@@ -703,7 +705,7 @@ private static function improveParamsFromDocblock(
array $docblock_params,
PhpParser\Node\FunctionLike $function,
bool $fake_method,
- ?string $fq_classlike_name
+ ?string $fq_classlike_name,
): void {
$base = $classlike_storage ? $classlike_storage->name . '::' : '';
@@ -936,7 +938,7 @@ private static function handleReturn(
array $type_aliases,
?ClassLikeStorage $classlike_storage,
string $cased_function_id,
- FileStorage $file_storage
+ FileStorage $file_storage,
): void {
if (!$fake_method
&& $docblock_info->return_type_line_number
@@ -1072,7 +1074,7 @@ private static function handleReturn(
private static function handleTaintFlow(
FunctionDocblockComment $docblock_info,
- FunctionLikeStorage $storage
+ FunctionLikeStorage $storage,
): void {
if ($docblock_info->flows) {
foreach ($docblock_info->flows as $flow) {
@@ -1160,7 +1162,7 @@ private static function handleRemovedTaint(
?ClassLikeStorage $classlike_storage,
string $cased_function_id,
FileStorage $file_storage,
- FileScanner $file_scanner
+ FileScanner $file_scanner,
): void {
try {
[$fixed_type_tokens, $function_template_types] = self::getConditionalSanitizedTypeTokens(
@@ -1215,7 +1217,7 @@ private static function handleAssertions(
array $class_template_types,
array $function_template_types,
array $type_aliases,
- ?ClassLikeStorage $classlike_storage
+ ?ClassLikeStorage $classlike_storage,
): void {
if ($docblock_info->assertions) {
$storage->assertions = [];
@@ -1376,7 +1378,7 @@ private static function handleParamOut(
PhpParser\Node\FunctionLike $stmt,
FunctionLikeStorage $storage,
Codebase $codebase,
- FileStorage $file_storage
+ FileStorage $file_storage,
): void {
$param_name = substr($docblock_param_out['name'], 1);
@@ -1428,7 +1430,7 @@ private static function handleTemplates(
array $type_aliases,
FileScanner $file_scanner,
PhpParser\Node\FunctionLike $stmt,
- string $cased_function_id
+ string $cased_function_id,
): array {
$storage->template_types = [];
@@ -1497,7 +1499,7 @@ private static function handleUnexpectedTags(
FunctionLikeStorage $storage,
PhpParser\Node\FunctionLike $stmt,
FileScanner $file_scanner,
- string $cased_function_id
+ string $cased_function_id,
): void {
foreach ($docblock_info->unexpected_tags as $tag => $details) {
foreach ($details['lines'] as $line) {
diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php
index e0ba4e3478b..b2bc3a4f6af 100644
--- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php
+++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php
@@ -1,5 +1,7 @@
codebase = $codebase;
$this->file_storage = $file_storage;
@@ -120,10 +122,11 @@ public function __construct(
/**
* @param bool $fake_method in the case of @method annotations we do something a little strange
- * @return FunctionStorage|MethodStorage|false
*/
- public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = false)
- {
+ public function start(
+ PhpParser\Node\FunctionLike $stmt,
+ bool $fake_method = false,
+ ): FunctionStorage|MethodStorage|false {
if ($stmt instanceof PhpParser\Node\Expr\Closure
|| $stmt instanceof PhpParser\Node\Expr\ArrowFunction
) {
@@ -243,6 +246,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal
if ($stmt instanceof PhpParser\Node\Stmt\Function_
|| $stmt instanceof PhpParser\Node\Stmt\ClassMethod
) {
+ /** @psalm-suppress RedundantCondition See https://github.com/vimeo/psalm/issues/10296 */
if ($stmt instanceof PhpParser\Node\Stmt\ClassMethod
&& $storage instanceof MethodStorage
&& $classlike_storage
@@ -733,7 +737,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal
private function inferPropertyTypeFromConstructor(
PhpParser\Node\Stmt\ClassMethod $stmt,
MethodStorage $storage,
- ClassLikeStorage $classlike_storage
+ ClassLikeStorage $classlike_storage,
): void {
if (!$stmt->stmts) {
return;
@@ -800,7 +804,7 @@ private function getTranslatedFunctionParam(
PhpParser\Node\Param $param,
PhpParser\Node\FunctionLike $stmt,
bool $fake_method,
- ?string $fq_classlike_name
+ ?string $fq_classlike_name,
): FunctionLikeParameter {
$param_type = null;
diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php b/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php
index 3e5fcef5d45..786b59e72d3 100644
--- a/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php
+++ b/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php
@@ -1,5 +1,7 @@
codebase = $codebase;
$this->file_scanner = $file_scanner;
diff --git a/src/Psalm/Internal/PhpVisitor/ShortClosureVisitor.php b/src/Psalm/Internal/PhpVisitor/ShortClosureVisitor.php
index fe0bd1f4a92..18137b22723 100644
--- a/src/Psalm/Internal/PhpVisitor/ShortClosureVisitor.php
+++ b/src/Psalm/Internal/PhpVisitor/ShortClosureVisitor.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php
index d33c19d64e8..3b13e077bac 100644
--- a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php
+++ b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php
@@ -1,5 +1,7 @@
*/
private array $matching_trait_nodes = [];
diff --git a/src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php b/src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php
index 354a639e4cc..1236d8c0b47 100644
--- a/src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php
+++ b/src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php
@@ -11,14 +11,14 @@
/**
* @internal
*/
-class TypeMappingVisitor extends NodeVisitorAbstract
+final class TypeMappingVisitor extends NodeVisitorAbstract
{
private NodeDataProvider $fake_type_provider;
private NodeDataProvider $real_type_provider;
public function __construct(
NodeDataProvider $fake_type_provider,
- NodeDataProvider $real_type_provider
+ NodeDataProvider $real_type_provider,
) {
$this->fake_type_provider = $fake_type_provider;
$this->real_type_provider = $real_type_provider;
diff --git a/src/Psalm/Internal/PhpVisitor/YieldTypeCollector.php b/src/Psalm/Internal/PhpVisitor/YieldTypeCollector.php
index 4d9f075a5e7..ddb1360bd92 100644
--- a/src/Psalm/Internal/PhpVisitor/YieldTypeCollector.php
+++ b/src/Psalm/Internal/PhpVisitor/YieldTypeCollector.php
@@ -1,5 +1,7 @@
*/
private array $yield_types = [];
diff --git a/src/Psalm/Internal/PluginManager/Command/DisableCommand.php b/src/Psalm/Internal/PluginManager/Command/DisableCommand.php
index c6b5dd1d89e..9104dbaa904 100644
--- a/src/Psalm/Internal/PluginManager/Command/DisableCommand.php
+++ b/src/Psalm/Internal/PluginManager/Command/DisableCommand.php
@@ -1,5 +1,7 @@
loadFromCache($fq_classlike_name_lc, $file_path);
@@ -121,7 +123,7 @@ private function loadFromCache(string $fq_classlike_name_lc, ?string $file_path)
private function getCacheLocationForClass(
string $fq_classlike_name_lc,
?string $file_path,
- bool $create_directory = false
+ bool $create_directory = false,
): string {
$root_cache_directory = $this->cache->getCacheDirectory();
diff --git a/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php b/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php
index 9b8c82617ea..8260b207d18 100644
--- a/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php
+++ b/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php
@@ -1,5 +1,7 @@
isFirstClassCallable()) {
return null;
diff --git a/src/Psalm/Internal/Provider/FakeFileProvider.php b/src/Psalm/Internal/Provider/FakeFileProvider.php
index 756e0d72806..a5e18fd7bb8 100644
--- a/src/Psalm/Internal/Provider/FakeFileProvider.php
+++ b/src/Psalm/Internal/Provider/FakeFileProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/FileProvider.php b/src/Psalm/Internal/Provider/FileProvider.php
index aa4202d032c..b070f7f3625 100644
--- a/src/Psalm/Internal/Provider/FileProvider.php
+++ b/src/Psalm/Internal/Provider/FileProvider.php
@@ -1,5 +1,7 @@
>|false
*/
- public function getAnalyzedMethodCache()
+ public function getAnalyzedMethodCache(): array|false
{
/** @var null|array> $cache_item */
$cache_item = $this->getCacheItem(self::ANALYZED_METHODS_CACHE_NAME);
@@ -246,7 +248,7 @@ public function setAnalyzedMethodCache(array $analyzed_methods): void
/**
* @return array|false
*/
- public function getFileMapCache()
+ public function getFileMapCache(): array|false
{
/** @var array|null $cache_item */
$cache_item = $this->getCacheItem(self::FILE_MAPS_CACHE_NAME);
@@ -283,10 +285,7 @@ public function setTypeCoverage(array $mixed_counts): void
$this->saveCacheItem(self::TYPE_COVERAGE_CACHE_NAME, $mixed_counts);
}
- /**
- * @return string|false
- */
- public function getConfigHashCache()
+ public function getConfigHashCache(): string|false
{
$cache_directory = $this->config->getCacheDirectory();
diff --git a/src/Psalm/Internal/Provider/FileReferenceProvider.php b/src/Psalm/Internal/Provider/FileReferenceProvider.php
index 15950320835..0e74f56e687 100644
--- a/src/Psalm/Internal/Provider/FileReferenceProvider.php
+++ b/src/Psalm/Internal/Provider/FileReferenceProvider.php
@@ -1,5 +1,7 @@
true];
@@ -755,7 +757,7 @@ public function addMethodReferenceToClassMember(
public function addMethodDependencyToClassMember(
string $calling_function_id,
- string $referenced_member_id
+ string $referenced_member_id,
): void {
if (!isset(self::$method_dependencies[$referenced_member_id])) {
self::$method_dependencies[$referenced_member_id] = [$calling_function_id => true];
@@ -775,7 +777,7 @@ public function addMethodReferenceToClassProperty(string $calling_function_id, s
public function addMethodReferenceToMissingClassMember(
string $calling_function_id,
- string $referenced_member_id
+ string $referenced_member_id,
): void {
if (!isset(self::$method_references_to_missing_class_members[$referenced_member_id])) {
self::$method_references_to_missing_class_members[$referenced_member_id] = [$calling_function_id => true];
@@ -795,7 +797,7 @@ public function addCallingLocationForClassMethod(CodeLocation $code_location, st
public function addCallingLocationForClassProperty(
CodeLocation $code_location,
- string $referenced_property_id
+ string $referenced_property_id,
): void {
if (!isset(self::$class_property_locations[$referenced_property_id])) {
self::$class_property_locations[$referenced_property_id] = [$code_location];
diff --git a/src/Psalm/Internal/Provider/FileStorageCacheProvider.php b/src/Psalm/Internal/Provider/FileStorageCacheProvider.php
index 9e63d00d781..e062ff7d117 100644
--- a/src/Psalm/Internal/Provider/FileStorageCacheProvider.php
+++ b/src/Psalm/Internal/Provider/FileStorageCacheProvider.php
@@ -1,5 +1,7 @@
|null $template_type_parameters
*/
public function getReturnType(
StatementsSource $statements_source,
string $fq_classlike_name,
string $method_name,
- $stmt,
+ PhpParser\Node\Expr\MethodCall|PhpParser\Node\Expr\StaticCall $stmt,
Context $context,
CodeLocation $code_location,
?array $template_type_parameters = null,
?string $called_fq_classlike_name = null,
- ?string $called_method_name = null
+ ?string $called_method_name = null,
): ?Union {
foreach (self::$handlers[strtolower($fq_classlike_name)] ?? [] as $class_handler) {
$event = new MethodReturnTypeProviderEvent(
diff --git a/src/Psalm/Internal/Provider/MethodVisibilityProvider.php b/src/Psalm/Internal/Provider/MethodVisibilityProvider.php
index 276de010434..fcda0291d9c 100644
--- a/src/Psalm/Internal/Provider/MethodVisibilityProvider.php
+++ b/src/Psalm/Internal/Provider/MethodVisibilityProvider.php
@@ -1,5 +1,7 @@
*/
private SplObjectStorage $node_types;
diff --git a/src/Psalm/Internal/Provider/ParserCacheProvider.php b/src/Psalm/Internal/Provider/ParserCacheProvider.php
index b09ca7260ee..739fc54d852 100644
--- a/src/Psalm/Internal/Provider/ParserCacheProvider.php
+++ b/src/Psalm/Internal/Provider/ParserCacheProvider.php
@@ -1,5 +1,7 @@
use_file_cache) {
return null;
@@ -222,7 +224,7 @@ public function saveStatementsToCache(
string $file_path,
string $file_content_hash,
array $stmts,
- bool $touch_only
+ bool $touch_only,
): void {
$cache_location = $this->getCacheLocationForPath($file_path, self::PARSER_CACHE_DIRECTORY, !$touch_only);
@@ -344,7 +346,7 @@ private function getParserCacheKey(string $file_path): string
private function getCacheLocationForPath(
string $file_path,
string $subdirectory,
- bool $create_directory = false
+ bool $create_directory = false,
): string {
$root_cache_directory = $this->cache->getCacheDirectory();
diff --git a/src/Psalm/Internal/Provider/ProjectCacheProvider.php b/src/Psalm/Internal/Provider/ProjectCacheProvider.php
index 3db3afa4ce0..8bfe3c41e24 100644
--- a/src/Psalm/Internal/Provider/ProjectCacheProvider.php
+++ b/src/Psalm/Internal/Provider/ProjectCacheProvider.php
@@ -1,5 +1,7 @@
file_provider = $file_provider;
$this->parser_cache_provider = $parser_cache_provider;
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayChunkReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayChunkReturnTypeProvider.php
index 5e949bec3e1..4e236619a13 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayChunkReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayChunkReturnTypeProvider.php
@@ -16,7 +16,7 @@
/**
* @internal
*/
-class ArrayChunkReturnTypeProvider implements FunctionReturnTypeProviderInterface
+final class ArrayChunkReturnTypeProvider implements FunctionReturnTypeProviderInterface
{
/**
* @return array
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayColumnReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayColumnReturnTypeProvider.php
index dbb3f3dfb36..4f731d1ea0a 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayColumnReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayColumnReturnTypeProvider.php
@@ -1,5 +1,7 @@
@@ -236,7 +238,7 @@ private static function getRowShape(
?Union $row_type,
SourceAnalyzer $statements_source,
Context $context,
- CodeLocation $code_location
+ CodeLocation $code_location,
): ?Atomic {
if ($row_type && $row_type->isSingle()) {
if ($row_type->hasArray()) {
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayCombineReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayCombineReturnTypeProvider.php
index 62e7cbcb884..9464a67b281 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayCombineReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayCombineReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillKeysReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillKeysReturnTypeProvider.php
index c40175a13ea..dc333149178 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillKeysReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillKeysReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php
index 3d0a08f2faf..f8230115991 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php
index 4f2a81e1f47..2d1734a0d7d 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php
index a427ed0f375..a6ae833b414 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php
@@ -1,5 +1,7 @@
@@ -294,7 +296,7 @@ private static function executeFakeCall(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr $fake_call,
Context $context,
- ?array &$assertions = null
+ ?array &$assertions = null,
): ?Union {
$old_data_provider = $statements_analyzer->node_data;
@@ -380,7 +382,7 @@ public static function getReturnTypeFromMappingIds(
PhpParser\Node\Arg $function_call_arg,
array $array_args,
?array &$assertions = null,
- ?int $fake_var_discriminator = null
+ ?int $fake_var_discriminator = null,
): Union {
$mapping_return_type = null;
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php
index c8f11e9e0b2..4efeda3d5f2 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPadReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPadReturnTypeProvider.php
index f818945d779..ff616f908a9 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPadReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPadReturnTypeProvider.php
@@ -17,7 +17,7 @@
/**
* @internal
*/
-class ArrayPadReturnTypeProvider implements FunctionReturnTypeProviderInterface
+final class ArrayPadReturnTypeProvider implements FunctionReturnTypeProviderInterface
{
/**
* @return array
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPointerAdjustmentReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPointerAdjustmentReturnTypeProvider.php
index 7d75ef7b3ff..5a62a189743 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPointerAdjustmentReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPointerAdjustmentReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayRandReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayRandReturnTypeProvider.php
index f4a6689051a..f2a4f5e3eda 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayRandReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayRandReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php
index 930896f8123..c316e7debb1 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php
index 4a77a7322cb..6e24a9134e4 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySliceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySliceReturnTypeProvider.php
index 393d36e34c1..93c9de8c71a 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySliceReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySliceReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySpliceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySpliceReturnTypeProvider.php
index 90abc661e12..5602839995a 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySpliceReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySpliceReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/BasenameReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/BasenameReturnTypeProvider.php
index 72d54927170..8e11092326e 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/BasenameReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/BasenameReturnTypeProvider.php
@@ -16,7 +16,7 @@
/**
* @internal
*/
-class BasenameReturnTypeProvider implements FunctionReturnTypeProviderInterface
+final class BasenameReturnTypeProvider implements FunctionReturnTypeProviderInterface
{
/**
* @return array
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ClosureFromCallableReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ClosureFromCallableReturnTypeProvider.php
index 9d33e12ef57..6c8f748b2be 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ClosureFromCallableReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ClosureFromCallableReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/DateTimeModifyReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/DateTimeModifyReturnTypeProvider.php
index b693d788ff1..f461604248d 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/DateTimeModifyReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/DateTimeModifyReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/DomNodeAppendChild.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/DomNodeAppendChild.php
index e714f74c7c5..a7dd0b41941 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/DomNodeAppendChild.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/DomNodeAppendChild.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/FirstArgStringReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/FirstArgStringReturnTypeProvider.php
index 25332b58215..3b043fe4cd3 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/FirstArgStringReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/FirstArgStringReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/GetClassMethodsReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/GetClassMethodsReturnTypeProvider.php
index a5f07266a36..f842fcdfb2a 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/GetClassMethodsReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/GetClassMethodsReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/GetObjectVarsReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/GetObjectVarsReturnTypeProvider.php
index 2bcda2b62f0..9fe1648d3b0 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/GetObjectVarsReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/GetObjectVarsReturnTypeProvider.php
@@ -29,7 +29,7 @@
/**
* @internal
*/
-class GetObjectVarsReturnTypeProvider implements FunctionReturnTypeProviderInterface
+final class GetObjectVarsReturnTypeProvider implements FunctionReturnTypeProviderInterface
{
public static function getFunctionIds(): array
{
@@ -45,7 +45,7 @@ public static function getGetObjectVarsReturnType(
Union $first_arg_type,
SourceAnalyzer $statements_source,
Context $context,
- CodeLocation $location
+ CodeLocation $location,
): Atomic {
self::$fallback ??= new TArray([Type::getString(), Type::getMixed()]);
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/HexdecReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/HexdecReturnTypeProvider.php
index 0cbd821ab00..ead0b9651d4 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/HexdecReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/HexdecReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ImagickPixelColorReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ImagickPixelColorReturnTypeProvider.php
index b756e98a5dc..57f36d31f5e 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ImagickPixelColorReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ImagickPixelColorReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/IteratorToArrayReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/IteratorToArrayReturnTypeProvider.php
index a5f91b973fe..a3464e63ba6 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/IteratorToArrayReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/IteratorToArrayReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/MbInternalEncodingReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/MbInternalEncodingReturnTypeProvider.php
index 053efea8e1c..3c918678deb 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/MbInternalEncodingReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/MbInternalEncodingReturnTypeProvider.php
@@ -21,7 +21,7 @@
/**
* @internal
*/
-class MbInternalEncodingReturnTypeProvider implements FunctionReturnTypeProviderInterface
+final class MbInternalEncodingReturnTypeProvider implements FunctionReturnTypeProviderInterface
{
/**
* @return array
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/MinMaxReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/MinMaxReturnTypeProvider.php
index 2f4b7fffe87..db7000bc721 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/MinMaxReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/MinMaxReturnTypeProvider.php
@@ -27,7 +27,7 @@
/**
* @internal
*/
-class MinMaxReturnTypeProvider implements FunctionReturnTypeProviderInterface
+final class MinMaxReturnTypeProvider implements FunctionReturnTypeProviderInterface
{
/**
* @return array
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/MktimeReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/MktimeReturnTypeProvider.php
index 8eb1b7d2c02..5552f4bacd9 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/MktimeReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/MktimeReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ParseUrlReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ParseUrlReturnTypeProvider.php
index bda2ab4f89e..d2b04719594 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ParseUrlReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ParseUrlReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementReturnTypeProvider.php
index 0ed2c493f62..5e95fdb824f 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/RandReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/RandReturnTypeProvider.php
index ea6184e70fd..98ef8759223 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/RandReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/RandReturnTypeProvider.php
@@ -16,7 +16,7 @@
/**
* @internal
*/
-class RandReturnTypeProvider implements FunctionReturnTypeProviderInterface
+final class RandReturnTypeProvider implements FunctionReturnTypeProviderInterface
{
/**
* @return array
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/RoundReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/RoundReturnTypeProvider.php
index eb8ee561f54..32779b41f7e 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/RoundReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/RoundReturnTypeProvider.php
@@ -18,7 +18,7 @@
/**
* @internal
*/
-class RoundReturnTypeProvider implements FunctionReturnTypeProviderInterface
+final class RoundReturnTypeProvider implements FunctionReturnTypeProviderInterface
{
/**
* @return array
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/SprintfReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/SprintfReturnTypeProvider.php
index 9d87dc356e6..f74d619fc10 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/SprintfReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/SprintfReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php
index c7d64270691..35ee134aceb 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/StrTrReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/StrTrReturnTypeProvider.php
index 721afd0713c..4308244f8f0 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/StrTrReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/StrTrReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/TriggerErrorReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/TriggerErrorReturnTypeProvider.php
index dfb8a173545..c0a812a40a7 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/TriggerErrorReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/TriggerErrorReturnTypeProvider.php
@@ -25,7 +25,7 @@
/**
* @internal
*/
-class TriggerErrorReturnTypeProvider implements FunctionReturnTypeProviderInterface
+final class TriggerErrorReturnTypeProvider implements FunctionReturnTypeProviderInterface
{
/**
* @return array
diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/VersionCompareReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/VersionCompareReturnTypeProvider.php
index 6340feddbaf..2fe7566be6b 100644
--- a/src/Psalm/Internal/Provider/ReturnTypeProvider/VersionCompareReturnTypeProvider.php
+++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/VersionCompareReturnTypeProvider.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Provider/StatementsProvider.php b/src/Psalm/Internal/Provider/StatementsProvider.php
index 21bccd1c35c..90a2a0a143f 100644
--- a/src/Psalm/Internal/Provider/StatementsProvider.php
+++ b/src/Psalm/Internal/Provider/StatementsProvider.php
@@ -1,5 +1,7 @@
file_provider = $file_provider;
$this->parser_cache_provider = $parser_cache_provider;
@@ -103,7 +102,7 @@ public function __construct(
public function getStatementsForFile(
string $file_path,
int $analysis_php_version_id,
- ?Progress $progress = null
+ ?Progress $progress = null,
): array {
unset($this->errors[$file_path]);
@@ -388,7 +387,7 @@ public static function parseStatements(
?string $file_path = null,
?string $existing_file_contents = null,
?array $existing_statements = null,
- ?array $file_changes = null
+ ?array $file_changes = null,
): array {
$attributes = [
'comments', 'startLine', 'startFilePos', 'endFilePos',
diff --git a/src/Psalm/Internal/ReferenceConstraint.php b/src/Psalm/Internal/ReferenceConstraint.php
index 64db0e24344..d318bdaa6f6 100644
--- a/src/Psalm/Internal/ReferenceConstraint.php
+++ b/src/Psalm/Internal/ReferenceConstraint.php
@@ -1,5 +1,7 @@
$args
@@ -142,12 +144,12 @@ public static function handleOverride(array $args, Codebase $codebase): void
$codebase->methods->return_type_provider->registerClosure(
$meta_fq_classlike_name,
static function (
- MethodReturnTypeProviderEvent $event
+ MethodReturnTypeProviderEvent $event,
) use (
$map,
$offset,
$meta_fq_classlike_name,
- $meta_method_name
+ $meta_method_name,
): ?Union {
$statements_analyzer = $event->getSource();
$call_args = $event->getCallArgs();
@@ -195,11 +197,11 @@ static function (
$codebase->methods->return_type_provider->registerClosure(
$meta_fq_classlike_name,
static function (
- MethodReturnTypeProviderEvent $event
+ MethodReturnTypeProviderEvent $event,
) use (
$type_offset,
$meta_fq_classlike_name,
- $meta_method_name
+ $meta_method_name,
): ?Union {
$statements_analyzer = $event->getSource();
$call_args = $event->getCallArgs();
@@ -229,11 +231,11 @@ static function (
$codebase->methods->return_type_provider->registerClosure(
$meta_fq_classlike_name,
static function (
- MethodReturnTypeProviderEvent $event
+ MethodReturnTypeProviderEvent $event,
) use (
$element_type_offset,
$meta_fq_classlike_name,
- $meta_method_name
+ $meta_method_name,
): ?Union {
$statements_analyzer = $event->getSource();
$call_args = $event->getCallArgs();
@@ -292,10 +294,10 @@ static function (
$codebase->functions->return_type_provider->registerClosure(
$function_id,
static function (
- FunctionReturnTypeProviderEvent $event
+ FunctionReturnTypeProviderEvent $event,
) use (
$map,
- $offset
+ $offset,
): Union {
$statements_analyzer = $event->getStatementsSource();
$call_args = $event->getCallArgs();
@@ -342,9 +344,9 @@ static function (
$codebase->functions->return_type_provider->registerClosure(
$function_id,
static function (
- FunctionReturnTypeProviderEvent $event
+ FunctionReturnTypeProviderEvent $event,
) use (
- $type_offset
+ $type_offset,
): Union {
$statements_analyzer = $event->getStatementsSource();
$call_args = $event->getCallArgs();
@@ -372,9 +374,9 @@ static function (
$codebase->functions->return_type_provider->registerClosure(
$function_id,
static function (
- FunctionReturnTypeProviderEvent $event
+ FunctionReturnTypeProviderEvent $event,
) use (
- $element_type_offset
+ $element_type_offset,
): Union {
$statements_analyzer = $event->getStatementsSource();
$call_args = $event->getCallArgs();
diff --git a/src/Psalm/Internal/Scanner/UnresolvedConstant/ArrayOffsetFetch.php b/src/Psalm/Internal/Scanner/UnresolvedConstant/ArrayOffsetFetch.php
index dcff9097691..656a2c9f359 100644
--- a/src/Psalm/Internal/Scanner/UnresolvedConstant/ArrayOffsetFetch.php
+++ b/src/Psalm/Internal/Scanner/UnresolvedConstant/ArrayOffsetFetch.php
@@ -1,5 +1,7 @@
*/
public array $entries;
diff --git a/src/Psalm/Internal/Scanner/UnresolvedConstant/ClassConstant.php b/src/Psalm/Internal/Scanner/UnresolvedConstant/ClassConstant.php
index e75bd93b318..6b4f4ec9eb1 100644
--- a/src/Psalm/Internal/Scanner/UnresolvedConstant/ClassConstant.php
+++ b/src/Psalm/Internal/Scanner/UnresolvedConstant/ClassConstant.php
@@ -1,5 +1,7 @@
value = $value;
}
diff --git a/src/Psalm/Internal/Scanner/UnresolvedConstant/UnresolvedAdditionOp.php b/src/Psalm/Internal/Scanner/UnresolvedConstant/UnresolvedAdditionOp.php
index 64c33e5874f..d2bd967d51a 100644
--- a/src/Psalm/Internal/Scanner/UnresolvedConstant/UnresolvedAdditionOp.php
+++ b/src/Psalm/Internal/Scanner/UnresolvedConstant/UnresolvedAdditionOp.php
@@ -1,11 +1,13 @@
cond = $cond;
$this->if = $if;
diff --git a/src/Psalm/Internal/Scanner/UnresolvedConstantComponent.php b/src/Psalm/Internal/Scanner/UnresolvedConstantComponent.php
index caede827d93..9046813131f 100644
--- a/src/Psalm/Internal/Scanner/UnresolvedConstantComponent.php
+++ b/src/Psalm/Internal/Scanner/UnresolvedConstantComponent.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Scope/IfConditionalScope.php b/src/Psalm/Internal/Scope/IfConditionalScope.php
index 5d7579c594e..386d8daf034 100644
--- a/src/Psalm/Internal/Scope/IfConditionalScope.php
+++ b/src/Psalm/Internal/Scope/IfConditionalScope.php
@@ -1,5 +1,7 @@
if_context = $if_context;
$this->post_if_context = $post_if_context;
diff --git a/src/Psalm/Internal/Scope/IfScope.php b/src/Psalm/Internal/Scope/IfScope.php
index 27a5181d970..955aaffdf03 100644
--- a/src/Psalm/Internal/Scope/IfScope.php
+++ b/src/Psalm/Internal/Scope/IfScope.php
@@ -1,5 +1,7 @@
|null
diff --git a/src/Psalm/Internal/Scope/LoopScope.php b/src/Psalm/Internal/Scope/LoopScope.php
index 1eb1fa0026e..dbd45a88217 100644
--- a/src/Psalm/Internal/Scope/LoopScope.php
+++ b/src/Psalm/Internal/Scope/LoopScope.php
@@ -1,5 +1,7 @@
|null
diff --git a/src/Psalm/Internal/Stubs/Generator/ClassLikeStubGenerator.php b/src/Psalm/Internal/Stubs/Generator/ClassLikeStubGenerator.php
index 4ea25eabbe6..dfbbc10c5e1 100644
--- a/src/Psalm/Internal/Stubs/Generator/ClassLikeStubGenerator.php
+++ b/src/Psalm/Internal/Stubs/Generator/ClassLikeStubGenerator.php
@@ -1,4 +1,4 @@
-getCodebase();
@@ -238,7 +240,7 @@ public static function reconcile(
private static function getMissingType(
Assertion $assertion,
- bool $inside_loop
+ bool $inside_loop,
): Union {
if (($assertion instanceof IsIsset || $assertion instanceof IsEqualIsset)
|| $assertion instanceof NonEmpty
@@ -282,7 +284,7 @@ private static function refine(
bool $negated,
?CodeLocation $code_location,
array $suppressed_issues,
- int &$failed_reconciliation
+ int &$failed_reconciliation,
): Union {
$codebase = $statements_analyzer->getCodebase();
@@ -522,7 +524,7 @@ private static function filterTypeWithAnother(
Codebase $codebase,
Union &$existing_type,
Union $new_type,
- bool &$any_scalar_type_match_found = false
+ bool &$any_scalar_type_match_found = false,
): ?Union {
$matching_atomic_types = [];
@@ -555,7 +557,7 @@ private static function filterAtomicWithAnother(
Atomic &$type_1_atomic,
Atomic $type_2_atomic,
Codebase $codebase,
- bool &$any_scalar_type_match_found
+ bool &$any_scalar_type_match_found,
): ?Atomic {
if ($type_1_atomic instanceof TFloat
&& $type_2_atomic instanceof TInt
@@ -825,7 +827,7 @@ private static function refineContainedAtomicWithAnother(
Atomic $type_1_atomic,
Atomic $type_2_atomic,
Codebase $codebase,
- bool $type_coerced
+ bool $type_coerced,
): ?Atomic {
if ($type_coerced
&& get_class($type_2_atomic) === TNamedObject::class
@@ -870,7 +872,7 @@ private static function handleLiteralEquality(
?string $var_id,
bool $negated,
?CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): Union {
$existing_var_atomic_types = [];
@@ -1009,7 +1011,7 @@ private static function handleLiteralEqualityWithInt(
?string $var_id,
bool $negated,
?CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): Union {
$value = $assertion_type->value;
@@ -1150,7 +1152,7 @@ private static function handleLiteralEqualityWithString(
?string $var_id,
bool $negated,
?CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): Union {
$value = $assertion_type->value;
@@ -1293,7 +1295,7 @@ private static function handleLiteralEqualityWithFloat(
?string $var_id,
bool $negated,
?CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): Union {
$value = $assertion_type->value;
@@ -1428,7 +1430,7 @@ private static function getCompatibleIntType(
Union $existing_var_type,
array $existing_var_atomic_types,
TLiteralInt $assertion_type,
- bool $is_loose_equality
+ bool $is_loose_equality,
): ?Union {
foreach ($existing_var_atomic_types as $existing_var_atomic_type) {
if ($existing_var_atomic_type instanceof TMixed
@@ -1456,7 +1458,7 @@ private static function getCompatibleStringType(
Union $existing_var_type,
array $existing_var_atomic_types,
TLiteralString $assertion_type,
- bool $is_loose_equality
+ bool $is_loose_equality,
): ?Union {
foreach ($existing_var_atomic_types as $existing_var_atomic_type) {
if ($existing_var_atomic_type instanceof TMixed
@@ -1483,7 +1485,7 @@ private static function getCompatibleFloatType(
Union $existing_var_type,
array $existing_var_atomic_types,
TLiteralFloat $assertion_type,
- bool $is_loose_equality
+ bool $is_loose_equality,
): ?Union {
foreach ($existing_var_atomic_types as $existing_var_atomic_type) {
if ($existing_var_atomic_type instanceof TMixed
@@ -1514,7 +1516,7 @@ private static function handleIsA(
?CodeLocation $code_location,
?string $key,
array $suppressed_issues,
- bool &$should_return
+ bool &$should_return,
): array {
$allow_string_comparison = $assertion->allow_string;
diff --git a/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php b/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php
index 6977e465876..8a39b72c976 100644
--- a/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php
+++ b/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php
@@ -1,5 +1,7 @@
is_pure && !$input_type_part->is_pure) {
if ($atomic_comparison_result) {
@@ -169,7 +171,7 @@ public static function isNotExplicitlyCallableTypeCallable(
Codebase $codebase,
Atomic $input_type_part,
TCallable $container_type_part,
- ?TypeComparisonResult $atomic_comparison_result
+ ?TypeComparisonResult $atomic_comparison_result,
): bool {
if ($input_type_part instanceof TArray) {
@@ -238,7 +240,7 @@ public static function getCallableFromAtomic(
Atomic $input_type_part,
?TCallable $container_type_part = null,
?StatementsAnalyzer $statements_analyzer = null,
- bool $expand_callable = false
+ bool $expand_callable = false,
): ?Atomic {
if ($input_type_part instanceof TCallable || $input_type_part instanceof TClosure) {
@@ -458,8 +460,8 @@ public static function getCallableMethodIdFromTKeyedArray(
TKeyedArray $input_type_part,
?Codebase $codebase = null,
?string $calling_method_id = null,
- ?string $file_name = null
- ) {
+ ?string $file_name = null,
+ ): string|MethodIdentifier|null {
if (!isset($input_type_part->properties[0])
|| !isset($input_type_part->properties[1])
) {
diff --git a/src/Psalm/Internal/Type/Comparator/ClassLikeStringComparator.php b/src/Psalm/Internal/Type/Comparator/ClassLikeStringComparator.php
index a3830ea83d4..e63dd39a0f6 100644
--- a/src/Psalm/Internal/Type/Comparator/ClassLikeStringComparator.php
+++ b/src/Psalm/Internal/Type/Comparator/ClassLikeStringComparator.php
@@ -1,5 +1,7 @@
min_bound === null;
$is_input_max = $input_type_part->max_bound === null;
@@ -47,7 +49,7 @@ public static function isContainedBy(
*/
public static function isContainedByUnion(
TIntRange $input_type_part,
- Union $container_type
+ Union $container_type,
): bool {
$container_atomic_types = $container_type->getAtomicTypes();
$reduced_range = new TIntRange(
diff --git a/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php b/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php
index c9d7aad5842..f9786880a27 100644
--- a/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php
+++ b/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php
@@ -1,5 +1,7 @@
fallback_params === null;
@@ -285,7 +287,7 @@ public static function isContainedByObjectWithProperties(
TNamedObject $input_type_part,
TObjectWithProperties $container_type_part,
bool $allow_interface_equality,
- ?TypeComparisonResult $atomic_comparison_result
+ ?TypeComparisonResult $atomic_comparison_result,
): bool {
$all_types_contain = true;
@@ -346,7 +348,7 @@ public static function isContainedByObjectWithProperties(
public static function coerceToObjectWithProperties(
Codebase $codebase,
TNamedObject $input_type_part,
- TObjectWithProperties $container_type_part
+ TObjectWithProperties $container_type_part,
): ?TObjectWithProperties {
$storage = $codebase->classlikes->getStorageFor($input_type_part->value);
diff --git a/src/Psalm/Internal/Type/Comparator/ObjectComparator.php b/src/Psalm/Internal/Type/Comparator/ObjectComparator.php
index 1d264658dd8..5689350663b 100644
--- a/src/Psalm/Internal/Type/Comparator/ObjectComparator.php
+++ b/src/Psalm/Internal/Type/Comparator/ObjectComparator.php
@@ -1,5 +1,7 @@
isVanillaMixed()) {
return true;
@@ -352,7 +354,7 @@ public static function isContainedBy(
*/
public static function isContainedByInPhp(
?Union $input_type,
- Union $container_type
+ Union $container_type,
): bool {
if ($container_type->isMixed()) {
return true;
@@ -400,7 +402,7 @@ public static function canBeContainedBy(
Union $container_type,
bool $ignore_null = false,
bool $ignore_false = false,
- array &$matching_input_keys = []
+ array &$matching_input_keys = [],
): bool {
if ($container_type->hasMixed()) {
return true;
@@ -452,7 +454,7 @@ public static function canExpressionTypesBeIdentical(
Codebase $codebase,
Union $type1,
Union $type2,
- bool $allow_interface_equality = true
+ bool $allow_interface_equality = true,
): bool {
if ($type1->hasMixed() || $type2->hasMixed()) {
return true;
@@ -495,7 +497,7 @@ public static function canExpressionTypesBeIdentical(
*/
private static function getTypeParts(
Codebase $codebase,
- Union $union_type
+ Union $union_type,
): array {
$atomic_types = [];
foreach ($union_type->getAtomicTypes() as $atomic_type) {
diff --git a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php
index 5909279ed1a..b916caa8e73 100644
--- a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php
+++ b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php
@@ -1,5 +1,7 @@
getBuilder();
$existing_var_atomic_types = $existing_var_type->getAtomicTypes();
diff --git a/src/Psalm/Internal/Type/ParseTree.php b/src/Psalm/Internal/Type/ParseTree.php
index e181b07df84..5693203547a 100644
--- a/src/Psalm/Internal/Type/ParseTree.php
+++ b/src/Psalm/Internal/Type/ParseTree.php
@@ -1,5 +1,7 @@
name = $name;
$this->byref = $byref;
diff --git a/src/Psalm/Internal/Type/ParseTree/MethodTree.php b/src/Psalm/Internal/Type/ParseTree/MethodTree.php
index f77494b405c..595e3cdfcd7 100644
--- a/src/Psalm/Internal/Type/ParseTree/MethodTree.php
+++ b/src/Psalm/Internal/Type/ParseTree/MethodTree.php
@@ -1,5 +1,7 @@
offset_start = $offset_start;
$this->offset_end = $offset_end;
diff --git a/src/Psalm/Internal/Type/ParseTreeCreator.php b/src/Psalm/Internal/Type/ParseTreeCreator.php
index 9fdd3fcc482..515838b95e8 100644
--- a/src/Psalm/Internal/Type/ParseTreeCreator.php
+++ b/src/Psalm/Internal/Type/ParseTreeCreator.php
@@ -1,5 +1,7 @@
getBuilder();
$old_var_type_string = $existing_var_type->getId();
@@ -620,7 +622,7 @@ private static function reconcileNonEmptyCountable(
bool $negated,
?CodeLocation $code_location,
array $suppressed_issues,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
$existing_var_type = $existing_var_type->getBuilder();
@@ -755,7 +757,7 @@ private static function reconcileExactlyCountable(
bool $negated,
?CodeLocation $code_location,
array $suppressed_issues,
- bool $is_equality
+ bool $is_equality,
): Union {
$existing_var_type = $existing_var_type->getBuilder();
if ($existing_var_type->hasType('array')) {
@@ -876,7 +878,7 @@ private static function reconcileHasMethod(
bool $negated,
?CodeLocation $code_location,
array $suppressed_issues,
- int &$failed_reconciliation
+ int &$failed_reconciliation,
): Union {
$method_name = $assertion->method;
$old_var_type_string = $existing_var_type->getId();
@@ -989,7 +991,7 @@ private static function reconcileString(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
$existing_var_atomic_types = $existing_var_type->getAtomicTypes();
@@ -1079,7 +1081,7 @@ private static function reconcileInt(
bool $negated,
?CodeLocation $code_location,
array $suppressed_issues,
- int &$failed_reconciliation
+ int &$failed_reconciliation,
): Union {
if ($existing_var_type->hasMixed()) {
if ($assertion instanceof IsLooselyEqual) {
@@ -1174,7 +1176,7 @@ private static function reconcileBool(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
if ($existing_var_type->hasMixed()) {
return Type::getBool();
@@ -1253,7 +1255,7 @@ private static function reconcileFalse(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
if ($existing_var_type->hasMixed()) {
return Type::getFalse();
@@ -1338,7 +1340,7 @@ private static function reconcileTrue(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
if ($existing_var_type->hasMixed()) {
return Type::getTrue();
@@ -1423,7 +1425,7 @@ private static function reconcileScalar(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
if ($existing_var_type->hasMixed()) {
return Type::getScalar();
@@ -1498,7 +1500,7 @@ private static function reconcileNumeric(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
if ($existing_var_type->hasMixed()) {
return Type::getNumeric();
@@ -1593,7 +1595,7 @@ private static function reconcileObject(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
if ($existing_var_type->hasMixed()) {
return new Union([$assertion_type]);
@@ -1711,7 +1713,7 @@ private static function reconcileResource(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
if ($existing_var_type->hasMixed()) {
return Type::getResource();
@@ -1770,7 +1772,7 @@ private static function reconcileCountable(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
@@ -1842,7 +1844,7 @@ private static function reconcileIterable(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
@@ -1904,7 +1906,7 @@ private static function reconcileInArray(
bool $negated,
?CodeLocation $code_location,
array $suppressed_issues,
- int &$failed_reconciliation
+ int &$failed_reconciliation,
): Union {
$new_var_type = $assertion->type;
@@ -1941,7 +1943,7 @@ private static function reconcileInArray(
private static function reconcileHasArrayKey(
Union $existing_var_type,
- HasArrayKey $assertion
+ HasArrayKey $assertion,
): Union {
$assertion = $assertion->key;
$types = $existing_var_type->getAtomicTypes();
@@ -1979,7 +1981,7 @@ private static function reconcileIsGreaterThan(
?string $var_id,
bool $negated,
?CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): Union {
$existing_var_type = $existing_var_type->getBuilder();
//we add 1 from the assertion value because we're on a strict operator
@@ -2088,7 +2090,7 @@ private static function reconcileIsLessThan(
?string $var_id,
bool $negated,
?CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): Union {
//we remove 1 from the assertion value because we're on a strict operator
$assertion_value = $assertion->value - 1;
@@ -2196,7 +2198,7 @@ private static function reconcileTraversable(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
@@ -2266,7 +2268,7 @@ private static function reconcileArray(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
@@ -2379,7 +2381,7 @@ private static function reconcileList(
array $suppressed_issues,
int &$failed_reconciliation,
bool $is_equality,
- bool $is_non_empty
+ bool $is_non_empty,
): Union {
$old_var_type_string = $existing_var_type->getId();
@@ -2486,7 +2488,7 @@ private static function reconcileStringArrayAccess(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $inside_loop
+ bool $inside_loop,
): Union {
$old_var_type_string = $existing_var_type->getId();
@@ -2554,7 +2556,7 @@ private static function reconcileIntArrayAccess(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $inside_loop
+ bool $inside_loop,
): Union {
$old_var_type_string = $existing_var_type->getId();
@@ -2615,7 +2617,7 @@ private static function reconcileCallable(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
if ($existing_var_type->hasMixed()) {
return Type::parseString('callable');
@@ -2720,7 +2722,7 @@ private static function reconcileTruthyOrNonEmpty(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $recursive_check
+ bool $recursive_check,
): Union {
$types = $existing_var_type->getAtomicTypes();
$old_var_type_string = $existing_var_type->getId();
@@ -2912,7 +2914,7 @@ private static function reconcileClassConstant(
Codebase $codebase,
TClassConstant $class_constant_expression,
Union $existing_type,
- int &$failed_reconciliation
+ int &$failed_reconciliation,
): Union {
$class_name = $class_constant_expression->fq_classlike_name;
if (!$codebase->classlike_storage_provider->has($class_name)) {
@@ -2941,7 +2943,7 @@ private static function reconcileClassConstant(
private static function reconcileValueOf(
Codebase $codebase,
TValueOf $assertion_type,
- int &$failed_reconciliation
+ int &$failed_reconciliation,
): ?Union {
$reconciled_types = [];
diff --git a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php
index eee9e3a169e..bc966c70d47 100644
--- a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php
+++ b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php
@@ -1,5 +1,7 @@
getId();
@@ -423,7 +425,7 @@ public static function reconcile(
}
private static function reconcileCallable(
- Union $existing_var_type
+ Union $existing_var_type,
): Union {
$existing_var_type = $existing_var_type->getBuilder();
foreach ($existing_var_type->getAtomicTypes() as $atomic_key => $type) {
@@ -453,7 +455,7 @@ private static function reconcileBool(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
$non_bool_types = [];
@@ -523,7 +525,7 @@ private static function reconcileNotNonEmptyCountable(
?CodeLocation $code_location,
array $suppressed_issues,
bool $is_equality,
- ?int $count
+ ?int $count,
): Union {
$existing_var_type = $existing_var_type->getBuilder();
$old_var_type_string = $existing_var_type->getId();
@@ -643,7 +645,7 @@ private static function reconcileNull(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$types = $existing_var_type->getAtomicTypes();
$old_var_type_string = $existing_var_type->getId();
@@ -720,7 +722,7 @@ private static function reconcileFalse(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$types = $existing_var_type->getAtomicTypes();
$old_var_type_string = $existing_var_type->getId();
@@ -802,7 +804,7 @@ private static function reconcileTrue(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$types = $existing_var_type->getAtomicTypes();
$old_var_type_string = $existing_var_type->getId();
@@ -885,7 +887,7 @@ private static function reconcileFalsyOrEmpty(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $recursive_check
+ bool $recursive_check,
): Union {
$existing_var_type = $existing_var_type->getBuilder();
$old_var_type_string = $existing_var_type->getId();
@@ -1068,7 +1070,7 @@ private static function reconcileScalar(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
$non_scalar_types = [];
@@ -1156,7 +1158,7 @@ private static function reconcileObject(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
$non_object_types = [];
@@ -1257,7 +1259,7 @@ private static function reconcileNumeric(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
$non_numeric_types = [];
@@ -1353,7 +1355,7 @@ private static function reconcileInt(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
$non_int_types = [];
@@ -1455,7 +1457,7 @@ private static function reconcileFloat(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
$non_float_types = [];
@@ -1552,7 +1554,7 @@ private static function reconcileString(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
$non_string_types = [];
@@ -1658,7 +1660,7 @@ private static function reconcileArray(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$old_var_type_string = $existing_var_type->getId();
$non_array_types = [];
@@ -1760,7 +1762,7 @@ private static function reconcileResource(
?CodeLocation $code_location,
array $suppressed_issues,
int &$failed_reconciliation,
- bool $is_equality
+ bool $is_equality,
): Union {
$types = $existing_var_type->getAtomicTypes();
$old_var_type_string = $existing_var_type->getId();
@@ -1831,7 +1833,7 @@ private static function reconcileIsLessThanOrEqualTo(
?string $var_id,
bool $negated,
?CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): Union {
$existing_var_type = $existing_var_type->getBuilder();
$assertion_value = $assertion->value;
@@ -1938,7 +1940,7 @@ private static function reconcileIsGreaterThanOrEqualTo(
?string $var_id,
bool $negated,
?CodeLocation $code_location,
- array $suppressed_issues
+ array $suppressed_issues,
): Union {
$existing_var_type = $existing_var_type->getBuilder();
$assertion_value = $assertion->value;
diff --git a/src/Psalm/Internal/Type/TemplateBound.php b/src/Psalm/Internal/Type/TemplateBound.php
index 01aada21077..b67c79cc211 100644
--- a/src/Psalm/Internal/Type/TemplateBound.php
+++ b/src/Psalm/Internal/Type/TemplateBound.php
@@ -1,5 +1,7 @@
type = $type;
$this->appearance_depth = $appearance_depth;
diff --git a/src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php b/src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php
index 8df4bd41bd0..3a872cefec1 100644
--- a/src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php
+++ b/src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php
@@ -1,5 +1,7 @@
param_name][$atomic_type->defining_class])) {
return null;
@@ -369,7 +371,7 @@ private static function replaceTemplateKeyOfValueOf(
private static function replaceTemplatePropertiesOf(
?Codebase $codebase,
TTemplatePropertiesOf $atomic_type,
- array $inferred_lower_bounds
+ array $inferred_lower_bounds,
): ?Atomic {
if (!isset($inferred_lower_bounds[$atomic_type->param_name][$atomic_type->defining_class])) {
return null;
@@ -398,7 +400,7 @@ private static function replaceConditional(
TemplateResult $template_result,
Codebase $codebase,
TConditional &$atomic_type,
- array $inferred_lower_bounds
+ array $inferred_lower_bounds,
): Union {
$template_type = isset($inferred_lower_bounds[$atomic_type->param_name][$atomic_type->defining_class])
? TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds(
diff --git a/src/Psalm/Internal/Type/TemplateResult.php b/src/Psalm/Internal/Type/TemplateResult.php
index 72a7a05cd5e..1ad9dc2399f 100644
--- a/src/Psalm/Internal/Type/TemplateResult.php
+++ b/src/Psalm/Internal/Type/TemplateResult.php
@@ -1,5 +1,7 @@
>
diff --git a/src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php b/src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php
index 7631f3f4413..cc6281b151b 100644
--- a/src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php
+++ b/src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php
@@ -1,5 +1,7 @@
defining_class === $calling_class) {
return [$atomic_type];
@@ -995,7 +997,7 @@ public static function handleTemplateParamClassStandin(
bool $add_lower_bound,
?string $bound_equality_classlike,
int $depth,
- bool $was_single
+ bool $was_single,
): array {
if ($atomic_type->defining_class === $calling_class) {
return [$atomic_type];
@@ -1140,7 +1142,7 @@ public static function getRootTemplateType(
string $param_name,
string $defining_class,
array $visited_classes,
- ?Codebase $codebase
+ ?Codebase $codebase,
): ?Union {
if (isset($visited_classes[$defining_class])) {
return null;
@@ -1239,7 +1241,7 @@ public static function getMappedGenericTypeParams(
Codebase $codebase,
Atomic $input_type_part,
Atomic $container_type_part,
- ?array &$container_type_params_covariant = null
+ ?array &$container_type_params_covariant = null,
): array {
$_ = null;
if ($input_type_part instanceof TGenericObject || $input_type_part instanceof TIterable) {
diff --git a/src/Psalm/Internal/Type/TypeAlias.php b/src/Psalm/Internal/Type/TypeAlias.php
index a8c05fb6d30..3e5da8b5069 100644
--- a/src/Psalm/Internal/Type/TypeAlias.php
+++ b/src/Psalm/Internal/Type/TypeAlias.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/Type/TypeAlias/InlineTypeAlias.php b/src/Psalm/Internal/Type/TypeAlias/InlineTypeAlias.php
index ab49068d4b1..35d6893ee96 100644
--- a/src/Psalm/Internal/Type/TypeAlias/InlineTypeAlias.php
+++ b/src/Psalm/Internal/Type/TypeAlias/InlineTypeAlias.php
@@ -1,5 +1,7 @@
declaring_fq_classlike_name = $declaring_fq_classlike_name;
$this->alias_name = $alias_name;
diff --git a/src/Psalm/Internal/Type/TypeCombination.php b/src/Psalm/Internal/Type/TypeCombination.php
index 863ae77f932..0bc11918e7a 100644
--- a/src/Psalm/Internal/Type/TypeCombination.php
+++ b/src/Psalm/Internal/Type/TypeCombination.php
@@ -1,5 +1,7 @@
*/
public array $value_types = [];
diff --git a/src/Psalm/Internal/Type/TypeCombiner.php b/src/Psalm/Internal/Type/TypeCombiner.php
index f63d26d1378..7bad564408c 100644
--- a/src/Psalm/Internal/Type/TypeCombiner.php
+++ b/src/Psalm/Internal/Type/TypeCombiner.php
@@ -1,5 +1,7 @@
from_loop_isset) {
@@ -969,7 +971,7 @@ private static function scrapeStringProperties(
Atomic $type,
TypeCombination $combination,
?Codebase $codebase,
- int $literal_limit
+ int $literal_limit,
): void {
if ($type instanceof TCallableString && isset($combination->value_types['callable'])) {
return;
@@ -1166,7 +1168,7 @@ private static function scrapeIntProperties(
string $type_key,
Atomic $type,
TypeCombination $combination,
- int $literal_limit
+ int $literal_limit,
): void {
if (isset($combination->value_types['array-key'])) {
return;
@@ -1336,7 +1338,7 @@ private static function getClassLikes(Codebase $codebase, string $fq_classlike_n
private static function handleKeyedArrayEntries(
TypeCombination $combination,
bool $overwrite_empty_array,
- bool $from_docblock
+ bool $from_docblock,
): array {
$new_types = [];
@@ -1453,7 +1455,7 @@ private static function getArrayTypeFromGenericParams(
bool $allow_mixed_union,
Atomic $type,
array $generic_type_params,
- bool $from_docblock
+ bool $from_docblock,
): Atomic {
if ($combination->objectlike_entries) {
$objectlike_generic_type = null;
diff --git a/src/Psalm/Internal/Type/TypeExpander.php b/src/Psalm/Internal/Type/TypeExpander.php
index 56f558038d5..d4037652e8b 100644
--- a/src/Psalm/Internal/Type/TypeExpander.php
+++ b/src/Psalm/Internal/Type/TypeExpander.php
@@ -1,5 +1,7 @@
* @psalm-suppress ConflictingReferenceConstraint, ReferenceConstraintViolation The output type is always Atomic
@@ -121,14 +121,14 @@ public static function expandAtomic(
Codebase $codebase,
Atomic &$return_type,
?string $self_class,
- $static_class_type,
+ string|TNamedObject|TTemplateParam|null $static_class_type,
?string $parent_class,
bool $evaluate_class_constants = true,
bool $evaluate_conditional_types = false,
bool $final = false,
bool $expand_generic = false,
bool $expand_templates = false,
- bool $throw_on_unresolvable_constant = false
+ bool $throw_on_unresolvable_constant = false,
): array {
if ($return_type instanceof TEnumCase) {
return [$return_type];
@@ -603,19 +603,17 @@ public static function expandAtomic(
}
/**
- * @param string|TNamedObject|TTemplateParam|null $static_class_type
* @param-out TNamedObject|TTemplateParam $return_type
- * @return TNamedObject|TTemplateParam
*/
private static function expandNamedObject(
Codebase $codebase,
TNamedObject &$return_type,
?string $self_class,
- $static_class_type,
+ string|TNamedObject|TTemplateParam|null $static_class_type,
?string $parent_class,
bool $final = false,
- bool &$expand_generic = false
- ) {
+ bool &$expand_generic = false,
+ ): TNamedObject|TTemplateParam {
if ($expand_generic
&& get_class($return_type) === TNamedObject::class
&& !$return_type->extra_types
@@ -717,21 +715,20 @@ private static function expandNamedObject(
}
/**
- * @param string|TNamedObject|TTemplateParam|null $static_class_type
* @return non-empty-list
*/
private static function expandConditional(
Codebase $codebase,
TConditional &$return_type,
?string $self_class,
- $static_class_type,
+ string|TNamedObject|TTemplateParam|null $static_class_type,
?string $parent_class,
bool $evaluate_class_constants = true,
bool $evaluate_conditional_types = false,
bool $final = false,
bool $expand_generic = false,
bool $expand_templates = false,
- bool $throw_on_unresolvable_constant = false
+ bool $throw_on_unresolvable_constant = false,
): array {
$new_as_type = self::expandUnion(
$codebase,
@@ -929,14 +926,13 @@ private static function expandConditional(
}
/**
- * @param string|TNamedObject|TTemplateParam|null $static_class_type
* @return non-empty-list
*/
private static function expandPropertiesOf(
Codebase $codebase,
TPropertiesOf &$return_type,
?string $self_class,
- $static_class_type
+ string|TNamedObject|TTemplateParam|null $static_class_type,
): array {
if ($self_class) {
$return_type = $return_type->replaceClassLike(
@@ -1013,21 +1009,20 @@ private static function expandPropertiesOf(
/**
* @param TKeyOf|TValueOf $return_type
- * @param string|TNamedObject|TTemplateParam|null $static_class_type
* @return non-empty-list
*/
private static function expandKeyOfValueOf(
Codebase $codebase,
Atomic &$return_type,
?string $self_class,
- $static_class_type,
+ string|TNamedObject|TTemplateParam|null $static_class_type,
?string $parent_class,
bool $evaluate_class_constants = true,
bool $evaluate_conditional_types = false,
bool $final = false,
bool $expand_generic = false,
bool $expand_templates = false,
- bool $throw_on_unresolvable_constant = false
+ bool $throw_on_unresolvable_constant = false,
): array {
// Expand class constants to their atomics
$type_atomics = [];
diff --git a/src/Psalm/Internal/Type/TypeParser.php b/src/Psalm/Internal/Type/TypeParser.php
index e5b463fdf4e..eda058b9b55 100644
--- a/src/Psalm/Internal/Type/TypeParser.php
+++ b/src/Psalm/Internal/Type/TypeParser.php
@@ -1,5 +1,7 @@
hasMixed()) {
return new TTemplateParamClass(
@@ -563,7 +565,6 @@ public static function getComputedIntsFromMask(array $potential_ints, bool $from
/**
* @param array> $template_type_map
* @param array $type_aliases
- * @return Atomic|Union
* @throws TypeParseTreeException
* @psalm-suppress ComplexMethod to be refactored
*/
@@ -572,8 +573,8 @@ private static function getTypeFromGenericTree(
Codebase $codebase,
array $template_type_map,
array $type_aliases,
- bool $from_docblock = false
- ) {
+ bool $from_docblock = false,
+ ): Atomic|Union {
$generic_type = $parse_tree->value;
$generic_params = [];
@@ -1017,7 +1018,7 @@ private static function getTypeFromUnionTree(
Codebase $codebase,
array $template_type_map,
array $type_aliases,
- bool $from_docblock
+ bool $from_docblock,
): Union {
$has_null = false;
@@ -1083,7 +1084,7 @@ private static function getTypeFromIntersectionTree(
Codebase $codebase,
array $template_type_map,
array $type_aliases,
- bool $from_docblock
+ bool $from_docblock,
): Atomic {
$intersection_types = [];
@@ -1196,7 +1197,6 @@ private static function getTypeFromIntersectionTree(
/**
* @param array> $template_type_map
* @param array $type_aliases
- * @return TCallable|TClosure
* @throws TypeParseTreeException
*/
private static function getTypeFromCallableTree(
@@ -1204,8 +1204,8 @@ private static function getTypeFromCallableTree(
Codebase $codebase,
array $template_type_map,
array $type_aliases,
- bool $from_docblock
- ) {
+ bool $from_docblock,
+ ): TCallable|TClosure {
$params = [];
foreach ($parse_tree->children as $child_tree) {
@@ -1274,7 +1274,7 @@ private static function getTypeFromCallableTree(
private static function getTypeFromIndexAccessTree(
IndexedAccessTree $parse_tree,
array $template_type_map,
- bool $from_docblock
+ bool $from_docblock,
): TTemplateIndexedAccess {
if (!isset($parse_tree->children[0]) || !$parse_tree->children[0] instanceof Value) {
throw new TypeParseTreeException('Unrecognised indexed access');
@@ -1325,7 +1325,6 @@ private static function getTypeFromIndexAccessTree(
/**
* @param array> $template_type_map
* @param array $type_aliases
- * @return TCallableKeyedArray|TKeyedArray|TObjectWithProperties|TArray
* @throws TypeParseTreeException
*/
private static function getTypeFromKeyedArrayTree(
@@ -1333,8 +1332,8 @@ private static function getTypeFromKeyedArrayTree(
Codebase $codebase,
array $template_type_map,
array $type_aliases,
- bool $from_docblock
- ) {
+ bool $from_docblock,
+ ): TCallableKeyedArray|TKeyedArray|TObjectWithProperties|TArray {
$properties = [];
$class_strings = [];
@@ -1532,7 +1531,7 @@ private static function extractIntersectionKey(Atomic $intersection_type): strin
*/
private static function extractKeyedIntersectionTypes(
Codebase $codebase,
- array $intersection_types
+ array $intersection_types,
): array {
$keyed_intersection_types = [];
$callable_intersection = null;
@@ -1662,7 +1661,7 @@ private static function getTypeFromKeyedArrays(
array $intersection_types,
Atomic $first_type,
Atomic $last_type,
- bool $from_docblock
+ bool $from_docblock,
): Atomic {
/** @var non-empty-array */
$properties = [];
diff --git a/src/Psalm/Internal/Type/TypeTokenizer.php b/src/Psalm/Internal/Type/TypeTokenizer.php
index 8be1587c8e8..a772bc7503e 100644
--- a/src/Psalm/Internal/Type/TypeTokenizer.php
+++ b/src/Psalm/Internal/Type/TypeTokenizer.php
@@ -1,5 +1,7 @@
@@ -312,7 +314,7 @@ public static function tokenize(string $string_type, bool $ignore_space = true):
*/
public static function fixScalarTerms(
string $type_string,
- ?int $analysis_php_version_id = null
+ ?int $analysis_php_version_id = null,
): string {
$type_string_lc = strtolower($type_string);
@@ -360,7 +362,7 @@ public static function getFullyQualifiedTokens(
?array $type_aliases = null,
?string $self_fqcln = null,
?string $parent_fqcln = null,
- bool $allow_assertions = false
+ bool $allow_assertions = false,
): array {
$type_tokens = self::tokenize($string_type);
diff --git a/src/Psalm/Internal/TypeVisitor/CanContainObjectTypeVisitor.php b/src/Psalm/Internal/TypeVisitor/CanContainObjectTypeVisitor.php
index b107ba2eaa0..833f6d3e4bf 100644
--- a/src/Psalm/Internal/TypeVisitor/CanContainObjectTypeVisitor.php
+++ b/src/Psalm/Internal/TypeVisitor/CanContainObjectTypeVisitor.php
@@ -1,5 +1,7 @@
old = strtolower($old);
$this->new = $new;
diff --git a/src/Psalm/Internal/TypeVisitor/ContainsClassLikeVisitor.php b/src/Psalm/Internal/TypeVisitor/ContainsClassLikeVisitor.php
index faedea36d6d..4fc9df15929 100644
--- a/src/Psalm/Internal/TypeVisitor/ContainsClassLikeVisitor.php
+++ b/src/Psalm/Internal/TypeVisitor/ContainsClassLikeVisitor.php
@@ -1,5 +1,7 @@
diff --git a/src/Psalm/Internal/TypeVisitor/TypeChecker.php b/src/Psalm/Internal/TypeVisitor/TypeChecker.php
index 4c2e52c916b..f05faa9a05c 100644
--- a/src/Psalm/Internal/TypeVisitor/TypeChecker.php
+++ b/src/Psalm/Internal/TypeVisitor/TypeChecker.php
@@ -1,5 +1,7 @@
source = $source;
$this->code_location = $code_location;
diff --git a/src/Psalm/Internal/TypeVisitor/TypeLocalizer.php b/src/Psalm/Internal/TypeVisitor/TypeLocalizer.php
index 81ba6a0eb42..17a710d8821 100644
--- a/src/Psalm/Internal/TypeVisitor/TypeLocalizer.php
+++ b/src/Psalm/Internal/TypeVisitor/TypeLocalizer.php
@@ -1,5 +1,7 @@
>
@@ -30,7 +32,7 @@ class TypeLocalizer extends MutableTypeVisitor
*/
public function __construct(
array $extends,
- string $base_fq_class_name
+ string $base_fq_class_name,
) {
$this->extends = $extends;
$this->base_fq_class_name = $base_fq_class_name;
diff --git a/src/Psalm/Internal/TypeVisitor/TypeScanner.php b/src/Psalm/Internal/TypeVisitor/TypeScanner.php
index d840e7327c2..e610f249d0b 100644
--- a/src/Psalm/Internal/TypeVisitor/TypeScanner.php
+++ b/src/Psalm/Internal/TypeVisitor/TypeScanner.php
@@ -1,5 +1,7 @@
scanner = $scanner;
$this->file_storage = $file_storage;
diff --git a/src/Psalm/Internal/VersionUtils.php b/src/Psalm/Internal/VersionUtils.php
index ac0d6575809..72e8be62720 100644
--- a/src/Psalm/Internal/VersionUtils.php
+++ b/src/Psalm/Internal/VersionUtils.php
@@ -1,5 +1,7 @@
function_id = $function_id ? strtolower($function_id) : null;
diff --git a/src/Psalm/Issue/ArgumentTypeCoercion.php b/src/Psalm/Issue/ArgumentTypeCoercion.php
index 516fd4104d6..26833a207dc 100644
--- a/src/Psalm/Issue/ArgumentTypeCoercion.php
+++ b/src/Psalm/Issue/ArgumentTypeCoercion.php
@@ -1,5 +1,7 @@
const_id = $const_id;
diff --git a/src/Psalm/Issue/ClassIssue.php b/src/Psalm/Issue/ClassIssue.php
index 3efaa7e5785..959f625cf42 100644
--- a/src/Psalm/Issue/ClassIssue.php
+++ b/src/Psalm/Issue/ClassIssue.php
@@ -1,20 +1,19 @@
fq_classlike_name = $fq_classlike_name;
diff --git a/src/Psalm/Issue/CodeIssue.php b/src/Psalm/Issue/CodeIssue.php
index ce4fcbc469b..e4b7791caa1 100644
--- a/src/Psalm/Issue/CodeIssue.php
+++ b/src/Psalm/Issue/CodeIssue.php
@@ -1,5 +1,7 @@
code_location = $code_location;
$this->message = $message;
diff --git a/src/Psalm/Issue/ComplexFunction.php b/src/Psalm/Issue/ComplexFunction.php
index 6db2fec3865..0f42c0630fc 100644
--- a/src/Psalm/Issue/ComplexFunction.php
+++ b/src/Psalm/Issue/ComplexFunction.php
@@ -1,5 +1,7 @@
function_id = strtolower($function_id);
diff --git a/src/Psalm/Issue/IfThisIsMismatch.php b/src/Psalm/Issue/IfThisIsMismatch.php
index 508b2176eeb..e56bd547631 100644
--- a/src/Psalm/Issue/IfThisIsMismatch.php
+++ b/src/Psalm/Issue/IfThisIsMismatch.php
@@ -1,5 +1,7 @@
method_id = strtolower($method_id);
diff --git a/src/Psalm/Issue/MethodSignatureMismatch.php b/src/Psalm/Issue/MethodSignatureMismatch.php
index d3ba51725e4..5a5a31a5d3d 100644
--- a/src/Psalm/Issue/MethodSignatureMismatch.php
+++ b/src/Psalm/Issue/MethodSignatureMismatch.php
@@ -1,5 +1,7 @@
code_location = $code_location;
$this->message = $message;
diff --git a/src/Psalm/Issue/MixedArgumentTypeCoercion.php b/src/Psalm/Issue/MixedArgumentTypeCoercion.php
index c9af86b0760..a7bd8f43d92 100644
--- a/src/Psalm/Issue/MixedArgumentTypeCoercion.php
+++ b/src/Psalm/Issue/MixedArgumentTypeCoercion.php
@@ -1,5 +1,7 @@
code_location = $code_location;
$this->message = $message;
diff --git a/src/Psalm/Issue/MixedArrayAccess.php b/src/Psalm/Issue/MixedArrayAccess.php
index bb827b7f841..407d3822dbb 100644
--- a/src/Psalm/Issue/MixedArrayAccess.php
+++ b/src/Psalm/Issue/MixedArrayAccess.php
@@ -1,5 +1,7 @@
code_location = $code_location;
$this->message = $message;
diff --git a/src/Psalm/Issue/MixedMethodCall.php b/src/Psalm/Issue/MixedMethodCall.php
index 939f787ef50..786f937a3ea 100644
--- a/src/Psalm/Issue/MixedMethodCall.php
+++ b/src/Psalm/Issue/MixedMethodCall.php
@@ -1,5 +1,7 @@
origin_location = $origin_location;
diff --git a/src/Psalm/Issue/MixedReturnStatement.php b/src/Psalm/Issue/MixedReturnStatement.php
index 758258911a9..eb1cc2bb962 100644
--- a/src/Psalm/Issue/MixedReturnStatement.php
+++ b/src/Psalm/Issue/MixedReturnStatement.php
@@ -1,5 +1,7 @@
dupe_key = strtolower($method_id);
diff --git a/src/Psalm/Issue/PossiblyUnusedParam.php b/src/Psalm/Issue/PossiblyUnusedParam.php
index 253af21166a..079bb9f1363 100644
--- a/src/Psalm/Issue/PossiblyUnusedParam.php
+++ b/src/Psalm/Issue/PossiblyUnusedParam.php
@@ -1,5 +1,7 @@
dupe_key = $property_id;
diff --git a/src/Psalm/Issue/PossiblyUnusedReturnValue.php b/src/Psalm/Issue/PossiblyUnusedReturnValue.php
index 975b3f9a228..c16ca5ca614 100644
--- a/src/Psalm/Issue/PossiblyUnusedReturnValue.php
+++ b/src/Psalm/Issue/PossiblyUnusedReturnValue.php
@@ -1,5 +1,7 @@
property_id = $property_id;
diff --git a/src/Psalm/Issue/PropertyNotSetInConstructor.php b/src/Psalm/Issue/PropertyNotSetInConstructor.php
index 187a48f9347..1c057ec3422 100644
--- a/src/Psalm/Issue/PropertyNotSetInConstructor.php
+++ b/src/Psalm/Issue/PropertyNotSetInConstructor.php
@@ -1,5 +1,7 @@
dupe_key = $property_id;
diff --git a/src/Psalm/Issue/PropertyTypeCoercion.php b/src/Psalm/Issue/PropertyTypeCoercion.php
index 457dd52ba38..eee59f8306b 100644
--- a/src/Psalm/Issue/PropertyTypeCoercion.php
+++ b/src/Psalm/Issue/PropertyTypeCoercion.php
@@ -1,5 +1,7 @@
* @readonly
*/
- public $journey = [];
+ public array $journey = [];
/**
* @param list $journey
@@ -30,7 +31,7 @@ public function __construct(
string $message,
CodeLocation $code_location,
array $journey,
- string $journey_text
+ string $journey_text,
) {
parent::__construct($message, $code_location);
@@ -58,7 +59,7 @@ public function getTaintTrace(): array
public static function nodeToDataFlowNodeData(
CodeLocation $location,
- string $label
+ string $label,
): DataFlowNodeData {
$selection_bounds = $location->getSelectionBounds();
$snippet_bounds = $location->getSnippetBounds();
diff --git a/src/Psalm/Issue/TaintedLdap.php b/src/Psalm/Issue/TaintedLdap.php
index 4ab8e32e2ff..1fb8cc55461 100644
--- a/src/Psalm/Issue/TaintedLdap.php
+++ b/src/Psalm/Issue/TaintedLdap.php
@@ -1,5 +1,7 @@
dupe_key = strtolower($method_id);
diff --git a/src/Psalm/Issue/UnusedMethodCall.php b/src/Psalm/Issue/UnusedMethodCall.php
index 067b13af8e5..0a4cf9cc945 100644
--- a/src/Psalm/Issue/UnusedMethodCall.php
+++ b/src/Psalm/Issue/UnusedMethodCall.php
@@ -1,5 +1,7 @@
dupe_key = $property_id;
diff --git a/src/Psalm/Issue/UnusedPsalmSuppress.php b/src/Psalm/Issue/UnusedPsalmSuppress.php
index 570012ae719..012ddcc90a8 100644
--- a/src/Psalm/Issue/UnusedPsalmSuppress.php
+++ b/src/Psalm/Issue/UnusedPsalmSuppress.php
@@ -1,5 +1,7 @@
var_name = strtolower($var_name);
diff --git a/src/Psalm/IssueBuffer.php b/src/Psalm/IssueBuffer.php
index e7dfdda9145..fc04545fbea 100644
--- a/src/Psalm/IssueBuffer.php
+++ b/src/Psalm/IssueBuffer.php
@@ -1,5 +1,7 @@
>
*/
- protected static $issues_data = [];
+ protected static array $issues_data = [];
/**
* @var array
*/
- protected static $console_issues = [];
+ protected static array $console_issues = [];
/**
* @var array
*/
- protected static $fixable_issue_counts = [];
+ protected static array $fixable_issue_counts = [];
- /**
- * @var int
- */
- protected static $error_count = 0;
+ protected static int $error_count = 0;
/**
* @var array
*/
- protected static $emitted = [];
+ protected static array $emitted = [];
- /** @var int */
- protected static $recording_level = 0;
+ protected static int $recording_level = 0;
/** @var array> */
- protected static $recorded_issues = [];
+ protected static array $recorded_issues = [];
/**
* @var array>
*/
- protected static $unused_suppressions = [];
+ protected static array $unused_suppressions = [];
/**
* @var array>
*/
- protected static $used_suppressions = [];
+ protected static array $used_suppressions = [];
/** @var array */
private static array $server = [];
@@ -539,7 +537,7 @@ public static function finish(
bool $is_full,
float $start_time,
bool $add_stats = false,
- array $issue_baseline = []
+ array $issue_baseline = [],
): void {
if (!$project_analyzer->stdout_report_options) {
throw new UnexpectedValueException('Cannot finish without stdout report options');
@@ -851,7 +849,7 @@ public static function printSuccessMessage(ProjectAnalyzer $project_analyzer): v
public static function getOutput(
array $issues_data,
ReportOptions $report_options,
- array $mixed_counts = [0, 0]
+ array $mixed_counts = [0, 0],
): string {
$total_expression_count = $mixed_counts[0] + $mixed_counts[1];
$mixed_expression_count = $mixed_counts[0];
diff --git a/src/Psalm/Node/VirtualNode.php b/src/Psalm/Node/VirtualNode.php
index b37dd76385f..23c4e2ce275 100644
--- a/src/Psalm/Node/VirtualNode.php
+++ b/src/Psalm/Node/VirtualNode.php
@@ -1,5 +1,7 @@
statements_analyzer = $statements_analyzer;
}
- /**
- * @return false|Union
- */
- public function infer(PhpParser\Node\Arg $arg)
+ public function infer(PhpParser\Node\Arg $arg): false|Union
{
$already_inferred_type = $this->statements_analyzer->node_data->getType($arg->value);
diff --git a/src/Psalm/Plugin/EventHandler/AddTaintsInterface.php b/src/Psalm/Plugin/EventHandler/AddTaintsInterface.php
index 66909acfeab..e00d65e8e29 100644
--- a/src/Psalm/Plugin/EventHandler/AddTaintsInterface.php
+++ b/src/Psalm/Plugin/EventHandler/AddTaintsInterface.php
@@ -1,5 +1,7 @@
expr = $expr;
$this->context = $context;
diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterAnalysisEvent.php
index 60db94732b0..6c95a0c7394 100644
--- a/src/Psalm/Plugin/EventHandler/Event/AfterAnalysisEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/AfterAnalysisEvent.php
@@ -1,5 +1,7 @@
codebase = $codebase;
$this->issues = $issues;
diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterClassLikeAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterClassLikeAnalysisEvent.php
index a6c51581eae..7b627ab9ffa 100644
--- a/src/Psalm/Plugin/EventHandler/Event/AfterClassLikeAnalysisEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/AfterClassLikeAnalysisEvent.php
@@ -1,5 +1,7 @@
stmt = $stmt;
$this->classlike_storage = $classlike_storage;
diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterClassLikeExistenceCheckEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterClassLikeExistenceCheckEvent.php
index d80732bcb8b..1971f150266 100644
--- a/src/Psalm/Plugin/EventHandler/Event/AfterClassLikeExistenceCheckEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/AfterClassLikeExistenceCheckEvent.php
@@ -1,5 +1,7 @@
fq_class_name = $fq_class_name;
$this->code_location = $code_location;
diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterClassLikeVisitEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterClassLikeVisitEvent.php
index 3861baf0165..709708cee26 100644
--- a/src/Psalm/Plugin/EventHandler/Event/AfterClassLikeVisitEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/AfterClassLikeVisitEvent.php
@@ -1,5 +1,7 @@
stmt = $stmt;
$this->storage = $storage;
diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterCodebasePopulatedEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterCodebasePopulatedEvent.php
index 238bf2489b5..6082be9a1a0 100644
--- a/src/Psalm/Plugin/EventHandler/Event/AfterCodebasePopulatedEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/AfterCodebasePopulatedEvent.php
@@ -1,5 +1,7 @@
expr = $expr;
$this->function_id = $function_id;
diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterExpressionAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterExpressionAnalysisEvent.php
index 25bb8dab8d3..9828b39b70a 100644
--- a/src/Psalm/Plugin/EventHandler/Event/AfterExpressionAnalysisEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/AfterExpressionAnalysisEvent.php
@@ -1,5 +1,7 @@
expr = $expr;
$this->context = $context;
diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterFileAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterFileAnalysisEvent.php
index ec468ced212..da204223da5 100644
--- a/src/Psalm/Plugin/EventHandler/Event/AfterFileAnalysisEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/AfterFileAnalysisEvent.php
@@ -1,5 +1,7 @@
statements_source = $statements_source;
$this->file_context = $file_context;
diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterFunctionCallAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterFunctionCallAnalysisEvent.php
index 96b463c7d65..673ad559beb 100644
--- a/src/Psalm/Plugin/EventHandler/Event/AfterFunctionCallAnalysisEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/AfterFunctionCallAnalysisEvent.php
@@ -1,5 +1,7 @@
expr = $expr;
$this->function_id = $function_id;
diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterFunctionLikeAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterFunctionLikeAnalysisEvent.php
index 2c5b1fa81cb..6a624c22dc3 100644
--- a/src/Psalm/Plugin/EventHandler/Event/AfterFunctionLikeAnalysisEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/AfterFunctionLikeAnalysisEvent.php
@@ -1,5 +1,7 @@
stmt = $stmt;
$this->functionlike_storage = $functionlike_storage;
diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterMethodCallAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterMethodCallAnalysisEvent.php
index b0ad1ef31d5..829f0dc15bc 100644
--- a/src/Psalm/Plugin/EventHandler/Event/AfterMethodCallAnalysisEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/AfterMethodCallAnalysisEvent.php
@@ -1,5 +1,7 @@
expr = $expr;
$this->method_id = $method_id;
diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterStatementAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterStatementAnalysisEvent.php
index f4b5473f9df..a74edefc191 100644
--- a/src/Psalm/Plugin/EventHandler/Event/AfterStatementAnalysisEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/AfterStatementAnalysisEvent.php
@@ -1,5 +1,7 @@
stmt = $stmt;
$this->context = $context;
diff --git a/src/Psalm/Plugin/EventHandler/Event/BeforeExpressionAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/BeforeExpressionAnalysisEvent.php
index e83c44e5fca..63357ee4f7b 100644
--- a/src/Psalm/Plugin/EventHandler/Event/BeforeExpressionAnalysisEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/BeforeExpressionAnalysisEvent.php
@@ -32,7 +32,7 @@ public function __construct(
Context $context,
StatementsSource $statements_source,
Codebase $codebase,
- array $file_replacements = []
+ array $file_replacements = [],
) {
$this->expr = $expr;
$this->context = $context;
diff --git a/src/Psalm/Plugin/EventHandler/Event/BeforeFileAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/BeforeFileAnalysisEvent.php
index 249ab125b38..0dbd4441c89 100644
--- a/src/Psalm/Plugin/EventHandler/Event/BeforeFileAnalysisEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/BeforeFileAnalysisEvent.php
@@ -1,5 +1,7 @@
statements_source = $statements_source;
$this->file_context = $file_context;
diff --git a/src/Psalm/Plugin/EventHandler/Event/BeforeStatementAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/BeforeStatementAnalysisEvent.php
index ccd42151eb5..4a37bd1b5d8 100644
--- a/src/Psalm/Plugin/EventHandler/Event/BeforeStatementAnalysisEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/BeforeStatementAnalysisEvent.php
@@ -32,7 +32,7 @@ public function __construct(
Context $context,
StatementsSource $statements_source,
Codebase $codebase,
- array $file_replacements = []
+ array $file_replacements = [],
) {
$this->stmt = $stmt;
$this->context = $context;
diff --git a/src/Psalm/Plugin/EventHandler/Event/DynamicFunctionStorageProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/DynamicFunctionStorageProviderEvent.php
index 639d2746e32..de9fc4c17b5 100644
--- a/src/Psalm/Plugin/EventHandler/Event/DynamicFunctionStorageProviderEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/DynamicFunctionStorageProviderEvent.php
@@ -32,7 +32,7 @@ public function __construct(
string $function_id,
PhpParser\Node\Expr\FuncCall $func_call,
Context $context,
- CodeLocation $code_location
+ CodeLocation $code_location,
) {
$this->statement_source = $statements_source;
$this->function_id = $function_id;
diff --git a/src/Psalm/Plugin/EventHandler/Event/FunctionExistenceProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/FunctionExistenceProviderEvent.php
index 3edaf09322e..87389cf2b1f 100644
--- a/src/Psalm/Plugin/EventHandler/Event/FunctionExistenceProviderEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/FunctionExistenceProviderEvent.php
@@ -1,5 +1,7 @@
statements_source = $statements_source;
$this->function_id = $function_id;
diff --git a/src/Psalm/Plugin/EventHandler/Event/FunctionParamsProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/FunctionParamsProviderEvent.php
index 23f3e05ff15..a26b95a3c1a 100644
--- a/src/Psalm/Plugin/EventHandler/Event/FunctionParamsProviderEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/FunctionParamsProviderEvent.php
@@ -1,5 +1,7 @@
statements_source = $statements_source;
$this->function_id = $function_id;
diff --git a/src/Psalm/Plugin/EventHandler/Event/FunctionReturnTypeProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/FunctionReturnTypeProviderEvent.php
index c620637bb4d..e34e333e943 100644
--- a/src/Psalm/Plugin/EventHandler/Event/FunctionReturnTypeProviderEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/FunctionReturnTypeProviderEvent.php
@@ -1,5 +1,7 @@
statements_source = $statements_source;
$this->function_id = $function_id;
diff --git a/src/Psalm/Plugin/EventHandler/Event/MethodExistenceProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/MethodExistenceProviderEvent.php
index ff1fb8f48e5..8c86c5e2e33 100644
--- a/src/Psalm/Plugin/EventHandler/Event/MethodExistenceProviderEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/MethodExistenceProviderEvent.php
@@ -1,5 +1,7 @@
fq_classlike_name = $fq_classlike_name;
$this->method_name_lowercase = $method_name_lowercase;
diff --git a/src/Psalm/Plugin/EventHandler/Event/MethodParamsProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/MethodParamsProviderEvent.php
index eb366963c66..babc8ffa379 100644
--- a/src/Psalm/Plugin/EventHandler/Event/MethodParamsProviderEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/MethodParamsProviderEvent.php
@@ -1,5 +1,7 @@
fq_classlike_name = $fq_classlike_name;
$this->method_name_lowercase = $method_name_lowercase;
diff --git a/src/Psalm/Plugin/EventHandler/Event/MethodReturnTypeProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/MethodReturnTypeProviderEvent.php
index 8e4e58bced2..e6a96aba9b3 100644
--- a/src/Psalm/Plugin/EventHandler/Event/MethodReturnTypeProviderEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/MethodReturnTypeProviderEvent.php
@@ -1,5 +1,7 @@
|null */
private ?array $template_type_parameters;
private ?string $called_fq_classlike_name;
@@ -35,7 +34,6 @@ final class MethodReturnTypeProviderEvent
* but another plugin may be able to determine the type, return null. Otherwise return a mixed union type if
* something should be returned, but can't be more specific.
*
- * @param PhpParser\Node\Expr\MethodCall|PhpParser\Node\Expr\StaticCall $stmt
* @param non-empty-list|null $template_type_parameters
* @param lowercase-string $method_name_lowercase
* @param lowercase-string $called_method_name_lowercase
@@ -45,12 +43,12 @@ public function __construct(
StatementsSource $source,
string $fq_classlike_name,
string $method_name_lowercase,
- $stmt,
+ PhpParser\Node\Expr\MethodCall|PhpParser\Node\Expr\StaticCall $stmt,
Context $context,
CodeLocation $code_location,
?array $template_type_parameters = null,
?string $called_fq_classlike_name = null,
- ?string $called_method_name_lowercase = null
+ ?string $called_method_name_lowercase = null,
) {
$this->source = $source;
$this->fq_classlike_name = $fq_classlike_name;
@@ -120,10 +118,7 @@ public function getCalledMethodNameLowercase(): ?string
return $this->called_method_name_lowercase;
}
- /**
- * @return PhpParser\Node\Expr\MethodCall|PhpParser\Node\Expr\StaticCall
- */
- public function getStmt()
+ public function getStmt(): PhpParser\Node\Expr\MethodCall|PhpParser\Node\Expr\StaticCall
{
return $this->stmt;
}
diff --git a/src/Psalm/Plugin/EventHandler/Event/MethodVisibilityProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/MethodVisibilityProviderEvent.php
index ffdf8e54b4f..b6b46458c7a 100644
--- a/src/Psalm/Plugin/EventHandler/Event/MethodVisibilityProviderEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/MethodVisibilityProviderEvent.php
@@ -1,5 +1,7 @@
source = $source;
$this->fq_classlike_name = $fq_classlike_name;
diff --git a/src/Psalm/Plugin/EventHandler/Event/PropertyExistenceProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/PropertyExistenceProviderEvent.php
index 20681f01e61..c71b544f535 100644
--- a/src/Psalm/Plugin/EventHandler/Event/PropertyExistenceProviderEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/PropertyExistenceProviderEvent.php
@@ -1,5 +1,7 @@
fq_classlike_name = $fq_classlike_name;
$this->property_name = $property_name;
diff --git a/src/Psalm/Plugin/EventHandler/Event/PropertyTypeProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/PropertyTypeProviderEvent.php
index 2f147607506..035ac12dc77 100644
--- a/src/Psalm/Plugin/EventHandler/Event/PropertyTypeProviderEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/PropertyTypeProviderEvent.php
@@ -1,5 +1,7 @@
fq_classlike_name = $fq_classlike_name;
$this->property_name = $property_name;
diff --git a/src/Psalm/Plugin/EventHandler/Event/PropertyVisibilityProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/PropertyVisibilityProviderEvent.php
index 8a99c821fc1..eaccc482f22 100644
--- a/src/Psalm/Plugin/EventHandler/Event/PropertyVisibilityProviderEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/PropertyVisibilityProviderEvent.php
@@ -1,5 +1,7 @@
source = $source;
$this->fq_classlike_name = $fq_classlike_name;
diff --git a/src/Psalm/Plugin/EventHandler/Event/StringInterpreterEvent.php b/src/Psalm/Plugin/EventHandler/Event/StringInterpreterEvent.php
index 8d612bf721c..968d955af0d 100644
--- a/src/Psalm/Plugin/EventHandler/Event/StringInterpreterEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/StringInterpreterEvent.php
@@ -1,5 +1,7 @@
*/
- protected $issues_data;
+ protected array $issues_data;
/** @var array */
- protected $fixable_issue_counts;
+ protected array $fixable_issue_counts;
- /** @var bool */
- protected $use_color;
+ protected bool $use_color;
- /** @var bool */
- protected $show_snippet;
+ protected bool $show_snippet;
- /** @var bool */
- protected $show_info;
+ protected bool $show_info;
- /** @var bool */
- protected $pretty;
+ protected bool $pretty;
- /** @var bool */
- protected $in_ci;
+ protected bool $in_ci;
- /** @var int */
- protected $mixed_expression_count;
+ protected int $mixed_expression_count;
- /** @var int */
- protected $total_expression_count;
+ protected int $total_expression_count;
/**
* @param array $issues_data
@@ -69,7 +64,7 @@ public function __construct(
array $fixable_issue_counts,
ReportOptions $report_options,
int $mixed_expression_count = 1,
- int $total_expression_count = 1
+ int $total_expression_count = 1,
) {
if (!$report_options->show_info) {
$this->issues_data = array_filter(
diff --git a/src/Psalm/Report/ByIssueLevelAndTypeReport.php b/src/Psalm/Report/ByIssueLevelAndTypeReport.php
index c657b415749..e3e4e54db5f 100644
--- a/src/Psalm/Report/ByIssueLevelAndTypeReport.php
+++ b/src/Psalm/Report/ByIssueLevelAndTypeReport.php
@@ -1,5 +1,7 @@
file_name . ':' . $data->line_from . ':' . $data->column_from;
diff --git a/src/Psalm/Report/CheckstyleReport.php b/src/Psalm/Report/CheckstyleReport.php
index d862923b663..52de1a73b0c 100644
--- a/src/Psalm/Report/CheckstyleReport.php
+++ b/src/Psalm/Report/CheckstyleReport.php
@@ -1,5 +1,7 @@
file_name . ':' . $data->line_from . ':' . $data->column_from;
diff --git a/src/Psalm/Report/CountReport.php b/src/Psalm/Report/CountReport.php
index b044d851651..a0ec59602ba 100644
--- a/src/Psalm/Report/CountReport.php
+++ b/src/Psalm/Report/CountReport.php
@@ -9,7 +9,7 @@
use function array_key_exists;
use function uksort;
-class CountReport extends Report
+final class CountReport extends Report
{
public function create(): string
{
diff --git a/src/Psalm/Report/EmacsReport.php b/src/Psalm/Report/EmacsReport.php
index c1cb008e61d..256d1082e46 100644
--- a/src/Psalm/Report/EmacsReport.php
+++ b/src/Psalm/Report/EmacsReport.php
@@ -1,5 +1,7 @@
key = $key;
}
public function getNegation(): Assertion
diff --git a/src/Psalm/Storage/Assertion/HasAtLeastCount.php b/src/Psalm/Storage/Assertion/HasAtLeastCount.php
index 3a30e1d5666..0c2555b9994 100644
--- a/src/Psalm/Storage/Assertion/HasAtLeastCount.php
+++ b/src/Psalm/Storage/Assertion/HasAtLeastCount.php
@@ -1,5 +1,7 @@
is_negatable = $is_negatable;
}
public function isNegation(): bool
diff --git a/src/Psalm/Storage/Assertion/IsNotIdentical.php b/src/Psalm/Storage/Assertion/IsNotIdentical.php
index 978ca956df6..f483cef0293 100644
--- a/src/Psalm/Storage/Assertion/IsNotIdentical.php
+++ b/src/Psalm/Storage/Assertion/IsNotIdentical.php
@@ -1,5 +1,7 @@
is_negatable = $is_negatable;
}
public function getNegation(): Assertion
diff --git a/src/Psalm/Storage/Assertion/NotInArray.php b/src/Psalm/Storage/Assertion/NotInArray.php
index 73c352d47dd..824ed5db303 100644
--- a/src/Psalm/Storage/Assertion/NotInArray.php
+++ b/src/Psalm/Storage/Assertion/NotInArray.php
@@ -1,5 +1,7 @@
name = $name;
$this->type = $type;
diff --git a/src/Psalm/Storage/AttributeStorage.php b/src/Psalm/Storage/AttributeStorage.php
index 7b9b0e7298a..8cbc499a637 100644
--- a/src/Psalm/Storage/AttributeStorage.php
+++ b/src/Psalm/Storage/AttributeStorage.php
@@ -1,5 +1,7 @@
*/
- public $args;
+ public array $args;
/**
- * @var CodeLocation
* @psalm-suppress PossiblyUnusedProperty part of public API
*/
- public $location;
+ public CodeLocation $location;
/**
- * @var CodeLocation
* @psalm-suppress PossiblyUnusedProperty part of public API
*/
- public $name_location;
+ public CodeLocation $name_location;
/**
* @param list $args
@@ -39,7 +36,7 @@ public function __construct(
string $fq_class_name,
array $args,
CodeLocation $location,
- CodeLocation $name_location
+ CodeLocation $name_location,
) {
$this->fq_class_name = $fq_class_name;
$this->args = $args;
diff --git a/src/Psalm/Storage/ClassConstantStorage.php b/src/Psalm/Storage/ClassConstantStorage.php
index 9c6d7cfcde5..78488412a81 100644
--- a/src/Psalm/Storage/ClassConstantStorage.php
+++ b/src/Psalm/Storage/ClassConstantStorage.php
@@ -1,5 +1,7 @@
visibility = $visibility;
$this->location = $location;
diff --git a/src/Psalm/Storage/ClassLikeStorage.php b/src/Psalm/Storage/ClassLikeStorage.php
index f8564444a26..8fabc2e3edd 100644
--- a/src/Psalm/Storage/ClassLikeStorage.php
+++ b/src/Psalm/Storage/ClassLikeStorage.php
@@ -1,5 +1,7 @@
*/
- public $constants = [];
+ public array $constants = [];
/**
* Aliases to help Psalm understand constant refs
- *
- * @var ?Aliases
*/
- public $aliases;
+ public ?Aliases $aliases = null;
- /**
- * @var bool
- */
- public $populated = false;
+ public bool $populated = false;
- /**
- * @var bool
- */
- public $stubbed = false;
+ public bool $stubbed = false;
- /**
- * @var bool
- */
- public $deprecated = false;
+ public bool $deprecated = false;
/**
* @var list
*/
- public $internal = [];
+ public array $internal = [];
/**
* @var TTemplateParam[]
*/
- public $templatedMixins = [];
+ public array $templatedMixins = [];
/**
* @var list
*/
- public $namedMixins = [];
+ public array $namedMixins = [];
- /**
- * @var ?string
- */
- public $mixin_declaring_fqcln;
+ public ?string $mixin_declaring_fqcln = null;
- /**
- * @var ?bool
- */
- public $sealed_properties = null;
+ public ?bool $sealed_properties = null;
- /**
- * @var ?bool
- */
- public $sealed_methods = null;
+ public ?bool $sealed_methods = null;
- /**
- * @var bool
- */
- public $override_property_visibility = false;
+ public bool $override_property_visibility = false;
- /**
- * @var bool
- */
- public $override_method_visibility = false;
+ public bool $override_method_visibility = false;
/**
* @var array
*/
- public $suppressed_issues = [];
+ public array $suppressed_issues = [];
- /**
- * @var string
- */
- public $name;
+ public string $name;
/**
* Is this class user-defined
- *
- * @var bool
*/
- public $user_defined = false;
+ public bool $user_defined = false;
/**
* Interfaces this class implements directly
*
* @var array
*/
- public $direct_class_interfaces = [];
+ public array $direct_class_interfaces = [];
/**
* Interfaces this class implements explicitly and implicitly
*
* @var array
*/
- public $class_implements = [];
+ public array $class_implements = [];
/**
* Parent interfaces listed explicitly
*
* @var array
*/
- public $direct_interface_parents = [];
+ public array $direct_interface_parents = [];
/**
* Parent interfaces
*
* @var array
*/
- public $parent_interfaces = [];
+ public array $parent_interfaces = [];
/**
* There can only be one direct parent class
- *
- * @var ?string
*/
- public $parent_class;
+ public ?string $parent_class = null;
/**
* Parent classes
*
* @var array
*/
- public $parent_classes = [];
+ public array $parent_classes = [];
- /**
- * @var CodeLocation|null
- */
- public $location;
+ public ?CodeLocation $location = null;
- /**
- * @var CodeLocation|null
- */
- public $stmt_location;
+ public ?CodeLocation $stmt_location = null;
- /**
- * @var CodeLocation|null
- */
- public $namespace_name_location;
+ public ?CodeLocation $namespace_name_location = null;
- /**
- * @var bool
- */
- public $abstract = false;
+ public bool $abstract = false;
- /**
- * @var bool
- */
- public $final = false;
+ public bool $final = false;
- /**
- * @var bool
- */
- public $final_from_docblock = false;
+ public bool $final_from_docblock = false;
/**
* @var array
*/
- public $used_traits = [];
+ public array $used_traits = [];
/**
* @var array
*/
- public $trait_alias_map = [];
+ public array $trait_alias_map = [];
/**
* @var array
@@ -194,57 +145,39 @@ final class ClassLikeStorage implements HasAttributesInterface
/**
* @var array
*/
- public $trait_final_map = [];
+ public array $trait_final_map = [];
/**
* @var array
*/
- public $trait_visibility_map = [];
+ public array $trait_visibility_map = [];
- /**
- * @var bool
- */
- public $is_trait = false;
+ public bool $is_trait = false;
- /**
- * @var bool
- */
- public $is_interface = false;
+ public bool $is_interface = false;
- /**
- * @var bool
- */
- public $is_enum = false;
+ public bool $is_enum = false;
- /**
- * @var bool
- */
- public $external_mutation_free = false;
+ public bool $external_mutation_free = false;
- /**
- * @var bool
- */
- public $mutation_free = false;
+ public bool $mutation_free = false;
- /**
- * @var bool
- */
- public $specialize_instance = false;
+ public bool $specialize_instance = false;
/**
* @var array
*/
- public $methods = [];
+ public array $methods = [];
/**
* @var array
*/
- public $pseudo_methods = [];
+ public array $pseudo_methods = [];
/**
* @var array
*/
- public $pseudo_static_methods = [];
+ public array $pseudo_static_methods = [];
/**
* Maps pseudo method names to the original declaring method identifier
@@ -254,17 +187,17 @@ final class ClassLikeStorage implements HasAttributesInterface
*
* @var array
*/
- public $declaring_pseudo_method_ids = [];
+ public array $declaring_pseudo_method_ids = [];
/**
* @var array
*/
- public $declaring_method_ids = [];
+ public array $declaring_method_ids = [];
/**
* @var array
*/
- public $appearing_method_ids = [];
+ public array $appearing_method_ids = [];
/**
* Map from lowercase method name to list of declarations in order from parent, to grandparent, to
@@ -273,62 +206,59 @@ final class ClassLikeStorage implements HasAttributesInterface
*
* @var array>
*/
- public $overridden_method_ids = [];
+ public array $overridden_method_ids = [];
/**
* @var array
*/
- public $documenting_method_ids = [];
+ public array $documenting_method_ids = [];
/**
* @var array
*/
- public $inheritable_method_ids = [];
+ public array $inheritable_method_ids = [];
/**
* @var array>
*/
- public $potential_declaring_method_ids = [];
+ public array $potential_declaring_method_ids = [];
/**
* @var array
*/
- public $properties = [];
+ public array $properties = [];
/**
* @var array
*/
- public $pseudo_property_set_types = [];
+ public array $pseudo_property_set_types = [];
/**
* @var array
*/
- public $pseudo_property_get_types = [];
+ public array $pseudo_property_get_types = [];
/**
* @var array
*/
- public $declaring_property_ids = [];
+ public array $declaring_property_ids = [];
/**
* @var array
*/
- public $appearing_property_ids = [];
+ public array $appearing_property_ids = [];
- /**
- * @var ?Union
- */
- public $inheritors = null;
+ public ?Union $inheritors = null;
/**
* @var array
*/
- public $inheritable_property_ids = [];
+ public array $inheritable_property_ids = [];
/**
* @var array>
*/
- public $overridden_property_ids = [];
+ public array $overridden_property_ids = [];
/**
* An array holding the class template "as" types.
@@ -341,12 +271,12 @@ final class ClassLikeStorage implements HasAttributesInterface
*
* @var array>|null
*/
- public $template_types;
+ public ?array $template_types = null;
/**
* @var array|null
*/
- public $template_covariants;
+ public ?array $template_covariants = null;
/**
* A map of which generic classlikes are extended or implemented by this class or interface.
@@ -356,7 +286,7 @@ final class ClassLikeStorage implements HasAttributesInterface
* @internal
* @var array>|null
*/
- public $template_extended_offsets;
+ public ?array $template_extended_offsets = null;
/**
* A map of which generic classlikes are extended or implemented by this class or interface.
@@ -372,108 +302,87 @@ final class ClassLikeStorage implements HasAttributesInterface
*
* @var array>|null
*/
- public $template_extended_params;
+ public ?array $template_extended_params = null;
/**
* @var array|null
*/
- public $template_type_extends_count;
+ public ?array $template_type_extends_count = null;
/**
* @var array|null
*/
- public $template_type_implements_count;
+ public ?array $template_type_implements_count = null;
- /**
- * @var ?Union
- */
- public $yield;
+ public ?Union $yield = null;
- /** @var ?string */
- public $declaring_yield_fqcn;
+ public ?string $declaring_yield_fqcn = null;
/**
* @var array|null
*/
- public $template_type_uses_count;
+ public ?array $template_type_uses_count = null;
/**
* @var array
*/
- public $initialized_properties = [];
+ public array $initialized_properties = [];
/**
* @var array
*/
- public $invalid_dependencies = [];
+ public array $invalid_dependencies = [];
/**
* @var array
*/
- public $dependent_classlikes = [];
+ public array $dependent_classlikes = [];
/**
* A hash of the source file's name, contents, and this file's modified on date
- *
- * @var string
*/
- public $hash = '';
+ public string $hash = '';
- /**
- * @var bool
- */
- public $has_visitor_issues = false;
+ public bool $has_visitor_issues = false;
/**
* @var list
*/
- public $docblock_issues = [];
+ public array $docblock_issues = [];
/**
* @var array
*/
- public $type_aliases = [];
+ public array $type_aliases = [];
- /**
- * @var bool
- */
- public $preserve_constructor_signature = false;
+ public bool $preserve_constructor_signature = false;
- /**
- * @var bool
- */
- public $enforce_template_inheritance = false;
+ public bool $enforce_template_inheritance = false;
- /**
- * @var null|string
- */
- public $extension_requirement;
+ public ?string $extension_requirement = null;
/**
* @var array
*/
- public $implementation_requirements = [];
+ public array $implementation_requirements = [];
/**
* @var list
*/
- public $attributes = [];
+ public array $attributes = [];
/**
* @var array
*/
- public $enum_cases = [];
+ public array $enum_cases = [];
/**
* @var 'int'|'string'|null
*/
- public $enum_type;
+ public ?string $enum_type = null;
- /**
- * @var ?string
- */
- public $description;
+ public ?string $description = null;
public bool $public_api = false;
@@ -494,7 +403,7 @@ public function getAttributeStorages(): array
public function hasAttributeIncludingParents(
string $fq_class_name,
- Codebase $codebase
+ Codebase $codebase,
): bool {
if ($this->hasAttribute($fq_class_name)) {
return true;
diff --git a/src/Psalm/Storage/CustomMetadataTrait.php b/src/Psalm/Storage/CustomMetadataTrait.php
index 85a8610a690..e2679ee01c9 100644
--- a/src/Psalm/Storage/CustomMetadataTrait.php
+++ b/src/Psalm/Storage/CustomMetadataTrait.php
@@ -1,5 +1,7 @@
*/
- public $custom_metadata = [];
+ public array $custom_metadata = [];
}
diff --git a/src/Psalm/Storage/EnumCaseStorage.php b/src/Psalm/Storage/EnumCaseStorage.php
index e6e98eb44db..12cf8b1098e 100644
--- a/src/Psalm/Storage/EnumCaseStorage.php
+++ b/src/Psalm/Storage/EnumCaseStorage.php
@@ -1,5 +1,7 @@
value = $value;
$this->stmt_location = $location;
diff --git a/src/Psalm/Storage/FileStorage.php b/src/Psalm/Storage/FileStorage.php
index fe818ff6d86..ce309152bba 100644
--- a/src/Psalm/Storage/FileStorage.php
+++ b/src/Psalm/Storage/FileStorage.php
@@ -1,5 +1,7 @@
*/
- public $classlikes_in_file = [];
+ public array $classlikes_in_file = [];
/**
* @var array
*/
- public $referenced_classlikes = [];
+ public array $referenced_classlikes = [];
/**
* @var array
*/
- public $required_classes = [];
+ public array $required_classes = [];
/**
* @var array
*/
- public $required_interfaces = [];
+ public array $required_interfaces = [];
- /** @var string */
- public $file_path;
+ public string $file_path;
/**
* @var array
*/
- public $functions = [];
+ public array $functions = [];
/** @var array */
- public $declaring_function_ids = [];
+ public array $declaring_function_ids = [];
/**
* @var array
*/
- public $constants = [];
+ public array $constants = [];
/** @var array */
- public $declaring_constants = [];
+ public array $declaring_constants = [];
/** @var array */
- public $required_file_paths = [];
+ public array $required_file_paths = [];
/** @var array */
- public $required_by_file_paths = [];
+ public array $required_by_file_paths = [];
- /** @var bool */
- public $populated = false;
+ public bool $populated = false;
- /** @var bool */
- public $deep_scan = false;
+ public bool $deep_scan = false;
- /** @var bool */
- public $has_extra_statements = false;
+ public bool $has_extra_statements = false;
- /**
- * @var string
- */
- public $hash = '';
+ public string $hash = '';
- /**
- * @var bool
- */
- public $has_visitor_issues = false;
+ public bool $has_visitor_issues = false;
/**
* @var list
*/
- public $docblock_issues = [];
+ public array $docblock_issues = [];
/**
* @var array
*/
- public $type_aliases = [];
+ public array $type_aliases = [];
/**
* @var array
*/
- public $classlike_aliases = [];
+ public array $classlike_aliases = [];
- /** @var ?Aliases */
- public $aliases;
+ public ?Aliases $aliases = null;
/** @var Aliases[] */
- public $namespace_aliases = [];
+ public array $namespace_aliases = [];
public function __construct(string $file_path)
{
diff --git a/src/Psalm/Storage/FunctionLikeParameter.php b/src/Psalm/Storage/FunctionLikeParameter.php
index 6c4a241080d..cdeaee2d3eb 100644
--- a/src/Psalm/Storage/FunctionLikeParameter.php
+++ b/src/Psalm/Storage/FunctionLikeParameter.php
@@ -1,5 +1,7 @@
|null
*/
- public $sinks;
+ public ?array $sinks = null;
- /**
- * @var bool
- */
- public $assert_untainted = false;
+ public bool $assert_untainted = false;
- /**
- * @var bool
- */
- public $type_inferred = false;
+ public bool $type_inferred = false;
- /**
- * @var bool
- */
- public $expect_variable = false;
+ public bool $expect_variable = false;
- /**
- * @var bool
- */
- public $promoted_property = false;
+ public bool $promoted_property = false;
/**
* @var list
*/
- public $attributes = [];
+ public array $attributes = [];
- /**
- * @var ?string
- */
- public $description;
+ public ?string $description = null;
/**
* @psalm-external-mutation-free
- * @param Union|UnresolvedConstantComponent|null $default_type
*/
public function __construct(
string $name,
@@ -127,8 +74,8 @@ public function __construct(
bool $is_optional = true,
bool $is_nullable = false,
bool $is_variadic = false,
- $default_type = null,
- ?Union $out_type = null
+ Union|UnresolvedConstantComponent|null $default_type = null,
+ ?Union $out_type = null,
) {
$this->name = $name;
$this->by_ref = $by_ref;
diff --git a/src/Psalm/Storage/FunctionLikeStorage.php b/src/Psalm/Storage/FunctionLikeStorage.php
index 7da0a2cea04..ef13057d9dc 100644
--- a/src/Psalm/Storage/FunctionLikeStorage.php
+++ b/src/Psalm/Storage/FunctionLikeStorage.php
@@ -1,5 +1,7 @@
*/
- public $params = [];
+ public array $params = [];
/**
* @psalm-readonly-allow-private-mutation
* @var array
*/
- public $param_lookup = [];
+ public array $param_lookup = [];
- /**
- * @var Union|null
- */
- public $return_type;
+ public ?Union $return_type = null;
- /**
- * @var CodeLocation|null
- */
- public $return_type_location;
+ public ?CodeLocation $return_type_location = null;
- /**
- * @var Union|null
- */
- public $signature_return_type;
+ public ?Union $signature_return_type = null;
- /**
- * @var CodeLocation|null
- */
- public $signature_return_type_location;
+ public ?CodeLocation $signature_return_type_location = null;
- /**
- * @var ?string
- */
- public $cased_name;
+ public ?string $cased_name = null;
/**
* @var array
*/
- public $suppressed_issues = [];
+ public array $suppressed_issues = [];
- /**
- * @var ?bool
- */
- public $deprecated;
+ public ?bool $deprecated = null;
/**
* @var list
*/
- public $internal = [];
+ public array $internal = [];
- /**
- * @var bool
- */
- public $variadic = false;
+ public bool $variadic = false;
- /**
- * @var bool
- */
- public $returns_by_ref = false;
+ public bool $returns_by_ref = false;
- /**
- * @var ?int
- */
- public $required_param_count;
+ public ?int $required_param_count = null;
/**
* @var array
*/
- public $defined_constants = [];
+ public array $defined_constants = [];
/**
* @var array
*/
- public $global_variables = [];
+ public array $global_variables = [];
/**
* @var array
*/
- public $global_types = [];
+ public array $global_types = [];
/**
* An array holding the class template "as" types.
@@ -120,57 +89,45 @@ abstract class FunctionLikeStorage implements HasAttributesInterface
*
* @var array>|null
*/
- public $template_types;
+ public ?array $template_types = null;
/**
* @var array
*/
- public $assertions = [];
+ public array $assertions = [];
/**
* @var array
*/
- public $if_true_assertions = [];
+ public array $if_true_assertions = [];
/**
* @var array
*/
- public $if_false_assertions = [];
+ public array $if_false_assertions = [];
- /**
- * @var bool
- */
- public $has_visitor_issues = false;
+ public bool $has_visitor_issues = false;
/**
* @var list
*/
- public $docblock_issues = [];
+ public array $docblock_issues = [];
/**
* @var array
*/
- public $throws = [];
+ public array $throws = [];
/**
* @var array
*/
- public $throw_locations = [];
+ public array $throw_locations = [];
- /**
- * @var bool
- */
- public $has_yield = false;
+ public bool $has_yield = false;
- /**
- * @var bool
- */
- public $mutation_free = false;
+ public bool $mutation_free = false;
- /**
- * @var string|null
- */
- public $return_type_description;
+ public ?string $return_type_description = null;
/**
* @var array
@@ -179,68 +136,54 @@ abstract class FunctionLikeStorage implements HasAttributesInterface
public bool $has_undertyped_native_parameters = false;
- /**
- * @var bool
- */
- public $is_static = false;
+ public bool $is_static = false;
- /**
- * @var bool
- */
- public $pure = false;
+ public bool $pure = false;
/**
* Whether or not the function output is dependent solely on input - a function can be
* impure but still have this property (e.g. var_export). Useful for taint analysis.
- *
- * @var bool
*/
- public $specialize_call = false;
+ public bool $specialize_call = false;
/**
* @var array
*/
- public $taint_source_types = [];
+ public array $taint_source_types = [];
/**
* @var array
*/
- public $added_taints = [];
+ public array $added_taints = [];
/**
* @var array
*/
- public $removed_taints = [];
+ public array $removed_taints = [];
/**
* @var array
*/
- public $conditionally_removed_taints = [];
+ public array $conditionally_removed_taints = [];
/**
* @var array
*/
- public $return_source_params = [];
+ public array $return_source_params = [];
- /**
- * @var bool
- */
- public $allow_named_arg_calls = true;
+ public bool $allow_named_arg_calls = true;
/**
* @var list
*/
- public $attributes = [];
+ public array $attributes = [];
/**
* @var list, return: bool}>|null
*/
- public $proxy_calls = [];
+ public ?array $proxy_calls = [];
- /**
- * @var ?string
- */
- public $description;
+ public ?string $description = null;
public bool $public_api = false;
diff --git a/src/Psalm/Storage/FunctionStorage.php b/src/Psalm/Storage/FunctionStorage.php
index e39e7cc2356..f9c9dcfeeb2 100644
--- a/src/Psalm/Storage/FunctionStorage.php
+++ b/src/Psalm/Storage/FunctionStorage.php
@@ -1,9 +1,11 @@
*/
- public $byref_uses = [];
+ public array $byref_uses = [];
}
diff --git a/src/Psalm/Storage/ImmutableNonCloneableTrait.php b/src/Psalm/Storage/ImmutableNonCloneableTrait.php
index 7609a73a8a4..092d702fbb4 100644
--- a/src/Psalm/Storage/ImmutableNonCloneableTrait.php
+++ b/src/Psalm/Storage/ImmutableNonCloneableTrait.php
@@ -1,5 +1,7 @@
*/
- public $this_property_mutations;
+ public ?array $this_property_mutations = null;
- /**
- * @var Union|null
- */
- public $self_out_type;
+ public ?Union $self_out_type = null;
- /**
- * @var Union|null
- */
- public $if_this_is_type = null;
- /**
- * @var bool
- */
- public $stubbed = false;
+ public ?Union $if_this_is_type = null;
+ public bool $stubbed = false;
- /**
- * @var bool
- */
- public $probably_fluent = false;
+ public bool $probably_fluent = false;
}
diff --git a/src/Psalm/Storage/Possibilities.php b/src/Psalm/Storage/Possibilities.php
index 70eb35287b4..62959661725 100644
--- a/src/Psalm/Storage/Possibilities.php
+++ b/src/Psalm/Storage/Possibilities.php
@@ -1,5 +1,7 @@
the rule being asserted
*/
- public $rule;
+ public array $rule;
/**
* @var int|string the id of the property/variable, or
* the parameter offset of the affected arg
*/
- public $var_id;
+ public int|string $var_id;
/**
- * @param string|int $var_id
* @param list $rule
*/
- public function __construct($var_id, array $rule)
+ public function __construct(string|int $var_id, array $rule)
{
$this->rule = $rule;
$this->var_id = $var_id;
@@ -36,7 +37,7 @@ public function __construct($var_id, array $rule)
public function getUntemplatedCopy(
TemplateResult $template_result,
?string $this_var_id,
- ?Codebase $codebase
+ ?Codebase $codebase,
): self {
$assertion_rules = [];
diff --git a/src/Psalm/Storage/PropertyStorage.php b/src/Psalm/Storage/PropertyStorage.php
index 745e1e50ea3..3eb742c281e 100644
--- a/src/Psalm/Storage/PropertyStorage.php
+++ b/src/Psalm/Storage/PropertyStorage.php
@@ -1,5 +1,7 @@
*/
- public $internal = [];
+ public array $internal = [];
- /**
- * @var ?string
- */
- public $getter_method;
+ public ?string $getter_method = null;
- /**
- * @var bool
- */
- public $is_promoted = false;
+ public bool $is_promoted = false;
/**
* @var list
*/
- public $attributes = [];
+ public array $attributes = [];
/**
* @var array
*/
- public $suppressed_issues = [];
+ public array $suppressed_issues = [];
- /**
- * @var ?string
- */
- public $description;
+ public ?string $description = null;
public function getInfo(): string
{
diff --git a/src/Psalm/Type.php b/src/Psalm/Type.php
index f1acd2f3a5f..7960ef264b6 100644
--- a/src/Psalm/Type.php
+++ b/src/Psalm/Type.php
@@ -1,5 +1,7 @@
getKey();
}
@@ -741,7 +730,7 @@ abstract public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): ?string;
abstract public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool;
@@ -759,7 +748,7 @@ public function replaceTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): self {
// do nothing
return $this;
@@ -770,7 +759,7 @@ public function replaceTemplateTypesWithStandins(
*/
public function replaceTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): self {
// do nothing
return $this;
diff --git a/src/Psalm/Type/Atomic/CallableTrait.php b/src/Psalm/Type/Atomic/CallableTrait.php
index 4ca12639b5e..6f1c38d1298 100644
--- a/src/Psalm/Type/Atomic/CallableTrait.php
+++ b/src/Psalm/Type/Atomic/CallableTrait.php
@@ -1,5 +1,7 @@
|null
*/
- public $params = [];
+ public ?array $params = [];
- /**
- * @var Union|null
- */
- public $return_type;
+ public ?Union $return_type = null;
- /**
- * @var ?bool
- */
- public $is_pure;
+ public ?bool $is_pure = null;
/**
* Constructs a new instance of a generic type
@@ -45,7 +41,7 @@ public function __construct(
?array $params = null,
?Union $return_type = null,
?bool $is_pure = null,
- bool $from_docblock = false
+ bool $from_docblock = false,
) {
$this->value = $value;
$this->params = $params;
@@ -127,7 +123,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
if ($use_phpdoc_format) {
if ($this instanceof TNamedObject) {
@@ -182,7 +178,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): string {
if ($this instanceof TNamedObject) {
return parent::toNamespacedString($namespace, $aliased_classes, $this_class, true);
@@ -232,7 +228,7 @@ protected function replaceCallableTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): ?array {
$replaced = false;
$params = $this->params;
@@ -300,7 +296,7 @@ protected function replaceCallableTemplateTypesWithStandins(
*/
protected function replaceCallableTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): ?array {
$replaced = false;
diff --git a/src/Psalm/Type/Atomic/DependentType.php b/src/Psalm/Type/Atomic/DependentType.php
index 98cf7a5749c..ac4c953509b 100644
--- a/src/Psalm/Type/Atomic/DependentType.php
+++ b/src/Psalm/Type/Atomic/DependentType.php
@@ -1,5 +1,7 @@
type_params;
foreach ($type_params as $offset => $type_param) {
diff --git a/src/Psalm/Type/Atomic/HasIntersectionTrait.php b/src/Psalm/Type/Atomic/HasIntersectionTrait.php
index 9a8bc2864e2..22d07725fcd 100644
--- a/src/Psalm/Type/Atomic/HasIntersectionTrait.php
+++ b/src/Psalm/Type/Atomic/HasIntersectionTrait.php
@@ -1,5 +1,7 @@
extra_types) {
return '';
@@ -91,7 +93,7 @@ public function getIntersectionTypes(): array
*/
protected function replaceIntersectionTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): ?array {
if (!$this->extra_types) {
return null;
@@ -137,7 +139,7 @@ protected function replaceIntersectionTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): ?array {
if (!$this->extra_types) {
return null;
diff --git a/src/Psalm/Type/Atomic/Scalar.php b/src/Psalm/Type/Atomic/Scalar.php
index 764b34af86a..739bb9bb514 100644
--- a/src/Psalm/Type/Atomic/Scalar.php
+++ b/src/Psalm/Type/Atomic/Scalar.php
@@ -1,5 +1,7 @@
= 7_02_00 ? ($this->extends ?? 'object') : null;
}
@@ -45,7 +44,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
return $this->extends ?? 'object';
}
diff --git a/src/Psalm/Type/Atomic/TArray.php b/src/Psalm/Type/Atomic/TArray.php
index 06477607592..cf90faf8851 100644
--- a/src/Psalm/Type/Atomic/TArray.php
+++ b/src/Psalm/Type/Atomic/TArray.php
@@ -1,5 +1,7 @@
getKey();
}
@@ -119,7 +118,7 @@ public function replaceTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): self {
$type_params = $this->replaceTypeParamsTemplateTypesWithStandins(
$template_result,
diff --git a/src/Psalm/Type/Atomic/TArrayKey.php b/src/Psalm/Type/Atomic/TArrayKey.php
index 07307cf25f9..b7cef140a6c 100644
--- a/src/Psalm/Type/Atomic/TArrayKey.php
+++ b/src/Psalm/Type/Atomic/TArrayKey.php
@@ -1,5 +1,7 @@
= 7_00_00 ? 'bool' : null;
}
diff --git a/src/Psalm/Type/Atomic/TCallable.php b/src/Psalm/Type/Atomic/TCallable.php
index 7ef847d4ab1..90fb430a291 100644
--- a/src/Psalm/Type/Atomic/TCallable.php
+++ b/src/Psalm/Type/Atomic/TCallable.php
@@ -1,5 +1,7 @@
value = $value;
$this->params = $params;
@@ -49,7 +48,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): string {
return 'callable';
}
@@ -88,7 +87,7 @@ public function replaceTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): self {
$replaced = $this->replaceCallableTemplateTypesWithStandins(
$template_result,
diff --git a/src/Psalm/Type/Atomic/TCallableKeyedArray.php b/src/Psalm/Type/Atomic/TCallableKeyedArray.php
index a4bf95c73f2..d52681c4e6d 100644
--- a/src/Psalm/Type/Atomic/TCallableKeyedArray.php
+++ b/src/Psalm/Type/Atomic/TCallableKeyedArray.php
@@ -1,5 +1,7 @@
= 7_02_00 ? 'object' : null;
}
diff --git a/src/Psalm/Type/Atomic/TCallableString.php b/src/Psalm/Type/Atomic/TCallableString.php
index f9c676f47af..7a157470e43 100644
--- a/src/Psalm/Type/Atomic/TCallableString.php
+++ b/src/Psalm/Type/Atomic/TCallableString.php
@@ -1,5 +1,7 @@
fq_classlike_name === 'static') {
return 'static::' . $this->const_name;
diff --git a/src/Psalm/Type/Atomic/TClassString.php b/src/Psalm/Type/Atomic/TClassString.php
index 723f8f40ca9..f994601666a 100644
--- a/src/Psalm/Type/Atomic/TClassString.php
+++ b/src/Psalm/Type/Atomic/TClassString.php
@@ -1,5 +1,7 @@
as = $as;
$this->as_type = $as_type;
@@ -107,7 +103,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): ?string {
return 'string';
}
@@ -119,7 +115,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
if ($this->as === 'object') {
return 'class-string';
@@ -167,7 +163,7 @@ public function replaceTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): self {
if (!$this->as_type) {
return $this;
diff --git a/src/Psalm/Type/Atomic/TClassStringMap.php b/src/Psalm/Type/Atomic/TClassStringMap.php
index b95e8b6c789..028252540de 100644
--- a/src/Psalm/Type/Atomic/TClassStringMap.php
+++ b/src/Psalm/Type/Atomic/TClassStringMap.php
@@ -1,5 +1,7 @@
param_name = $param_name;
$this->as_type = $as_type;
@@ -67,7 +63,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
if ($use_phpdoc_format) {
return (new TArray([Type::getString(), $this->value_param]))
@@ -100,7 +96,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): string {
return 'array';
}
@@ -129,7 +125,7 @@ public function replaceTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): self {
$cloned = null;
@@ -183,7 +179,7 @@ public function replaceTemplateTypesWithStandins(
*/
public function replaceTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): self {
$value_param = TemplateInferredTypeReplacer::replace(
$this->value_param,
diff --git a/src/Psalm/Type/Atomic/TClosedResource.php b/src/Psalm/Type/Atomic/TClosedResource.php
index 06d419ff13c..3bde7d5508e 100644
--- a/src/Psalm/Type/Atomic/TClosedResource.php
+++ b/src/Psalm/Type/Atomic/TClosedResource.php
@@ -1,5 +1,7 @@
*/
- public $byref_uses = [];
+ public array $byref_uses = [];
/**
* @param list $params
@@ -35,7 +37,7 @@ public function __construct(
?bool $is_pure = null,
array $byref_uses = [],
array $extra_types = [],
- bool $from_docblock = false
+ bool $from_docblock = false,
) {
$this->params = $params;
$this->return_type = $return_type;
@@ -60,7 +62,7 @@ public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool
*/
public function replaceTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): self {
$replaced = $this->replaceCallableTemplateTypesWithArgTypes($template_result, $codebase);
$intersection = $this->replaceIntersectionTemplateTypesWithArgTypes($template_result, $codebase);
@@ -90,7 +92,7 @@ public function replaceTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): self {
$replaced = $this->replaceCallableTemplateTypesWithStandins(
$template_result,
diff --git a/src/Psalm/Type/Atomic/TConditional.php b/src/Psalm/Type/Atomic/TConditional.php
index 9d3bbc9222b..f15ebdf350e 100644
--- a/src/Psalm/Type/Atomic/TConditional.php
+++ b/src/Psalm/Type/Atomic/TConditional.php
@@ -1,5 +1,7 @@
param_name = $param_name;
$this->defining_class = $defining_class;
@@ -67,7 +51,7 @@ public function setTypes(
?Union $as_type,
?Union $conditional_type = null,
?Union $if_type = null,
- ?Union $else_type = null
+ ?Union $else_type = null,
): self {
$as_type ??= $this->as_type;
$conditional_type ??= $this->conditional_type;
@@ -117,7 +101,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): ?string {
return null;
}
@@ -129,7 +113,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
return '';
}
@@ -149,7 +133,7 @@ public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool
*/
public function replaceTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): self {
$conditional = TemplateInferredTypeReplacer::replace(
$this->conditional_type,
diff --git a/src/Psalm/Type/Atomic/TDependentGetClass.php b/src/Psalm/Type/Atomic/TDependentGetClass.php
index 168355daece..ebc492233b0 100644
--- a/src/Psalm/Type/Atomic/TDependentGetClass.php
+++ b/src/Psalm/Type/Atomic/TDependentGetClass.php
@@ -1,5 +1,7 @@
value;
}
@@ -52,7 +51,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
return $this->value . '::' . $this->case_name;
}
diff --git a/src/Psalm/Type/Atomic/TFalse.php b/src/Psalm/Type/Atomic/TFalse.php
index 03d1e27c05f..0bfc243ef44 100644
--- a/src/Psalm/Type/Atomic/TFalse.php
+++ b/src/Psalm/Type/Atomic/TFalse.php
@@ -1,5 +1,7 @@
= 7_00_00 ? 'float' : null;
}
diff --git a/src/Psalm/Type/Atomic/TGenericObject.php b/src/Psalm/Type/Atomic/TGenericObject.php
index 45aa50b8cee..244a3218e40 100644
--- a/src/Psalm/Type/Atomic/TGenericObject.php
+++ b/src/Psalm/Type/Atomic/TGenericObject.php
@@ -1,5 +1,7 @@
toNamespacedString($namespace, $aliased_classes, $this_class, true);
$intersection = strrpos($result, '&');
@@ -143,7 +145,7 @@ public function replaceTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): self {
$types = $this->replaceTypeParamsTemplateTypesWithStandins(
$template_result,
diff --git a/src/Psalm/Type/Atomic/TInt.php b/src/Psalm/Type/Atomic/TInt.php
index 9cfd0de654d..5d503f02ac9 100644
--- a/src/Psalm/Type/Atomic/TInt.php
+++ b/src/Psalm/Type/Atomic/TInt.php
@@ -1,5 +1,7 @@
= 7_00_00 ? 'int' : null;
}
diff --git a/src/Psalm/Type/Atomic/TIntMask.php b/src/Psalm/Type/Atomic/TIntMask.php
index e6e57539022..f19e30ee91d 100644
--- a/src/Psalm/Type/Atomic/TIntMask.php
+++ b/src/Psalm/Type/Atomic/TIntMask.php
@@ -1,5 +1,7 @@
*/
- public $values;
+ public array $values;
/** @param non-empty-array $values */
public function __construct(array $values, bool $from_docblock = false)
@@ -51,7 +53,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
if ($use_phpdoc_format) {
return 'int';
diff --git a/src/Psalm/Type/Atomic/TIntMaskOf.php b/src/Psalm/Type/Atomic/TIntMaskOf.php
index d5a4ae79b62..ace9727db82 100644
--- a/src/Psalm/Type/Atomic/TIntMaskOf.php
+++ b/src/Psalm/Type/Atomic/TIntMaskOf.php
@@ -1,5 +1,7 @@
min_bound = $min_bound;
$this->max_bound = $max_bound;
@@ -56,7 +51,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
return $use_phpdoc_format ?
'int' :
diff --git a/src/Psalm/Type/Atomic/TIterable.php b/src/Psalm/Type/Atomic/TIterable.php
index 6b6c9ea32ab..f8153751a04 100644
--- a/src/Psalm/Type/Atomic/TIterable.php
+++ b/src/Psalm/Type/Atomic/TIterable.php
@@ -1,5 +1,7 @@
$type_params
@@ -94,7 +90,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): ?string {
return $analysis_php_version_id >= 7_01_00 ? 'iterable' : null;
}
@@ -160,7 +156,7 @@ public function replaceTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): self {
$types = $this->replaceTypeParamsTemplateTypesWithStandins(
$template_result,
diff --git a/src/Psalm/Type/Atomic/TKeyOf.php b/src/Psalm/Type/Atomic/TKeyOf.php
index 6928fc8659d..22d9e53d588 100644
--- a/src/Psalm/Type/Atomic/TKeyOf.php
+++ b/src/Psalm/Type/Atomic/TKeyOf.php
@@ -1,5 +1,7 @@
*/
- public $properties;
+ public array $properties;
/**
* @var array|null
*/
- public $class_strings;
+ public ?array $class_strings = null;
/**
* If the shape has fallback params then they are here
*
* @var array{Union, Union}|null
*/
- public $fallback_params;
+ public ?array $fallback_params = null;
/**
* @var bool - if this is a list of sequential elements
*/
- public $is_list = false;
+ public bool $is_list = false;
/** @var non-empty-lowercase-string */
protected const NAME_ARRAY = 'array';
@@ -70,7 +72,7 @@ public function __construct(
?array $class_strings = null,
?array $fallback_params = null,
bool $is_list = false,
- bool $from_docblock = false
+ bool $from_docblock = false,
) {
if ($is_list && $fallback_params) {
$fallback_params[0] = Type::getListKey();
@@ -218,7 +220,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
if ($use_phpdoc_format) {
return $this->getGenericArrayType()->toNamespacedString(
@@ -290,7 +292,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): string {
return 'array';
}
@@ -508,7 +510,7 @@ public function replaceTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): self {
if ($input_type instanceof TKeyedArray
&& $input_type->is_list
@@ -609,7 +611,7 @@ public function replaceTemplateTypesWithStandins(
*/
public function replaceTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): self {
$properties = $this->properties;
foreach ($properties as $offset => $property) {
@@ -684,11 +686,7 @@ public function getAssertionString(): string
return $this->is_list ? 'list' : 'array';
}
- /**
- * @param string|int $name
- * @return string|int
- */
- private function escapeAndQuote($name)
+ private function escapeAndQuote(string|int $name): string|int
{
if (is_string($name)) {
$quote = false;
diff --git a/src/Psalm/Type/Atomic/TLiteralClassString.php b/src/Psalm/Type/Atomic/TLiteralClassString.php
index c5483511c9e..a3e14fa2d12 100644
--- a/src/Psalm/Type/Atomic/TLiteralClassString.php
+++ b/src/Psalm/Type/Atomic/TLiteralClassString.php
@@ -1,5 +1,7 @@
value;
}
diff --git a/src/Psalm/Type/Atomic/TLiteralString.php b/src/Psalm/Type/Atomic/TLiteralString.php
index 6a622887d55..f235fdfb95b 100644
--- a/src/Psalm/Type/Atomic/TLiteralString.php
+++ b/src/Psalm/Type/Atomic/TLiteralString.php
@@ -1,5 +1,7 @@
value . "'";
}
diff --git a/src/Psalm/Type/Atomic/TLowercaseString.php b/src/Psalm/Type/Atomic/TLowercaseString.php
index b65ac5e9dcb..f9eac221716 100644
--- a/src/Psalm/Type/Atomic/TLowercaseString.php
+++ b/src/Psalm/Type/Atomic/TLowercaseString.php
@@ -1,5 +1,7 @@
= 8_00_00 ? 'mixed' : null;
}
diff --git a/src/Psalm/Type/Atomic/TNamedObject.php b/src/Psalm/Type/Atomic/TNamedObject.php
index ee7c5d38ea5..7a0a2e602fe 100644
--- a/src/Psalm/Type/Atomic/TNamedObject.php
+++ b/src/Psalm/Type/Atomic/TNamedObject.php
@@ -1,5 +1,7 @@
value === 'static') {
return 'static';
@@ -178,7 +169,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): ?string {
if ($this->value === 'static') {
return $analysis_php_version_id >= 8_00_00 ? 'static' : null;
@@ -206,7 +197,7 @@ public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool
*/
public function replaceTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): self {
$intersection = $this->replaceIntersectionTemplateTypesWithArgTypes($template_result, $codebase);
if (!$intersection) {
@@ -230,7 +221,7 @@ public function replaceTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): self {
$intersection = $this->replaceIntersectionTemplateTypesWithStandins(
$template_result,
@@ -264,7 +255,7 @@ public static function createFromName(
bool $is_static = false,
bool $definite_class = false,
array $extra_types = [],
- bool $from_docblock = false
+ bool $from_docblock = false,
): TNamedObject {
if ($value === 'Closure') {
return new TClosure($value, null, null, null, [], $extra_types, $from_docblock);
diff --git a/src/Psalm/Type/Atomic/TNever.php b/src/Psalm/Type/Atomic/TNever.php
index 397424b860a..a9918aeb8e2 100644
--- a/src/Psalm/Type/Atomic/TNever.php
+++ b/src/Psalm/Type/Atomic/TNever.php
@@ -1,5 +1,7 @@
count = $count;
$this->min_count = $min_count;
diff --git a/src/Psalm/Type/Atomic/TNonEmptyLowercaseString.php b/src/Psalm/Type/Atomic/TNonEmptyLowercaseString.php
index a72f2a6e811..e9872592e9b 100644
--- a/src/Psalm/Type/Atomic/TNonEmptyLowercaseString.php
+++ b/src/Psalm/Type/Atomic/TNonEmptyLowercaseString.php
@@ -1,5 +1,7 @@
= 7_02_00 ? $this->getKey() : null;
}
diff --git a/src/Psalm/Type/Atomic/TObjectWithProperties.php b/src/Psalm/Type/Atomic/TObjectWithProperties.php
index cae5be7e7f7..1f54c63c8a8 100644
--- a/src/Psalm/Type/Atomic/TObjectWithProperties.php
+++ b/src/Psalm/Type/Atomic/TObjectWithProperties.php
@@ -1,5 +1,7 @@
*/
- public $properties;
+ public array $properties;
/**
* @var array
*/
- public $methods;
+ public array $methods;
- /** @var bool */
- public $is_stringable_object_only = false;
+ public bool $is_stringable_object_only = false;
/**
* Constructs a new instance of a generic type
@@ -48,7 +49,7 @@ public function __construct(
array $properties,
array $methods = [],
array $extra_types = [],
- bool $from_docblock = false
+ bool $from_docblock = false,
) {
$this->properties = $properties;
$this->methods = $methods;
@@ -140,7 +141,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
if ($use_phpdoc_format) {
return 'object';
@@ -178,7 +179,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): string {
return $this->getKey();
}
@@ -228,7 +229,7 @@ public function replaceTemplateTypesWithStandins(
?string $calling_function = null,
bool $replace = true,
bool $add_lower_bound = false,
- int $depth = 0
+ int $depth = 0,
): self {
$properties = [];
@@ -280,7 +281,7 @@ public function replaceTemplateTypesWithStandins(
*/
public function replaceTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): self {
$properties = $this->properties;
foreach ($properties as $offset => $property) {
diff --git a/src/Psalm/Type/Atomic/TPropertiesOf.php b/src/Psalm/Type/Atomic/TPropertiesOf.php
index 49da46df53d..c5c4a92b6fe 100644
--- a/src/Psalm/Type/Atomic/TPropertiesOf.php
+++ b/src/Psalm/Type/Atomic/TPropertiesOf.php
@@ -1,5 +1,7 @@
@@ -45,7 +47,7 @@ public static function tokenNames(): array
public function __construct(
TNamedObject $classlike_type,
?int $visibility_filter,
- bool $from_docblock = false
+ bool $from_docblock = false,
) {
$this->classlike_type = $classlike_type;
$this->visibility_filter = $visibility_filter;
@@ -104,7 +106,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): string {
return $this->getKey();
}
diff --git a/src/Psalm/Type/Atomic/TResource.php b/src/Psalm/Type/Atomic/TResource.php
index 1d99eef800c..b01a0987bde 100644
--- a/src/Psalm/Type/Atomic/TResource.php
+++ b/src/Psalm/Type/Atomic/TResource.php
@@ -1,5 +1,7 @@
= 7_00_00 ? 'string' : null;
}
diff --git a/src/Psalm/Type/Atomic/TTemplateIndexedAccess.php b/src/Psalm/Type/Atomic/TTemplateIndexedAccess.php
index 80c7db23408..bba86e66e29 100644
--- a/src/Psalm/Type/Atomic/TTemplateIndexedAccess.php
+++ b/src/Psalm/Type/Atomic/TTemplateIndexedAccess.php
@@ -1,5 +1,7 @@
array_param_name = $array_param_name;
$this->offset_param_name = $offset_param_name;
@@ -48,7 +41,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): ?string {
return null;
}
diff --git a/src/Psalm/Type/Atomic/TTemplateKeyOf.php b/src/Psalm/Type/Atomic/TTemplateKeyOf.php
index debb1fc8fa1..48c61dff5ec 100644
--- a/src/Psalm/Type/Atomic/TTemplateKeyOf.php
+++ b/src/Psalm/Type/Atomic/TTemplateKeyOf.php
@@ -1,5 +1,7 @@
param_name = $param_name;
$this->defining_class = $defining_class;
@@ -63,7 +56,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
return 'key-of<' . $this->param_name . '>';
}
@@ -75,7 +68,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): ?string {
return null;
}
@@ -90,7 +83,7 @@ public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool
*/
public function replaceTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): self {
$as = TemplateInferredTypeReplacer::replace(
$this->as,
diff --git a/src/Psalm/Type/Atomic/TTemplateParam.php b/src/Psalm/Type/Atomic/TTemplateParam.php
index f1bb94b88be..8a95ab2bdb8 100644
--- a/src/Psalm/Type/Atomic/TTemplateParam.php
+++ b/src/Psalm/Type/Atomic/TTemplateParam.php
@@ -1,5 +1,7 @@
$extra_types
@@ -42,7 +35,7 @@ public function __construct(
Union $extends,
string $defining_class,
array $extra_types = [],
- bool $from_docblock = false
+ bool $from_docblock = false,
) {
$this->param_name = $param_name;
$this->as = $extends;
@@ -103,7 +96,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): ?string {
return null;
}
@@ -115,7 +108,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
if ($use_phpdoc_format) {
return $this->as->toNamespacedString(
@@ -151,7 +144,7 @@ public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool
*/
public function replaceTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): self {
$intersection = $this->replaceIntersectionTemplateTypesWithArgTypes($template_result, $codebase);
if (!$intersection) {
diff --git a/src/Psalm/Type/Atomic/TTemplateParamClass.php b/src/Psalm/Type/Atomic/TTemplateParamClass.php
index ccf40a27c8c..00b370a68b8 100644
--- a/src/Psalm/Type/Atomic/TTemplateParamClass.php
+++ b/src/Psalm/Type/Atomic/TTemplateParamClass.php
@@ -1,5 +1,7 @@
param_name = $param_name;
$this->defining_class = $defining_class;
@@ -61,7 +57,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
return $this->param_name . '::class';
}
diff --git a/src/Psalm/Type/Atomic/TTemplatePropertiesOf.php b/src/Psalm/Type/Atomic/TTemplatePropertiesOf.php
index 9dbc710c147..31f6ef3b3ec 100644
--- a/src/Psalm/Type/Atomic/TTemplatePropertiesOf.php
+++ b/src/Psalm/Type/Atomic/TTemplatePropertiesOf.php
@@ -1,5 +1,7 @@
param_name = $param_name;
$this->defining_class = $defining_class;
@@ -70,7 +63,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): string {
return $this->getKey();
}
@@ -85,7 +78,7 @@ public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool
*/
public function replaceTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): self {
$param = new TTemplateParam(
$this->as->param_name,
diff --git a/src/Psalm/Type/Atomic/TTemplateValueOf.php b/src/Psalm/Type/Atomic/TTemplateValueOf.php
index 6d00b32ea8c..98be9d1e85c 100644
--- a/src/Psalm/Type/Atomic/TTemplateValueOf.php
+++ b/src/Psalm/Type/Atomic/TTemplateValueOf.php
@@ -1,5 +1,7 @@
param_name = $param_name;
$this->defining_class = $defining_class;
@@ -63,7 +56,7 @@ public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- bool $use_phpdoc_format
+ bool $use_phpdoc_format,
): string {
return 'value-of<' . $this->param_name . '>';
}
@@ -75,7 +68,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): ?string {
return null;
}
@@ -90,7 +83,7 @@ public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool
*/
public function replaceTemplateTypesWithArgTypes(
TemplateResult $template_result,
- ?Codebase $codebase
+ ?Codebase $codebase,
): self {
$as = TemplateInferredTypeReplacer::replace(
$this->as,
diff --git a/src/Psalm/Type/Atomic/TTraitString.php b/src/Psalm/Type/Atomic/TTraitString.php
index 07f38880e2a..fbad80e98a0 100644
--- a/src/Psalm/Type/Atomic/TTraitString.php
+++ b/src/Psalm/Type/Atomic/TTraitString.php
@@ -1,5 +1,7 @@
|null $extra_types
@@ -84,7 +84,7 @@ public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
- int $analysis_php_version_id
+ int $analysis_php_version_id,
): ?string {
return null;
}
diff --git a/src/Psalm/Type/Atomic/TUnknownClassString.php b/src/Psalm/Type/Atomic/TUnknownClassString.php
index 765b15e9e93..a8d2811e0cc 100644
--- a/src/Psalm/Type/Atomic/TUnknownClassString.php
+++ b/src/Psalm/Type/Atomic/TUnknownClassString.php
@@ -1,5 +1,7 @@
= 7_01_00 ? $this->getKey() : null;
}
diff --git a/src/Psalm/Type/MutableTypeVisitor.php b/src/Psalm/Type/MutableTypeVisitor.php
index a61f69dad9f..c081f35ccce 100644
--- a/src/Psalm/Type/MutableTypeVisitor.php
+++ b/src/Psalm/Type/MutableTypeVisitor.php
@@ -1,5 +1,7 @@
bar) into a different sort of issue
- *
- * @var bool
*/
- public $from_property = false;
+ public bool $from_property = false;
/**
* Whether the type originated from *static* property
*
* Unlike non-static properties, static properties have no prescribed place
* like __construct() to be initialized in
- *
- * @var bool
*/
- public $from_static_property = false;
+ public bool $from_static_property = false;
/**
* Whether the property that this type has been derived from has been initialized in a constructor
- *
- * @var bool
*/
- public $initialized = true;
+ public bool $initialized = true;
/**
* Which class the type was initialised in
- *
- * @var ?string
*/
- public $initialized_class;
+ public ?string $initialized_class = null;
/**
* Whether or not the type has been checked yet
- *
- * @var bool
*/
- public $checked = false;
+ public bool $checked = false;
- /**
- * @var bool
- */
- public $failed_reconciliation = false;
+ public bool $failed_reconciliation = false;
/**
* Whether or not to ignore issues with possibly-null values
- *
- * @var bool
*/
- public $ignore_nullable_issues = false;
+ public bool $ignore_nullable_issues = false;
/**
* Whether or not to ignore issues with possibly-false values
- *
- * @var bool
*/
- public $ignore_falsable_issues = false;
+ public bool $ignore_falsable_issues = false;
/**
* Whether or not to ignore issues with isset on this type
- *
- * @var bool
*/
- public $ignore_isset = false;
+ public bool $ignore_isset = false;
/**
* Whether or not this variable is possibly undefined
- *
- * @var bool
*/
- public $possibly_undefined = false;
+ public bool $possibly_undefined = false;
/**
* Whether or not this variable is possibly undefined
- *
- * @var bool
*/
- public $possibly_undefined_from_try = false;
+ public bool $possibly_undefined_from_try = false;
/**
* whether this type had never set explicitly
* since it's the bottom type, it's combined into everything else and lost
*
* @psalm-suppress PossiblyUnusedProperty used in setTypes and addType
- * @var bool
*/
- public $explicit_never = false;
+ public bool $explicit_never = false;
/**
* Whether or not this union had a template, since replaced
- *
- * @var bool
*/
- public $had_template = false;
+ public bool $had_template = false;
/**
* Whether or not this union comes from a template "as" default
- *
- * @var bool
*/
- public $from_template_default = false;
+ public bool $from_template_default = false;
/**
* @var array
@@ -178,25 +148,14 @@ final class MutableUnion implements TypeNode
* True if the type was passed or returned by reference, or if the type refers to an object's
* property or an item in an array. Note that this is not true for locally created references
* that don't refer to properties or array items (see Context::$references_in_scope).
- *
- * @var bool
*/
- public $by_ref = false;
+ public bool $by_ref = false;
- /**
- * @var bool
- */
- public $reference_free = false;
+ public bool $reference_free = false;
- /**
- * @var bool
- */
- public $allow_mutations = true;
+ public bool $allow_mutations = true;
- /**
- * @var bool
- */
- public $has_mutations = true;
+ public bool $has_mutations = true;
/**
* This is a cache of getId on non-exact mode
@@ -212,12 +171,9 @@ final class MutableUnion implements TypeNode
/**
* @var array
*/
- public $parent_nodes = [];
+ public array $parent_nodes = [];
- /**
- * @var bool
- */
- public $different = false;
+ public bool $different = false;
/** @psalm-suppress PossiblyUnusedProperty */
public bool $propagate_parent_nodes = false;
@@ -381,10 +337,8 @@ public function bustCache(): void
/**
* @psalm-external-mutation-free
- * @param Union|MutableUnion $old_type
- * @param Union|MutableUnion|null $new_type
*/
- public function substitute($old_type, $new_type = null): self
+ public function substitute(Union|MutableUnion $old_type, Union|MutableUnion|null $new_type = null): self
{
if ($this->hasMixed() && !$this->isEmptyMixed()) {
return $this;
diff --git a/src/Psalm/Type/Reconciler.php b/src/Psalm/Type/Reconciler.php
index f10a66408fe..6cc30cdc79f 100644
--- a/src/Psalm/Type/Reconciler.php
+++ b/src/Psalm/Type/Reconciler.php
@@ -1,5 +1,7 @@
bar) into a different sort of issue
- *
- * @var bool
*/
- public $from_property = false;
+ public bool $from_property = false;
/**
* Whether the type originated from *static* property
*
* Unlike non-static properties, static properties have no prescribed place
* like __construct() to be initialized in
- *
- * @var bool
*/
- public $from_static_property = false;
+ public bool $from_static_property = false;
/**
* Whether the property that this type has been derived from has been initialized in a constructor
- *
- * @var bool
*/
- public $initialized = true;
+ public bool $initialized = true;
/**
* Which class the type was initialised in
- *
- * @var ?string
*/
- public $initialized_class;
+ public ?string $initialized_class = null;
/**
* Whether or not the type has been checked yet
- *
- * @var bool
*/
- public $checked = false;
+ public bool $checked = false;
- /**
- * @var bool
- */
- public $failed_reconciliation = false;
+ public bool $failed_reconciliation = false;
/**
* Whether or not to ignore issues with possibly-null values
- *
- * @var bool
*/
- public $ignore_nullable_issues = false;
+ public bool $ignore_nullable_issues = false;
/**
* Whether or not to ignore issues with possibly-false values
- *
- * @var bool
*/
- public $ignore_falsable_issues = false;
+ public bool $ignore_falsable_issues = false;
/**
* Whether or not to ignore issues with isset on this type
- *
- * @var bool
*/
- public $ignore_isset = false;
+ public bool $ignore_isset = false;
/**
* Whether or not this variable is possibly undefined
- *
- * @var bool
*/
- public $possibly_undefined = false;
+ public bool $possibly_undefined = false;
/**
* Whether or not this variable is possibly undefined
- *
- * @var bool
*/
- public $possibly_undefined_from_try = false;
+ public bool $possibly_undefined_from_try = false;
/**
* whether this type had never set explicitly
* since it's the bottom type, it's combined into everything else and lost
- *
- * @var bool
*/
- public $explicit_never = false;
+ public bool $explicit_never = false;
/**
* Whether or not this union had a template, since replaced
- *
- * @var bool
*/
- public $had_template = false;
+ public bool $had_template = false;
/**
* Whether or not this union comes from a template "as" default
- *
- * @var bool
*/
- public $from_template_default = false;
+ public bool $from_template_default = false;
/**
* @var array
@@ -190,25 +159,14 @@ final class Union implements TypeNode
* True if the type was passed or returned by reference, or if the type refers to an object's
* property or an item in an array. Note that this is not true for locally created references
* that don't refer to properties or array items (see Context::$references_in_scope).
- *
- * @var bool
*/
- public $by_ref = false;
+ public bool $by_ref = false;
- /**
- * @var bool
- */
- public $reference_free = false;
+ public bool $reference_free = false;
- /**
- * @var bool
- */
- public $allow_mutations = true;
+ public bool $allow_mutations = true;
- /**
- * @var bool
- */
- public $has_mutations = true;
+ public bool $has_mutations = true;
/**
* This is a cache of getId on non-exact mode
@@ -224,14 +182,11 @@ final class Union implements TypeNode
/**
* @var array
*/
- public $parent_nodes = [];
+ public array $parent_nodes = [];
public bool $propagate_parent_nodes = false;
- /**
- * @var bool
- */
- public $different = false;
+ public bool $different = false;
/**
* @param TProperties $properties
@@ -315,7 +270,7 @@ public function setPossiblyUndefined(bool $possibly_undefined, ?bool $from_try =
}
/** @return static */
- public function setByRef(bool $by_ref)
+ public function setByRef(bool $by_ref): static
{
if ($by_ref === $this->by_ref) {
return $this;
diff --git a/src/Psalm/Type/UnionTrait.php b/src/Psalm/Type/UnionTrait.php
index 19144ece9df..8ae3600764e 100644
--- a/src/Psalm/Type/UnionTrait.php
+++ b/src/Psalm/Type/UnionTrait.php
@@ -1,5 +1,7 @@
isSingleAndMaybeNullable()) {
if ($analysis_php_version_id < 8_00_00) {
@@ -1210,10 +1212,9 @@ public function isSingleLiteral(): bool
/**
* @psalm-mutation-free
- * @return TLiteralInt|TLiteralString|TLiteralFloat
* @psalm-suppress InvalidFalsableReturnType
*/
- public function getSingleLiteral()
+ public function getSingleLiteral(): TLiteralInt|TLiteralString|TLiteralFloat
{
if (!$this->isSingleLiteral()) {
throw new InvalidArgumentException("Not a single literal");
@@ -1278,7 +1279,7 @@ public function check(
bool $inferred = true,
bool $inherited = false,
bool $prevent_template_covariance = false,
- ?string $calling_method_id = null
+ ?string $calling_method_id = null,
): bool {
if ($this->checked) {
return true;
@@ -1309,7 +1310,7 @@ public function check(
public function queueClassLikesForScanning(
Codebase $codebase,
?FileStorage $file_storage = null,
- array $phantom_classes = []
+ array $phantom_classes = [],
): void {
$scanner_visitor = new TypeScanner(
$codebase->scanner,
@@ -1380,7 +1381,7 @@ public function equals(
self $other_type,
bool $ensure_source_equality = true,
bool $ensure_parent_node_equality = true,
- bool $ensure_possibly_undefined_equality = true
+ bool $ensure_possibly_undefined_equality = true,
): bool {
if ($other_type === $this) {
return true;
diff --git a/tests/AlgebraTest.php b/tests/AlgebraTest.php
index e3ec6254ac6..24d96e9e202 100644
--- a/tests/AlgebraTest.php
+++ b/tests/AlgebraTest.php
@@ -1,5 +1,7 @@
inner->toString();
}
- /**
- * @param mixed $other
- */
- protected function matches($other): bool
+ protected function matches(mixed $other): bool
{
return $this->inner->matches($other);
}
- /**
- * @param mixed $other
- */
- protected function failureDescription($other): string
+ protected function failureDescription(mixed $other): string
{
return $this->exporter()->shortenedExport($other) . ' ' . $this->toString();
}
diff --git a/tests/EndToEnd/DestructiveAutoloaderTest.php b/tests/EndToEnd/DestructiveAutoloaderTest.php
index 400efeec9d6..74a8a59e6de 100644
--- a/tests/EndToEnd/DestructiveAutoloaderTest.php
+++ b/tests/EndToEnd/DestructiveAutoloaderTest.php
@@ -1,5 +1,7 @@
getTestName(), 'SKIPPED-') !== false) {
$this->markTestSkipped();
@@ -84,7 +86,7 @@ public function testPartialAstDiff(
array $same_methods,
array $same_signatures,
array $changed_methods,
- array $diff_map_offsets
+ array $diff_map_offsets,
): void {
if (strpos($this->getTestName(), 'SKIPPED-') !== false) {
$this->markTestSkipped();
diff --git a/tests/FileManipulation/ClassConstantMoveTest.php b/tests/FileManipulation/ClassConstantMoveTest.php
index f06239abb0a..3e22aa14a0b 100644
--- a/tests/FileManipulation/ClassConstantMoveTest.php
+++ b/tests/FileManipulation/ClassConstantMoveTest.php
@@ -1,5 +1,7 @@
getTestName();
if (strpos($test_name, 'SKIPPED-') !== false) {
diff --git a/tests/FileManipulation/ClassMoveTest.php b/tests/FileManipulation/ClassMoveTest.php
index e49e0cf87f8..c2f5c8ee7a5 100644
--- a/tests/FileManipulation/ClassMoveTest.php
+++ b/tests/FileManipulation/ClassMoveTest.php
@@ -1,5 +1,7 @@
getTestName();
if (strpos($test_name, 'SKIPPED-') !== false) {
diff --git a/tests/FileManipulation/FileManipulationTestCase.php b/tests/FileManipulation/FileManipulationTestCase.php
index de361f6ffd2..06941283881 100644
--- a/tests/FileManipulation/FileManipulationTestCase.php
+++ b/tests/FileManipulation/FileManipulationTestCase.php
@@ -1,5 +1,7 @@
getTestName();
if (strpos($test_name, 'SKIPPED-') !== false) {
diff --git a/tests/FileManipulation/ImmutableAnnotationAdditionTest.php b/tests/FileManipulation/ImmutableAnnotationAdditionTest.php
index 926cef22aad..0e3083911c4 100644
--- a/tests/FileManipulation/ImmutableAnnotationAdditionTest.php
+++ b/tests/FileManipulation/ImmutableAnnotationAdditionTest.php
@@ -1,5 +1,7 @@
getTestName();
if (strpos($test_name, 'SKIPPED-') !== false) {
diff --git a/tests/FileManipulation/MissingPropertyTypeTest.php b/tests/FileManipulation/MissingPropertyTypeTest.php
index afeb644ee88..9fe744661f5 100644
--- a/tests/FileManipulation/MissingPropertyTypeTest.php
+++ b/tests/FileManipulation/MissingPropertyTypeTest.php
@@ -1,5 +1,7 @@
getTestName();
if (strpos($test_name, 'SKIPPED-') !== false) {
diff --git a/tests/FileManipulation/ParamNameMismatchTest.php b/tests/FileManipulation/ParamNameMismatchTest.php
index 3dfd82d778a..186885a4309 100644
--- a/tests/FileManipulation/ParamNameMismatchTest.php
+++ b/tests/FileManipulation/ParamNameMismatchTest.php
@@ -1,5 +1,7 @@
getTestName();
if (strpos($test_name, 'SKIPPED-') !== false) {
diff --git a/tests/FileManipulation/PureAnnotationAdditionTest.php b/tests/FileManipulation/PureAnnotationAdditionTest.php
index 3434481ad4f..2b44581a82e 100644
--- a/tests/FileManipulation/PureAnnotationAdditionTest.php
+++ b/tests/FileManipulation/PureAnnotationAdditionTest.php
@@ -1,5 +1,7 @@
getTestName();
if (strpos($test_name, 'SKIPPED-') !== false) {
diff --git a/tests/FileUpdates/AnalyzedMethodTest.php b/tests/FileUpdates/AnalyzedMethodTest.php
index 30e8f29fa12..598efeb6189 100644
--- a/tests/FileUpdates/AnalyzedMethodTest.php
+++ b/tests/FileUpdates/AnalyzedMethodTest.php
@@ -1,5 +1,7 @@
getTestName();
if (strpos($test_name, 'SKIPPED-') !== false) {
diff --git a/tests/FileUpdates/CachedStorageTest.php b/tests/FileUpdates/CachedStorageTest.php
index 3e6b97bff90..a41a33b86bb 100644
--- a/tests/FileUpdates/CachedStorageTest.php
+++ b/tests/FileUpdates/CachedStorageTest.php
@@ -1,5 +1,7 @@
project_analyzer->getCodebase()->diff_methods = true;
$this->project_analyzer->getCodebase()->reportUnusedCode();
diff --git a/tests/FileUpdates/ErrorFixTest.php b/tests/FileUpdates/ErrorFixTest.php
index 7ea00bafe0c..c6e9ffc0132 100644
--- a/tests/FileUpdates/ErrorFixTest.php
+++ b/tests/FileUpdates/ErrorFixTest.php
@@ -1,5 +1,7 @@
project_analyzer->getCodebase()->diff_methods = true;
diff --git a/tests/FileUpdates/TemporaryUpdateTest.php b/tests/FileUpdates/TemporaryUpdateTest.php
index f8e1c0bf0ab..507b483f0c6 100644
--- a/tests/FileUpdates/TemporaryUpdateTest.php
+++ b/tests/FileUpdates/TemporaryUpdateTest.php
@@ -1,5 +1,7 @@
codebase;
$codebase->diff_methods = true;
diff --git a/tests/ForbiddenCodeTest.php b/tests/ForbiddenCodeTest.php
index 86b36f5279e..0a1911b1665 100644
--- a/tests/ForbiddenCodeTest.php
+++ b/tests/ForbiddenCodeTest.php
@@ -1,5 +1,7 @@
project_analyzer->getCodebase();
@@ -64,7 +66,7 @@ public function testInvalidInclude(
array $files,
array $files_to_check,
string $error_message,
- array $directories = []
+ array $directories = [],
): void {
if (strpos($this->getTestName(), 'SKIPPED-') !== false) {
$this->markTestSkipped();
diff --git a/tests/IntRangeTest.php b/tests/IntRangeTest.php
index c7c09ae2d92..852710db8f5 100644
--- a/tests/IntRangeTest.php
+++ b/tests/IntRangeTest.php
@@ -1,5 +1,7 @@
addFile('somefile.php', $code);
$this->analyzeFile('somefile.php', new Context());
diff --git a/tests/LanguageServer/CompletionTest.php b/tests/LanguageServer/CompletionTest.php
index 942556f56cd..7e6cb52bdae 100644
--- a/tests/LanguageServer/CompletionTest.php
+++ b/tests/LanguageServer/CompletionTest.php
@@ -1,5 +1,7 @@
configureClientRoot($client_root_provided_later);
@@ -53,7 +55,7 @@ public function testMapsServerToClient(
?string $client_root_preconfigured,
string $client_root_provided_later,
string $client_path,
- string $server_path
+ string $server_path,
): void {
$mapper = new PathMapper($server_root, $client_root_preconfigured);
$mapper->configureClientRoot($client_root_provided_later);
diff --git a/tests/LanguageServer/SymbolLookupTest.php b/tests/LanguageServer/SymbolLookupTest.php
index d235bc33442..a0a36cb5dd2 100644
--- a/tests/LanguageServer/SymbolLookupTest.php
+++ b/tests/LanguageServer/SymbolLookupTest.php
@@ -1,5 +1,7 @@
codebase->config;
$config->throw_exception = false;
diff --git a/tests/ListTest.php b/tests/ListTest.php
index 5dce65e5491..c36c4bac7df 100644
--- a/tests/ListTest.php
+++ b/tests/ListTest.php
@@ -1,5 +1,7 @@
';
}
- /**
- * @return false
- */
- public function getComposerFilePathForClassLike(string $fq_classlike_name): bool
+ public function getComposerFilePathForClassLike(string $fq_classlike_name): string|false
{
return false;
}
diff --git a/tests/TestEnvironmentTest.php b/tests/TestEnvironmentTest.php
index 5a123791289..7b6a1b587b1 100644
--- a/tests/TestEnvironmentTest.php
+++ b/tests/TestEnvironmentTest.php
@@ -1,5 +1,7 @@
getTestName();
if (strpos($test_name, 'PHP80-') !== false) {
diff --git a/tests/Traits/ValidCodeAnalysisTestTrait.php b/tests/Traits/ValidCodeAnalysisTestTrait.php
index b37acced357..e8b7ffce80e 100644
--- a/tests/Traits/ValidCodeAnalysisTestTrait.php
+++ b/tests/Traits/ValidCodeAnalysisTestTrait.php
@@ -1,5 +1,7 @@
getTestName();
if (strpos($test_name, 'PHP80-') !== false) {
diff --git a/tests/TryCatchTest.php b/tests/TryCatchTest.php
index c83e2b0911e..87a714e2359 100644
--- a/tests/TryCatchTest.php
+++ b/tests/TryCatchTest.php
@@ -1,5 +1,7 @@
project_analyzer->getCodebase()->queueClassLikeForScanning(Countable::class);
$this->project_analyzer->getCodebase()->scanFiles();
}
diff --git a/tests/TypeReconciliation/RedundantConditionTest.php b/tests/TypeReconciliation/RedundantConditionTest.php
index 88142c7187e..b6e01460cc9 100644
--- a/tests/TypeReconciliation/RedundantConditionTest.php
+++ b/tests/TypeReconciliation/RedundantConditionTest.php
@@ -1,5 +1,7 @@