diff --git a/UPGRADING.md b/UPGRADING.md
index 62cbdfc964c..55cb4f65119 100644
--- a/UPGRADING.md
+++ b/UPGRADING.md
@@ -34,7 +34,7 @@
- [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 and return typehints are now strictly typed.
+- [BC] All parameters, properties and return typehints are now strictly typed.
- [BC] `strict_types` is now applied to all files of the Psalm codebase.
diff --git a/phpcs.xml b/phpcs.xml
index 527c444042d..1a6858b03cb 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -249,10 +249,6 @@
-
- bin/*
- src/Psalm/Internal/*
- tests/*
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 3c8161aabe4..d04ba234885 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -251,6 +251,16 @@
$stub
+
+
+ methods[$declaring_method_name]->stubbed]]>
+
+
+
+
+ methods[$implementing_method_id->method_name]->abstract]]>
+
+
$property_name
diff --git a/src/Psalm/Aliases.php b/src/Psalm/Aliases.php
index 5ec3f3fb3e7..daa39b90a30 100644
--- a/src/Psalm/Aliases.php
+++ b/src/Psalm/Aliases.php
@@ -9,44 +9,40 @@ final class Aliases
/**
* @var array
*/
- 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
diff --git a/src/Psalm/CodeLocation.php b/src/Psalm/CodeLocation.php
index 063a6f498f8..9c35acfb340 100644
--- a/src/Psalm/CodeLocation.php
+++ b/src/Psalm/CodeLocation.php
@@ -35,34 +35,25 @@ class CodeLocation
{
use ImmutableNonCloneableTrait;
- /** @var string */
- public $file_path;
+ public string $file_path;
- /** @var string */
- public $file_name;
+ public string $file_name;
- /** @var int */
- public $raw_line_number;
+ public int $raw_line_number;
private int $end_line_number = -1;
- /** @var int */
- public $raw_file_start;
+ public int $raw_file_start;
- /** @var int */
- public $raw_file_end;
+ public int $raw_file_end;
- /** @var int */
- protected $file_start;
+ protected int $file_start;
- /** @var int */
- protected $file_end;
+ protected int $file_end;
- /** @var bool */
- protected $single_line;
+ protected bool $single_line;
- /** @var int */
- protected $preview_start;
+ protected int $preview_start;
private int $preview_end = -1;
@@ -78,20 +69,17 @@ class CodeLocation
private ?string $text = null;
- /** @var int|null */
- public $docblock_start;
+ public ?int $docblock_start = null;
private ?int $docblock_start_line_number = null;
- /** @var int|null */
- protected $docblock_line_number;
+ protected ?int $docblock_line_number = null;
private ?int $regex_type = null;
private bool $have_recalculated = false;
- /** @var null|CodeLocation */
- public $previous_location;
+ public ?CodeLocation $previous_location = null;
public const VAR_TYPE = 0;
public const FUNCTION_RETURN_TYPE = 1;
diff --git a/src/Psalm/Codebase.php b/src/Psalm/Codebase.php
index ca852b76435..1e2e47498b7 100644
--- a/src/Psalm/Codebase.php
+++ b/src/Psalm/Codebase.php
@@ -100,10 +100,7 @@
final class Codebase
{
- /**
- * @var Config
- */
- public $config;
+ public Config $config;
/**
* A map of fully-qualified use declarations to the files
@@ -111,211 +108,138 @@ final class Codebase
*
* @var array>
*/
- 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(
diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php
index d977722fd21..d86d787c73b 100644
--- a/src/Psalm/Config.php
+++ b/src/Psalm/Config.php
@@ -138,7 +138,7 @@ class Config
/**
* @var array
*/
- public static $ERROR_LEVELS = [
+ public static array $ERROR_LEVELS = [
self::REPORT_INFO,
self::REPORT_ERROR,
self::REPORT_SUPPRESS,
@@ -172,7 +172,7 @@ class Config
*
* @var array
*/
- protected $universal_object_crates;
+ protected array $universal_object_crates;
/**
* @var static|null
@@ -181,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
@@ -300,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 = [];
@@ -533,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.
@@ -608,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,
@@ -635,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',
@@ -700,7 +555,7 @@ class Config
*
* @var array
*/
- public $php_extensions_not_supported = [];
+ public array $php_extensions_not_supported = [];
/**
* @var array
diff --git a/src/Psalm/Config/FileFilter.php b/src/Psalm/Config/FileFilter.php
index b0410026369..4eb8c1a32f2 100644
--- a/src/Psalm/Config/FileFilter.php
+++ b/src/Psalm/Config/FileFilter.php
@@ -48,62 +48,59 @@ class FileFilter
/**
* @var array
*/
- 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)
{
diff --git a/src/Psalm/Context.php b/src/Psalm/Context.php
index 23824f67fae..084e0650b31 100644
--- a/src/Psalm/Context.php
+++ b/src/Psalm/Context.php
@@ -40,19 +40,19 @@ final class Context
/**
* @var array
*/
- 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.
@@ -65,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
@@ -88,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?
@@ -335,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)
diff --git a/src/Psalm/Exception/UnresolvableConstantException.php b/src/Psalm/Exception/UnresolvableConstantException.php
index 94029bd012a..175fe7b033e 100644
--- a/src/Psalm/Exception/UnresolvableConstantException.php
+++ b/src/Psalm/Exception/UnresolvableConstantException.php
@@ -8,15 +8,9 @@
final class UnresolvableConstantException extends Exception
{
- /**
- * @var string
- */
- public $class_name;
+ public string $class_name;
- /**
- * @var string
- */
- public $const_name;
+ public string $const_name;
public function __construct(string $class_name, string $const_name)
{
diff --git a/src/Psalm/FileManipulation.php b/src/Psalm/FileManipulation.php
index 35b8c808c26..56acda2c230 100644
--- a/src/Psalm/FileManipulation.php
+++ b/src/Psalm/FileManipulation.php
@@ -12,20 +12,15 @@
final class FileManipulation
{
- /** @var int */
- public $start;
+ public int $start;
- /** @var int */
- public $end;
+ public int $end;
- /** @var string */
- public $insertion_text;
+ public string $insertion_text;
- /** @var bool */
- public $preserve_indentation;
+ public bool $preserve_indentation;
- /** @var bool */
- public $remove_trailing_newline;
+ public bool $remove_trailing_newline;
public function __construct(
int $start,
diff --git a/src/Psalm/Issue/ArgumentIssue.php b/src/Psalm/Issue/ArgumentIssue.php
index 79fdf8b8309..7ebedbab8ad 100644
--- a/src/Psalm/Issue/ArgumentIssue.php
+++ b/src/Psalm/Issue/ArgumentIssue.php
@@ -10,10 +10,7 @@
abstract class ArgumentIssue extends CodeIssue
{
- /**
- * @var ?string
- */
- public $function_id;
+ public ?string $function_id = null;
public function __construct(
string $message,
diff --git a/src/Psalm/Issue/ClassConstantIssue.php b/src/Psalm/Issue/ClassConstantIssue.php
index d47b40a1930..cb6dac913cd 100644
--- a/src/Psalm/Issue/ClassConstantIssue.php
+++ b/src/Psalm/Issue/ClassConstantIssue.php
@@ -8,10 +8,7 @@
abstract class ClassConstantIssue extends CodeIssue
{
- /**
- * @var string
- */
- public $const_id;
+ public string $const_id;
public function __construct(
string $message,
diff --git a/src/Psalm/Issue/ClassIssue.php b/src/Psalm/Issue/ClassIssue.php
index 9e3f1476615..959f625cf42 100644
--- a/src/Psalm/Issue/ClassIssue.php
+++ b/src/Psalm/Issue/ClassIssue.php
@@ -8,10 +8,7 @@
abstract class ClassIssue extends CodeIssue
{
- /**
- * @var string
- */
- public $fq_classlike_name;
+ public string $fq_classlike_name;
public function __construct(
string $message,
diff --git a/src/Psalm/Issue/CodeIssue.php b/src/Psalm/Issue/CodeIssue.php
index d82c9978def..e4b7791caa1 100644
--- a/src/Psalm/Issue/CodeIssue.php
+++ b/src/Psalm/Issue/CodeIssue.php
@@ -18,21 +18,16 @@ abstract class CodeIssue
public const SHORTCODE = 0;
/**
- * @var CodeLocation
* @readonly
*/
- public $code_location;
+ public CodeLocation $code_location;
/**
- * @var string
* @readonly
*/
- public $message;
+ public string $message;
- /**
- * @var ?string
- */
- public $dupe_key;
+ public ?string $dupe_key = null;
public function __construct(
string $message,
diff --git a/src/Psalm/Issue/FunctionIssue.php b/src/Psalm/Issue/FunctionIssue.php
index 8ea22b53ead..9d3b5ee05d8 100644
--- a/src/Psalm/Issue/FunctionIssue.php
+++ b/src/Psalm/Issue/FunctionIssue.php
@@ -10,10 +10,7 @@
abstract class FunctionIssue extends CodeIssue
{
- /**
- * @var string
- */
- public $function_id;
+ public string $function_id;
public function __construct(
string $message,
diff --git a/src/Psalm/Issue/MethodIssue.php b/src/Psalm/Issue/MethodIssue.php
index ad3b84f5e2b..2d4cd8c5c15 100644
--- a/src/Psalm/Issue/MethodIssue.php
+++ b/src/Psalm/Issue/MethodIssue.php
@@ -10,10 +10,7 @@
abstract class MethodIssue extends CodeIssue
{
- /**
- * @var string
- */
- public $method_id;
+ public string $method_id;
public function __construct(
string $message,
diff --git a/src/Psalm/Issue/MixedIssueTrait.php b/src/Psalm/Issue/MixedIssueTrait.php
index 3cd5079fcf8..10dda63d98a 100644
--- a/src/Psalm/Issue/MixedIssueTrait.php
+++ b/src/Psalm/Issue/MixedIssueTrait.php
@@ -9,10 +9,9 @@
trait MixedIssueTrait
{
/**
- * @var ?CodeLocation
* @readonly
*/
- public $origin_location;
+ public ?CodeLocation $origin_location = null;
public function __construct(
string $message,
diff --git a/src/Psalm/Issue/PropertyIssue.php b/src/Psalm/Issue/PropertyIssue.php
index 4cf1d4cf883..6be211689e7 100644
--- a/src/Psalm/Issue/PropertyIssue.php
+++ b/src/Psalm/Issue/PropertyIssue.php
@@ -8,10 +8,7 @@
abstract class PropertyIssue extends CodeIssue
{
- /**
- * @var string
- */
- public $property_id;
+ public string $property_id;
public function __construct(
string $message,
diff --git a/src/Psalm/Issue/TaintedInput.php b/src/Psalm/Issue/TaintedInput.php
index 8c1f9137cbd..f394c24ac95 100644
--- a/src/Psalm/Issue/TaintedInput.php
+++ b/src/Psalm/Issue/TaintedInput.php
@@ -14,16 +14,15 @@ abstract class TaintedInput extends CodeIssue
public const SHORTCODE = 205;
/**
- * @var string
* @readonly
*/
- public $journey_text;
+ public string $journey_text;
/**
* @var list
* @readonly
*/
- public $journey = [];
+ public array $journey = [];
/**
* @param list $journey
diff --git a/src/Psalm/Issue/VariableIssue.php b/src/Psalm/Issue/VariableIssue.php
index 36a64df0f44..a24644f7f20 100644
--- a/src/Psalm/Issue/VariableIssue.php
+++ b/src/Psalm/Issue/VariableIssue.php
@@ -10,10 +10,7 @@
abstract class VariableIssue extends CodeIssue
{
- /**
- * @var string
- */
- public $var_name;
+ public string $var_name;
public function __construct(
string $message,
diff --git a/src/Psalm/IssueBuffer.php b/src/Psalm/IssueBuffer.php
index 21514018e6d..fc04545fbea 100644
--- a/src/Psalm/IssueBuffer.php
+++ b/src/Psalm/IssueBuffer.php
@@ -87,43 +87,39 @@ final class IssueBuffer
/**
* @var array>
*/
- 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 = [];
diff --git a/src/Psalm/Plugin/EventHandler/Event/AfterMethodCallAnalysisEvent.php b/src/Psalm/Plugin/EventHandler/Event/AfterMethodCallAnalysisEvent.php
index 25a77e0b486..829f0dc15bc 100644
--- a/src/Psalm/Plugin/EventHandler/Event/AfterMethodCallAnalysisEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/AfterMethodCallAnalysisEvent.php
@@ -15,10 +15,7 @@
final class AfterMethodCallAnalysisEvent
{
- /**
- * @var MethodCall|StaticCall
- */
- private $expr;
+ private MethodCall|StaticCall $expr;
private string $method_id;
private string $appearing_method_id;
private string $declaring_method_id;
diff --git a/src/Psalm/Plugin/EventHandler/Event/MethodReturnTypeProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/MethodReturnTypeProviderEvent.php
index f2089fa5356..e6a96aba9b3 100644
--- a/src/Psalm/Plugin/EventHandler/Event/MethodReturnTypeProviderEvent.php
+++ b/src/Psalm/Plugin/EventHandler/Event/MethodReturnTypeProviderEvent.php
@@ -20,10 +20,7 @@ final class MethodReturnTypeProviderEvent
private string $method_name_lowercase;
private Context $context;
private CodeLocation $code_location;
- /**
- * @var PhpParser\Node\Expr\MethodCall|PhpParser\Node\Expr\StaticCall
- */
- private $stmt;
+ private PhpParser\Node\Expr\MethodCall|PhpParser\Node\Expr\StaticCall $stmt;
/** @var non-empty-list|null */
private ?array $template_type_parameters;
private ?string $called_fq_classlike_name;
diff --git a/src/Psalm/Progress/LongProgress.php b/src/Psalm/Progress/LongProgress.php
index 79f43ddb50c..8cf23fa1fc6 100644
--- a/src/Psalm/Progress/LongProgress.php
+++ b/src/Psalm/Progress/LongProgress.php
@@ -17,17 +17,13 @@ class LongProgress extends Progress
{
public const NUMBER_OF_COLUMNS = 60;
- /** @var int|null */
- protected $number_of_tasks;
+ protected ?int $number_of_tasks = null;
- /** @var int */
- protected $progress = 0;
+ protected int $progress = 0;
- /** @var bool */
- protected $print_errors = false;
+ protected bool $print_errors = false;
- /** @var bool */
- protected $print_infos = false;
+ protected bool $print_infos = false;
public function __construct(bool $print_errors = true, bool $print_infos = true)
{
diff --git a/src/Psalm/Report.php b/src/Psalm/Report.php
index a606d718de1..c2a86945672 100644
--- a/src/Psalm/Report.php
+++ b/src/Psalm/Report.php
@@ -36,31 +36,24 @@ abstract class Report
/**
* @var array
*/
- 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
diff --git a/src/Psalm/Report/ReportOptions.php b/src/Psalm/Report/ReportOptions.php
index 67668449ba3..38b9b190f7e 100644
--- a/src/Psalm/Report/ReportOptions.php
+++ b/src/Psalm/Report/ReportOptions.php
@@ -8,41 +8,22 @@
final class ReportOptions
{
- /**
- * @var bool
- */
- public $use_color = true;
+ public bool $use_color = true;
- /**
- * @var bool
- */
- public $show_snippet = true;
+ public bool $show_snippet = true;
- /**
- * @var bool
- */
- public $show_info = true;
+ public bool $show_info = true;
/**
* @var Report::TYPE_*
*/
public $format = Report::TYPE_CONSOLE;
- /**
- * @var bool
- */
- public $pretty = false;
+ public bool $pretty = false;
- /**
- * @var ?string
- */
- public $output_path;
+ public ?string $output_path = null;
- /**
- * @var bool
- */
- public $show_suggestions = true;
+ public bool $show_suggestions = true;
- /** @var bool */
- public $in_ci = false;
+ public bool $in_ci = false;
}
diff --git a/src/Psalm/SourceControl/Git/CommitInfo.php b/src/Psalm/SourceControl/Git/CommitInfo.php
index 464d1b26b72..d10bbb41c0b 100644
--- a/src/Psalm/SourceControl/Git/CommitInfo.php
+++ b/src/Psalm/SourceControl/Git/CommitInfo.php
@@ -13,52 +13,38 @@ final class CommitInfo
{
/**
* Commit ID.
- *
- * @var null|string
*/
- protected $id;
+ protected ?string $id = null;
/**
* Author name.
- *
- * @var null|string
*/
- protected $author_name;
+ protected ?string $author_name = null;
/**
* Author email.
- *
- * @var null|string
*/
- protected $author_email;
+ protected ?string $author_email = null;
/**
* Committer name.
- *
- * @var null|string
*/
- protected $committer_name;
+ protected ?string $committer_name = null;
/**
* Committer email.
- *
- * @var null|string
*/
- protected $committer_email;
+ protected ?string $committer_email = null;
/**
* Commit message.
- *
- * @var null|string
*/
- protected $message;
+ protected ?string $message = null;
/**
* Commit message.
- *
- * @var null|int
*/
- protected $date;
+ protected ?int $date = null;
public function toArray(): array
{
diff --git a/src/Psalm/SourceControl/Git/GitInfo.php b/src/Psalm/SourceControl/Git/GitInfo.php
index 77c7d6ae73c..dd7927255fa 100644
--- a/src/Psalm/SourceControl/Git/GitInfo.php
+++ b/src/Psalm/SourceControl/Git/GitInfo.php
@@ -33,24 +33,20 @@ final class GitInfo extends SourceControlInfo
{
/**
* Branch name.
- *
- * @var string
*/
- protected $branch;
+ protected string $branch;
/**
* Head.
- *
- * @var CommitInfo
*/
- protected $head;
+ protected CommitInfo $head;
/**
* Remote.
*
* @var RemoteInfo[]
*/
- protected $remotes;
+ protected array $remotes;
/**
* Constructor.
diff --git a/src/Psalm/SourceControl/Git/RemoteInfo.php b/src/Psalm/SourceControl/Git/RemoteInfo.php
index d747b311004..91bf9a9b44a 100644
--- a/src/Psalm/SourceControl/Git/RemoteInfo.php
+++ b/src/Psalm/SourceControl/Git/RemoteInfo.php
@@ -13,17 +13,13 @@ final class RemoteInfo
{
/**
* Remote name.
- *
- * @var null|string
*/
- protected $name;
+ protected ?string $name = null;
/**
* Remote URL.
- *
- * @var null|string
*/
- protected $url;
+ protected ?string $url = null;
public function toArray(): array
{
diff --git a/src/Psalm/Storage/Assertion/DoesNotHaveAtLeastCount.php b/src/Psalm/Storage/Assertion/DoesNotHaveAtLeastCount.php
index e49d4865d60..83076312120 100644
--- a/src/Psalm/Storage/Assertion/DoesNotHaveAtLeastCount.php
+++ b/src/Psalm/Storage/Assertion/DoesNotHaveAtLeastCount.php
@@ -12,7 +12,7 @@
final class DoesNotHaveAtLeastCount extends Assertion
{
/** @var positive-int */
- public $count;
+ public int $count;
/** @param positive-int $count */
public function __construct(int $count)
diff --git a/src/Psalm/Storage/Assertion/DoesNotHaveExactCount.php b/src/Psalm/Storage/Assertion/DoesNotHaveExactCount.php
index 632b6a11d07..cc96639ddf0 100644
--- a/src/Psalm/Storage/Assertion/DoesNotHaveExactCount.php
+++ b/src/Psalm/Storage/Assertion/DoesNotHaveExactCount.php
@@ -12,7 +12,7 @@
final class DoesNotHaveExactCount extends Assertion
{
/** @var positive-int */
- public $count;
+ public int $count;
/** @param positive-int $count */
public function __construct(int $count)
diff --git a/src/Psalm/Storage/Assertion/HasAtLeastCount.php b/src/Psalm/Storage/Assertion/HasAtLeastCount.php
index d15be0219f3..0c2555b9994 100644
--- a/src/Psalm/Storage/Assertion/HasAtLeastCount.php
+++ b/src/Psalm/Storage/Assertion/HasAtLeastCount.php
@@ -12,7 +12,7 @@
final class HasAtLeastCount extends Assertion
{
/** @var positive-int */
- public $count;
+ public int $count;
/** @param positive-int $count */
public function __construct(int $count)
diff --git a/src/Psalm/Storage/Assertion/HasExactCount.php b/src/Psalm/Storage/Assertion/HasExactCount.php
index 3f45ede8db7..8f468b1eda4 100644
--- a/src/Psalm/Storage/Assertion/HasExactCount.php
+++ b/src/Psalm/Storage/Assertion/HasExactCount.php
@@ -12,7 +12,7 @@
final class HasExactCount extends Assertion
{
/** @var positive-int */
- public $count;
+ public int $count;
/** @param positive-int $count */
public function __construct(int $count)
diff --git a/src/Psalm/Storage/AttributeArg.php b/src/Psalm/Storage/AttributeArg.php
index 2d7c98265d9..72fd6080222 100644
--- a/src/Psalm/Storage/AttributeArg.php
+++ b/src/Psalm/Storage/AttributeArg.php
@@ -15,21 +15,16 @@ final class AttributeArg
{
use ImmutableNonCloneableTrait;
/**
- * @var ?string
* @psalm-suppress PossiblyUnusedProperty It's part of the public API for now
*/
- public $name;
+ public ?string $name = null;
- /**
- * @var Union|UnresolvedConstantComponent
- */
- public $type;
+ public Union|UnresolvedConstantComponent $type;
/**
- * @var CodeLocation
* @psalm-suppress PossiblyUnusedProperty It's part of the public API for now
*/
- public $location;
+ public CodeLocation $location;
public function __construct(
?string $name,
diff --git a/src/Psalm/Storage/AttributeStorage.php b/src/Psalm/Storage/AttributeStorage.php
index 3ecab7899ac..8cbc499a637 100644
--- a/src/Psalm/Storage/AttributeStorage.php
+++ b/src/Psalm/Storage/AttributeStorage.php
@@ -12,27 +12,22 @@
final class AttributeStorage
{
use ImmutableNonCloneableTrait;
- /**
- * @var string
- */
- public $fq_class_name;
+ public string $fq_class_name;
/**
* @var list
*/
- 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
diff --git a/src/Psalm/Storage/ClassLikeStorage.php b/src/Psalm/Storage/ClassLikeStorage.php
index 5d622b16f7e..8fabc2e3edd 100644
--- a/src/Psalm/Storage/ClassLikeStorage.php
+++ b/src/Psalm/Storage/ClassLikeStorage.php
@@ -25,168 +25,117 @@ final class ClassLikeStorage implements HasAttributesInterface
/**
* @var array
*/
- 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
@@ -196,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
@@ -256,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
@@ -275,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.
@@ -343,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.
@@ -358,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.
@@ -374,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;
diff --git a/src/Psalm/Storage/CustomMetadataTrait.php b/src/Psalm/Storage/CustomMetadataTrait.php
index cbb80570429..e2679ee01c9 100644
--- a/src/Psalm/Storage/CustomMetadataTrait.php
+++ b/src/Psalm/Storage/CustomMetadataTrait.php
@@ -10,5 +10,5 @@
trait CustomMetadataTrait
{
/** @var array */
- public $custom_metadata = [];
+ public array $custom_metadata = [];
}
diff --git a/src/Psalm/Storage/EnumCaseStorage.php b/src/Psalm/Storage/EnumCaseStorage.php
index 7b99d1a6320..12cf8b1098e 100644
--- a/src/Psalm/Storage/EnumCaseStorage.php
+++ b/src/Psalm/Storage/EnumCaseStorage.php
@@ -10,18 +10,11 @@
final class EnumCaseStorage
{
- /**
- * @var TLiteralString|TLiteralInt|null
- */
- public $value;
+ public TLiteralString|TLiteralInt|null $value = null;
- /** @var CodeLocation */
- public $stmt_location;
+ public CodeLocation $stmt_location;
- /**
- * @var bool
- */
- public $deprecated = false;
+ public bool $deprecated = false;
public function __construct(
TLiteralString|TLiteralInt|null $value,
diff --git a/src/Psalm/Storage/FileStorage.php b/src/Psalm/Storage/FileStorage.php
index 1c505d2fc2c..ce309152bba 100644
--- a/src/Psalm/Storage/FileStorage.php
+++ b/src/Psalm/Storage/FileStorage.php
@@ -16,87 +16,76 @@ final class FileStorage
/**
* @var array
*/
- 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 03e88c50ca3..cdeaee2d3eb 100644
--- a/src/Psalm/Storage/FunctionLikeParameter.php
+++ b/src/Psalm/Storage/FunctionLikeParameter.php
@@ -15,105 +15,51 @@ final class FunctionLikeParameter implements HasAttributesInterface, TypeNode
{
use CustomMetadataTrait;
- /**
- * @var string
- */
- public $name;
+ public string $name;
- /**
- * @var bool
- */
- public $by_ref;
+ public bool $by_ref;
- /**
- * @var Union|null
- */
- public $type;
+ public ?Union $type = null;
- /**
- * @var Union|null
- */
- public $out_type;
+ public ?Union $out_type = null;
- /**
- * @var Union|null
- */
- public $signature_type;
+ public ?Union $signature_type = null;
- /**
- * @var bool
- */
- public $has_docblock_type = false;
+ public bool $has_docblock_type = false;
- /**
- * @var bool
- */
- public $is_optional;
+ public bool $is_optional;
- /**
- * @var bool
- */
- public $is_nullable;
+ public bool $is_nullable;
- /**
- * @var Union|UnresolvedConstantComponent|null
- */
- public $default_type;
+ public Union|UnresolvedConstantComponent|null $default_type = null;
- /**
- * @var CodeLocation|null
- */
- public $location;
+ public ?CodeLocation $location = null;
- /**
- * @var CodeLocation|null
- */
- public $type_location;
+ public ?CodeLocation $type_location = null;
- /**
- * @var CodeLocation|null
- */
- public $signature_type_location;
+ public ?CodeLocation $signature_type_location = null;
- /**
- * @var bool
- */
- public $is_variadic;
+ public bool $is_variadic;
/**
* @var array|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
diff --git a/src/Psalm/Storage/FunctionLikeStorage.php b/src/Psalm/Storage/FunctionLikeStorage.php
index 8cd00d73cce..ef13057d9dc 100644
--- a/src/Psalm/Storage/FunctionLikeStorage.php
+++ b/src/Psalm/Storage/FunctionLikeStorage.php
@@ -19,97 +19,64 @@ abstract class FunctionLikeStorage implements HasAttributesInterface
{
use CustomMetadataTrait;
- /**
- * @var CodeLocation|null
- */
- public $location;
+ public ?CodeLocation $location = null;
- /**
- * @var CodeLocation|null
- */
- public $stmt_location;
+ public ?CodeLocation $stmt_location = null;
/**
* @psalm-readonly-allow-private-mutation
* @var list
*/
- 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.
@@ -122,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
@@ -181,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 b9adb7beeeb..f9c9dcfeeb2 100644
--- a/src/Psalm/Storage/FunctionStorage.php
+++ b/src/Psalm/Storage/FunctionStorage.php
@@ -7,5 +7,5 @@
final class FunctionStorage extends FunctionLikeStorage
{
/** @var array */
- public $byref_uses = [];
+ public array $byref_uses = [];
}
diff --git a/src/Psalm/Storage/MethodStorage.php b/src/Psalm/Storage/MethodStorage.php
index dcde8d9a083..c6ebc2d8aab 100644
--- a/src/Psalm/Storage/MethodStorage.php
+++ b/src/Psalm/Storage/MethodStorage.php
@@ -8,102 +8,45 @@
final class MethodStorage extends FunctionLikeStorage
{
- /**
- * @var bool
- */
- public $is_static = false;
+ public bool $is_static = false;
- /**
- * @var int
- */
- public $visibility = 0;
+ public int $visibility = 0;
- /**
- * @var bool
- */
- public $final = false;
+ public bool $final = false;
- /**
- * @var bool
- */
- public $final_from_docblock = false;
+ public bool $final_from_docblock = false;
- /**
- * @var bool
- */
- public $abstract = false;
+ public bool $abstract = false;
- /**
- * @var bool
- */
- public $overridden_downstream = false;
+ public bool $overridden_downstream = false;
- /**
- * @var bool
- */
- public $overridden_somewhere = false;
+ public bool $overridden_somewhere = false;
- /**
- * @var bool
- */
- public $inheritdoc = false;
+ public bool $inheritdoc = false;
- /**
- * @var ?bool
- */
- public $inherited_return_type = false;
+ public ?bool $inherited_return_type = false;
- /**
- * @var ?string
- */
- public $defining_fqcln;
+ public ?string $defining_fqcln = null;
- /**
- * @var bool
- */
- public $has_docblock_param_types = false;
+ public bool $has_docblock_param_types = false;
- /**
- * @var bool
- */
- public $has_docblock_return_type = false;
+ public bool $has_docblock_return_type = false;
- /**
- * @var bool
- */
- public $external_mutation_free = false;
+ public bool $external_mutation_free = false;
- /**
- * @var bool
- */
- public $immutable = false;
+ public bool $immutable = false;
- /**
- * @var bool
- */
- public $mutation_free_inferred = false;
+ public bool $mutation_free_inferred = false;
/**
* @var ?array
*/
- 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 4eca32da64f..62959661725 100644
--- a/src/Psalm/Storage/Possibilities.php
+++ b/src/Psalm/Storage/Possibilities.php
@@ -17,13 +17,13 @@ final class Possibilities
/**
* @var list 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 list $rule
diff --git a/src/Psalm/Storage/PropertyStorage.php b/src/Psalm/Storage/PropertyStorage.php
index b18916c3a67..73d373cc3da 100644
--- a/src/Psalm/Storage/PropertyStorage.php
+++ b/src/Psalm/Storage/PropertyStorage.php
@@ -12,102 +12,58 @@ final class PropertyStorage implements HasAttributesInterface
{
use CustomMetadataTrait;
- /**
- * @var ?bool
- */
- public $is_static;
+ public ?bool $is_static = null;
/**
* @var ClassLikeAnalyzer::VISIBILITY_*
*/
public $visibility = ClassLikeAnalyzer::VISIBILITY_PUBLIC;
- /**
- * @var CodeLocation|null
- */
- public $location;
+ public ?CodeLocation $location = null;
- /**
- * @var CodeLocation|null
- */
- public $stmt_location;
+ public ?CodeLocation $stmt_location = null;
- /**
- * @var CodeLocation|null
- */
- public $type_location;
+ public ?CodeLocation $type_location = null;
- /**
- * @var CodeLocation|null
- */
- public $signature_type_location;
+ public ?CodeLocation $signature_type_location = null;
- /**
- * @var Union|null
- */
- public $type;
+ public ?Union $type = null;
- /**
- * @var Union|null
- */
- public $signature_type;
+ public ?Union $signature_type = null;
- /**
- * @var Union|null
- */
- public $suggested_type;
+ public ?Union $suggested_type = null;
- /**
- * @var bool
- */
- public $has_default = false;
+ public bool $has_default = false;
- /**
- * @var bool
- */
- public $deprecated = false;
+ public bool $deprecated = false;
- /**
- * @var bool
- */
- public $readonly = false;
+ public bool $readonly = false;
/**
* Whether or not to allow mutation by internal methods
- *
- * @var bool
*/
- public $allow_private_mutation = false;
+ public bool $allow_private_mutation = false;
/**
* @var list
*/
- 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/Atomic.php b/src/Psalm/Type/Atomic.php
index a879ec989bb..b80d0af22a0 100644
--- a/src/Psalm/Type/Atomic.php
+++ b/src/Psalm/Type/Atomic.php
@@ -91,32 +91,19 @@ protected function __clone()
/**
* Whether or not the type has been checked yet
- *
- * @var bool
*/
- public $checked = false;
+ public bool $checked = false;
/**
* Whether or not the type comes from a docblock
- *
- * @var bool
*/
- public $from_docblock = false;
+ public bool $from_docblock = false;
- /**
- * @var ?int
- */
- public $offset_start;
+ public ?int $offset_start = null;
- /**
- * @var ?int
- */
- public $offset_end;
+ public ?int $offset_end = null;
- /**
- * @var ?string
- */
- public $text;
+ public ?string $text = null;
/**
* @return static
diff --git a/src/Psalm/Type/Atomic/CallableTrait.php b/src/Psalm/Type/Atomic/CallableTrait.php
index 56020594677..6f1c38d1298 100644
--- a/src/Psalm/Type/Atomic/CallableTrait.php
+++ b/src/Psalm/Type/Atomic/CallableTrait.php
@@ -24,17 +24,11 @@ trait CallableTrait
/**
* @var list|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
diff --git a/src/Psalm/Type/Atomic/TAnonymousClassInstance.php b/src/Psalm/Type/Atomic/TAnonymousClassInstance.php
index 85719d74ace..d92a2f2f0b6 100644
--- a/src/Psalm/Type/Atomic/TAnonymousClassInstance.php
+++ b/src/Psalm/Type/Atomic/TAnonymousClassInstance.php
@@ -11,10 +11,7 @@
*/
final class TAnonymousClassInstance extends TNamedObject
{
- /**
- * @var string|null
- */
- public $extends;
+ public ?string $extends = null;
/**
* @param string $value the name of the object
diff --git a/src/Psalm/Type/Atomic/TArray.php b/src/Psalm/Type/Atomic/TArray.php
index 5082e6a1dfa..cf90faf8851 100644
--- a/src/Psalm/Type/Atomic/TArray.php
+++ b/src/Psalm/Type/Atomic/TArray.php
@@ -30,10 +30,7 @@ class TArray extends Atomic
*/
public array $type_params;
- /**
- * @var string
- */
- public $value = 'array';
+ public string $value = 'array';
/**
* Constructs a new instance of a generic type
diff --git a/src/Psalm/Type/Atomic/TCallable.php b/src/Psalm/Type/Atomic/TCallable.php
index 36e2bf3c0e4..90fb430a291 100644
--- a/src/Psalm/Type/Atomic/TCallable.php
+++ b/src/Psalm/Type/Atomic/TCallable.php
@@ -20,10 +20,7 @@ final class TCallable extends Atomic
{
use CallableTrait;
- /**
- * @var string
- */
- public $value;
+ public string $value;
/**
* Constructs a new instance of a generic type
diff --git a/src/Psalm/Type/Atomic/TClassConstant.php b/src/Psalm/Type/Atomic/TClassConstant.php
index 2b0946940a1..217877448b7 100644
--- a/src/Psalm/Type/Atomic/TClassConstant.php
+++ b/src/Psalm/Type/Atomic/TClassConstant.php
@@ -14,11 +14,9 @@
*/
final class TClassConstant extends Atomic
{
- /** @var string */
- public $fq_classlike_name;
+ public string $fq_classlike_name;
- /** @var string */
- public $const_name;
+ public string $const_name;
public function __construct(string $fq_classlike_name, string $const_name, bool $from_docblock = false)
{
diff --git a/src/Psalm/Type/Atomic/TClassString.php b/src/Psalm/Type/Atomic/TClassString.php
index 51641ac4d84..f994601666a 100644
--- a/src/Psalm/Type/Atomic/TClassString.php
+++ b/src/Psalm/Type/Atomic/TClassString.php
@@ -27,21 +27,15 @@
*/
class TClassString extends TString
{
- /**
- * @var string
- */
- public $as;
+ public string $as;
public ?TNamedObject $as_type;
- /** @var bool */
- public $is_loaded = false;
+ public bool $is_loaded = false;
- /** @var bool */
- public $is_interface = false;
+ public bool $is_interface = false;
- /** @var bool */
- public $is_enum = false;
+ public bool $is_enum = false;
public function __construct(
string $as = 'object',
diff --git a/src/Psalm/Type/Atomic/TClassStringMap.php b/src/Psalm/Type/Atomic/TClassStringMap.php
index 92950418b71..028252540de 100644
--- a/src/Psalm/Type/Atomic/TClassStringMap.php
+++ b/src/Psalm/Type/Atomic/TClassStringMap.php
@@ -23,17 +23,11 @@
*/
final class TClassStringMap extends Atomic
{
- /**
- * @var string
- */
- public $param_name;
+ public string $param_name;
public ?TNamedObject $as_type;
- /**
- * @var Union
- */
- public $value_param;
+ public Union $value_param;
/**
* Constructs a new instance of a list
diff --git a/src/Psalm/Type/Atomic/TClosure.php b/src/Psalm/Type/Atomic/TClosure.php
index 334c5837ff3..b556f503d29 100644
--- a/src/Psalm/Type/Atomic/TClosure.php
+++ b/src/Psalm/Type/Atomic/TClosure.php
@@ -23,7 +23,7 @@ final class TClosure extends TNamedObject
use CallableTrait;
/** @var array */
- public $byref_uses = [];
+ public array $byref_uses = [];
/**
* @param list $params
diff --git a/src/Psalm/Type/Atomic/TConditional.php b/src/Psalm/Type/Atomic/TConditional.php
index 3673a3b4847..f15ebdf350e 100644
--- a/src/Psalm/Type/Atomic/TConditional.php
+++ b/src/Psalm/Type/Atomic/TConditional.php
@@ -17,35 +17,17 @@
*/
final class TConditional extends Atomic
{
- /**
- * @var string
- */
- public $param_name;
+ public string $param_name;
- /**
- * @var string
- */
- public $defining_class;
+ public string $defining_class;
- /**
- * @var Union
- */
- public $as_type;
+ public Union $as_type;
- /**
- * @var Union
- */
- public $conditional_type;
+ public Union $conditional_type;
- /**
- * @var Union
- */
- public $if_type;
+ public Union $if_type;
- /**
- * @var Union
- */
- public $else_type;
+ public Union $else_type;
public function __construct(
string $param_name,
diff --git a/src/Psalm/Type/Atomic/TDependentGetClass.php b/src/Psalm/Type/Atomic/TDependentGetClass.php
index 76078ad6d4b..ebc492233b0 100644
--- a/src/Psalm/Type/Atomic/TDependentGetClass.php
+++ b/src/Psalm/Type/Atomic/TDependentGetClass.php
@@ -15,15 +15,10 @@ final class TDependentGetClass extends TString implements DependentType
{
/**
* Used to hold information as to what this refers to
- *
- * @var string
*/
- public $typeof;
+ public string $typeof;
- /**
- * @var Union
- */
- public $as_type;
+ public Union $as_type;
/**
* @param string $typeof the variable id
diff --git a/src/Psalm/Type/Atomic/TDependentGetDebugType.php b/src/Psalm/Type/Atomic/TDependentGetDebugType.php
index 5dd416e52c3..5875f911fdc 100644
--- a/src/Psalm/Type/Atomic/TDependentGetDebugType.php
+++ b/src/Psalm/Type/Atomic/TDependentGetDebugType.php
@@ -13,10 +13,8 @@ final class TDependentGetDebugType extends TString implements DependentType
{
/**
* Used to hold information as to what this refers to
- *
- * @var string
*/
- public $typeof;
+ public string $typeof;
/**
* @param string $typeof the variable id
diff --git a/src/Psalm/Type/Atomic/TDependentGetType.php b/src/Psalm/Type/Atomic/TDependentGetType.php
index 1db93696a56..7f1bfee3877 100644
--- a/src/Psalm/Type/Atomic/TDependentGetType.php
+++ b/src/Psalm/Type/Atomic/TDependentGetType.php
@@ -13,10 +13,8 @@ final class TDependentGetType extends TString
{
/**
* Used to hold information as to what this refers to
- *
- * @var string
*/
- public $typeof;
+ public string $typeof;
/**
* @param string $typeof the variable id
diff --git a/src/Psalm/Type/Atomic/TEnumCase.php b/src/Psalm/Type/Atomic/TEnumCase.php
index f57927c48ea..2fcbb1faa69 100644
--- a/src/Psalm/Type/Atomic/TEnumCase.php
+++ b/src/Psalm/Type/Atomic/TEnumCase.php
@@ -11,10 +11,7 @@
*/
final class TEnumCase extends TNamedObject
{
- /**
- * @var string
- */
- public $case_name;
+ public string $case_name;
public function __construct(string $fq_enum_name, string $case_name)
{
diff --git a/src/Psalm/Type/Atomic/TFalse.php b/src/Psalm/Type/Atomic/TFalse.php
index 8929777083c..0bfc243ef44 100644
--- a/src/Psalm/Type/Atomic/TFalse.php
+++ b/src/Psalm/Type/Atomic/TFalse.php
@@ -12,7 +12,7 @@
final class TFalse extends TBool
{
/** @var false */
- public $value = false;
+ public bool $value = false;
public function getKey(bool $include_extra = true): string
{
diff --git a/src/Psalm/Type/Atomic/TGenericObject.php b/src/Psalm/Type/Atomic/TGenericObject.php
index 71f1afc1768..244a3218e40 100644
--- a/src/Psalm/Type/Atomic/TGenericObject.php
+++ b/src/Psalm/Type/Atomic/TGenericObject.php
@@ -34,7 +34,7 @@ final class TGenericObject extends TNamedObject
public array $type_params;
/** @var bool if the parameters have been remapped to another class */
- public $remapped_params = false;
+ public bool $remapped_params = false;
/**
* @param string $value the name of the object
diff --git a/src/Psalm/Type/Atomic/TIntMask.php b/src/Psalm/Type/Atomic/TIntMask.php
index b5686ae83bc..f19e30ee91d 100644
--- a/src/Psalm/Type/Atomic/TIntMask.php
+++ b/src/Psalm/Type/Atomic/TIntMask.php
@@ -15,7 +15,7 @@
final class TIntMask extends TInt
{
/** @var non-empty-array */
- public $values;
+ public array $values;
/** @param non-empty-array $values */
public function __construct(array $values, bool $from_docblock = false)
diff --git a/src/Psalm/Type/Atomic/TIntMaskOf.php b/src/Psalm/Type/Atomic/TIntMaskOf.php
index acd878433cc..ace9727db82 100644
--- a/src/Psalm/Type/Atomic/TIntMaskOf.php
+++ b/src/Psalm/Type/Atomic/TIntMaskOf.php
@@ -15,8 +15,7 @@
*/
final class TIntMaskOf extends TInt
{
- /** @var TClassConstant|TKeyOf|TValueOf */
- public $value;
+ public TClassConstant|TKeyOf|TValueOf $value;
/**
* @param TClassConstant|TKeyOf|TValueOf $value
diff --git a/src/Psalm/Type/Atomic/TIntRange.php b/src/Psalm/Type/Atomic/TIntRange.php
index a7991a52153..b3a55d714fd 100644
--- a/src/Psalm/Type/Atomic/TIntRange.php
+++ b/src/Psalm/Type/Atomic/TIntRange.php
@@ -17,17 +17,10 @@ final class TIntRange extends TInt
public const BOUND_MIN = 'min';
public const BOUND_MAX = 'max';
- /**
- * @var int|null
- */
- public $min_bound;
- /**
- * @var int|null
- */
- public $max_bound;
+ public ?int $min_bound = null;
+ public ?int $max_bound = null;
- /** @var string|null */
- public $dependent_list_key;
+ public ?string $dependent_list_key = null;
public function __construct(
?int $min_bound,
diff --git a/src/Psalm/Type/Atomic/TIterable.php b/src/Psalm/Type/Atomic/TIterable.php
index 93d1caa8875..f8153751a04 100644
--- a/src/Psalm/Type/Atomic/TIterable.php
+++ b/src/Psalm/Type/Atomic/TIterable.php
@@ -33,15 +33,9 @@ final class TIterable extends Atomic
*/
public array $type_params;
- /**
- * @var string
- */
- public $value = 'iterable';
+ public string $value = 'iterable';
- /**
- * @var bool
- */
- public $has_docblock_params = false;
+ public bool $has_docblock_params = false;
/**
* @param array{Union, Union}|array $type_params
diff --git a/src/Psalm/Type/Atomic/TKeyOf.php b/src/Psalm/Type/Atomic/TKeyOf.php
index 51370754b27..22d9e53d588 100644
--- a/src/Psalm/Type/Atomic/TKeyOf.php
+++ b/src/Psalm/Type/Atomic/TKeyOf.php
@@ -16,8 +16,7 @@
*/
final class TKeyOf extends TArrayKey
{
- /** @var Union */
- public $type;
+ public Union $type;
public function __construct(Union $type, bool $from_docblock = false)
{
diff --git a/src/Psalm/Type/Atomic/TKeyedArray.php b/src/Psalm/Type/Atomic/TKeyedArray.php
index 965ef12e2ec..80f9f968319 100644
--- a/src/Psalm/Type/Atomic/TKeyedArray.php
+++ b/src/Psalm/Type/Atomic/TKeyedArray.php
@@ -36,24 +36,24 @@ class TKeyedArray extends Atomic
/**
* @var non-empty-array
*/
- 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';
diff --git a/src/Psalm/Type/Atomic/TLiteralClassString.php b/src/Psalm/Type/Atomic/TLiteralClassString.php
index b7936a488c7..a3e14fa2d12 100644
--- a/src/Psalm/Type/Atomic/TLiteralClassString.php
+++ b/src/Psalm/Type/Atomic/TLiteralClassString.php
@@ -19,10 +19,8 @@ final class TLiteralClassString extends TLiteralString
{
/**
* Whether or not this type can represent a child of the class named in $value
- *
- * @var bool
*/
- public $definite_class = false;
+ public bool $definite_class = false;
public function __construct(string $value, bool $definite_class = false, bool $from_docblock = false)
{
diff --git a/src/Psalm/Type/Atomic/TLiteralString.php b/src/Psalm/Type/Atomic/TLiteralString.php
index 6da01c89674..f235fdfb95b 100644
--- a/src/Psalm/Type/Atomic/TLiteralString.php
+++ b/src/Psalm/Type/Atomic/TLiteralString.php
@@ -19,8 +19,7 @@
*/
class TLiteralString extends TString
{
- /** @var string */
- public $value;
+ public string $value;
/**
* Creates a literal string with a known value.
diff --git a/src/Psalm/Type/Atomic/TMixed.php b/src/Psalm/Type/Atomic/TMixed.php
index d9aad81eb38..b7f24fcb6c5 100644
--- a/src/Psalm/Type/Atomic/TMixed.php
+++ b/src/Psalm/Type/Atomic/TMixed.php
@@ -13,8 +13,7 @@
*/
class TMixed extends Atomic
{
- /** @var bool */
- public $from_loop_isset = false;
+ public bool $from_loop_isset = false;
public function __construct(bool $from_loop_isset = false, bool $from_docblock = false)
{
diff --git a/src/Psalm/Type/Atomic/TNamedObject.php b/src/Psalm/Type/Atomic/TNamedObject.php
index daf9571e7fd..7a0a2e602fe 100644
--- a/src/Psalm/Type/Atomic/TNamedObject.php
+++ b/src/Psalm/Type/Atomic/TNamedObject.php
@@ -24,27 +24,16 @@ class TNamedObject extends Atomic
{
use HasIntersectionTrait;
- /**
- * @var string
- */
- public $value;
+ public string $value;
- /**
- * @var bool
- */
- public $is_static = false;
+ public bool $is_static = false;
- /**
- * @var bool
- */
- public $is_static_resolved = false;
+ public bool $is_static_resolved = false;
/**
* Whether or not this type can represent a child of the class named in $value
- *
- * @var bool
*/
- public $definite_class = false;
+ public bool $definite_class = false;
/**
* @param string $value the name of the object
diff --git a/src/Psalm/Type/Atomic/TNonEmptyArray.php b/src/Psalm/Type/Atomic/TNonEmptyArray.php
index c4b9a9c28ab..b71dd5d5f3b 100644
--- a/src/Psalm/Type/Atomic/TNonEmptyArray.php
+++ b/src/Psalm/Type/Atomic/TNonEmptyArray.php
@@ -17,17 +17,14 @@ final class TNonEmptyArray extends TArray
/**
* @var positive-int|null
*/
- public $count;
+ public ?int $count = null;
/**
* @var positive-int|null
*/
- public $min_count;
+ public ?int $min_count = null;
- /**
- * @var string
- */
- public $value = 'non-empty-array';
+ public string $value = 'non-empty-array';
/**
* @param array{Union, Union} $type_params
diff --git a/src/Psalm/Type/Atomic/TObjectWithProperties.php b/src/Psalm/Type/Atomic/TObjectWithProperties.php
index 96dcc33a062..1f54c63c8a8 100644
--- a/src/Psalm/Type/Atomic/TObjectWithProperties.php
+++ b/src/Psalm/Type/Atomic/TObjectWithProperties.php
@@ -29,15 +29,14 @@ final class TObjectWithProperties extends TObject
/**
* @var array
*/
- 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
diff --git a/src/Psalm/Type/Atomic/TTemplateIndexedAccess.php b/src/Psalm/Type/Atomic/TTemplateIndexedAccess.php
index ac2442834af..bba86e66e29 100644
--- a/src/Psalm/Type/Atomic/TTemplateIndexedAccess.php
+++ b/src/Psalm/Type/Atomic/TTemplateIndexedAccess.php
@@ -11,20 +11,11 @@
*/
final class TTemplateIndexedAccess extends Atomic
{
- /**
- * @var string
- */
- public $array_param_name;
+ public string $array_param_name;
- /**
- * @var string
- */
- public $offset_param_name;
+ public string $offset_param_name;
- /**
- * @var string
- */
- public $defining_class;
+ public string $defining_class;
public function __construct(
string $array_param_name,
diff --git a/src/Psalm/Type/Atomic/TTemplateKeyOf.php b/src/Psalm/Type/Atomic/TTemplateKeyOf.php
index 50f20ff1e13..48c61dff5ec 100644
--- a/src/Psalm/Type/Atomic/TTemplateKeyOf.php
+++ b/src/Psalm/Type/Atomic/TTemplateKeyOf.php
@@ -17,20 +17,11 @@
*/
final class TTemplateKeyOf extends Atomic
{
- /**
- * @var string
- */
- public $param_name;
+ public string $param_name;
- /**
- * @var string
- */
- public $defining_class;
+ public string $defining_class;
- /**
- * @var Union
- */
- public $as;
+ public Union $as;
public function __construct(
string $param_name,
diff --git a/src/Psalm/Type/Atomic/TTemplateParam.php b/src/Psalm/Type/Atomic/TTemplateParam.php
index d896b87b817..8a95ab2bdb8 100644
--- a/src/Psalm/Type/Atomic/TTemplateParam.php
+++ b/src/Psalm/Type/Atomic/TTemplateParam.php
@@ -21,20 +21,11 @@ final class TTemplateParam extends Atomic
{
use HasIntersectionTrait;
- /**
- * @var string
- */
- public $param_name;
+ public string $param_name;
- /**
- * @var Union
- */
- public $as;
+ public Union $as;
- /**
- * @var string
- */
- public $defining_class;
+ public string $defining_class;
/**
* @param array $extra_types
diff --git a/src/Psalm/Type/Atomic/TTemplateParamClass.php b/src/Psalm/Type/Atomic/TTemplateParamClass.php
index 488a8e382dd..00b370a68b8 100644
--- a/src/Psalm/Type/Atomic/TTemplateParamClass.php
+++ b/src/Psalm/Type/Atomic/TTemplateParamClass.php
@@ -11,15 +11,9 @@
*/
final class TTemplateParamClass extends TClassString
{
- /**
- * @var string
- */
- public $param_name;
+ public string $param_name;
- /**
- * @var string
- */
- public $defining_class;
+ public string $defining_class;
public function __construct(
string $param_name,
diff --git a/src/Psalm/Type/Atomic/TTemplatePropertiesOf.php b/src/Psalm/Type/Atomic/TTemplatePropertiesOf.php
index d629f704fb6..e1e888f10f5 100644
--- a/src/Psalm/Type/Atomic/TTemplatePropertiesOf.php
+++ b/src/Psalm/Type/Atomic/TTemplatePropertiesOf.php
@@ -17,18 +17,9 @@
*/
final class TTemplatePropertiesOf extends Atomic
{
- /**
- * @var string
- */
- public $param_name;
- /**
- * @var string
- */
- public $defining_class;
- /**
- * @var TTemplateParam
- */
- public $as;
+ public string $param_name;
+ public string $defining_class;
+ public TTemplateParam $as;
/**
* @var TPropertiesOf::VISIBILITY_*|null
*/
diff --git a/src/Psalm/Type/Atomic/TTemplateValueOf.php b/src/Psalm/Type/Atomic/TTemplateValueOf.php
index 895a532ef13..98be9d1e85c 100644
--- a/src/Psalm/Type/Atomic/TTemplateValueOf.php
+++ b/src/Psalm/Type/Atomic/TTemplateValueOf.php
@@ -17,20 +17,11 @@
*/
final class TTemplateValueOf extends Atomic
{
- /**
- * @var string
- */
- public $param_name;
+ public string $param_name;
- /**
- * @var string
- */
- public $defining_class;
+ public string $defining_class;
- /**
- * @var Union
- */
- public $as;
+ public Union $as;
public function __construct(
string $param_name,
diff --git a/src/Psalm/Type/Atomic/TTrue.php b/src/Psalm/Type/Atomic/TTrue.php
index 16b354ad91e..67937dd7548 100644
--- a/src/Psalm/Type/Atomic/TTrue.php
+++ b/src/Psalm/Type/Atomic/TTrue.php
@@ -12,7 +12,7 @@
final class TTrue extends TBool
{
/** @var true */
- public $value = true;
+ public bool $value = true;
public function getKey(bool $include_extra = true): string
{
diff --git a/src/Psalm/Type/Atomic/TTypeAlias.php b/src/Psalm/Type/Atomic/TTypeAlias.php
index fdc674cd8a4..52a2fe9037a 100644
--- a/src/Psalm/Type/Atomic/TTypeAlias.php
+++ b/src/Psalm/Type/Atomic/TTypeAlias.php
@@ -20,13 +20,11 @@ final class TTypeAlias extends Atomic
* referencing type(s) are part of other intersection types. The intersection types are not set anymore
* and with v6 this property along with its related methods will get removed.
*/
- public $extra_types;
+ public ?array $extra_types = null;
- /** @var string */
- public $declaring_fq_classlike_name;
+ public string $declaring_fq_classlike_name;
- /** @var string */
- public $alias_name;
+ public string $alias_name;
/**
* @param array|null $extra_types
diff --git a/src/Psalm/Type/Atomic/TValueOf.php b/src/Psalm/Type/Atomic/TValueOf.php
index b278bc82989..ad71cd03ce3 100644
--- a/src/Psalm/Type/Atomic/TValueOf.php
+++ b/src/Psalm/Type/Atomic/TValueOf.php
@@ -20,8 +20,7 @@
*/
final class TValueOf extends Atomic
{
- /** @var Union */
- public $type;
+ public Union $type;
public function __construct(Union $type, bool $from_docblock = false)
{
diff --git a/src/Psalm/Type/MutableUnion.php b/src/Psalm/Type/MutableUnion.php
index bcf0aa44534..70b6377ee69 100644
--- a/src/Psalm/Type/MutableUnion.php
+++ b/src/Psalm/Type/MutableUnion.php
@@ -41,120 +41,88 @@ final class MutableUnion implements TypeNode
/**
* Whether the type originated in a docblock
- *
- * @var bool
*/
- public $from_docblock = false;
+ public bool $from_docblock = false;
/**
* Whether the type originated from integer calculation
- *
- * @var bool
*/
- public $from_calculation = false;
+ public bool $from_calculation = false;
/**
* Whether the type originated from a property
*
* This helps turn isset($foo->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
@@ -180,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
@@ -214,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;
diff --git a/src/Psalm/Type/Union.php b/src/Psalm/Type/Union.php
index cb0575674e0..1d0b7fd0748 100644
--- a/src/Psalm/Type/Union.php
+++ b/src/Psalm/Type/Union.php
@@ -54,119 +54,86 @@ final class Union implements TypeNode
/**
* Whether the type originated in a docblock
- *
- * @var bool
*/
- public $from_docblock = false;
+ public bool $from_docblock = false;
/**
* Whether the type originated from integer calculation
- *
- * @var bool
*/
- public $from_calculation = false;
+ public bool $from_calculation = false;
/**
* Whether the type originated from a property
*
* This helps turn isset($foo->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
@@ -192,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
@@ -226,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