Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rector to add property typehints #8887

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 8 additions & 16 deletions src/Psalm/CodeLocation.php
Expand Up @@ -42,8 +42,7 @@ class CodeLocation
/** @var int */
public $raw_line_number;

/** @var int */
private $end_line_number = -1;
private int $end_line_number = -1;

/** @var int */
public $raw_file_start;
Expand All @@ -63,23 +62,17 @@ class CodeLocation
/** @var int */
protected $preview_start;

/** @var int */
private $preview_end = -1;
private int $preview_end = -1;

/** @var int */
private $selection_start = -1;
private int $selection_start = -1;

/** @var int */
private $selection_end = -1;
private int $selection_end = -1;

/** @var int */
private $column_from = -1;
private int $column_from = -1;

/** @var int */
private $column_to = -1;
private int $column_to = -1;

/** @var string */
private $snippet = '';
private string $snippet = '';

/** @var null|string */
private $text;
Expand All @@ -96,8 +89,7 @@ class CodeLocation
/** @var null|int */
private $regex_type;

/** @var bool */
private $have_recalculated = false;
private bool $have_recalculated = false;

/** @var null|CodeLocation */
public $previous_location;
Expand Down
5 changes: 1 addition & 4 deletions src/Psalm/Codebase.php
Expand Up @@ -146,10 +146,7 @@ final class Codebase
*/
public $statements_provider;

/**
* @var Progress
*/
private $progress;
private Progress $progress;

/**
* @var array<string, Union>
Expand Down
36 changes: 16 additions & 20 deletions src/Psalm/Config.php
Expand Up @@ -245,55 +245,53 @@ class Config

/**
* The PHP version to assume as declared in the config file
*
* @var string|null
*/
private $configured_php_version;
private ?string $configured_php_version = null;

/**
* @var array<int, string>
*/
private $file_extensions = ['php'];
private array $file_extensions = ['php'];

/**
* @var array<string, class-string<FileScanner>>
*/
private $filetype_scanners = [];
private array $filetype_scanners = [];

/**
* @var array<string, class-string<FileAnalyzer>>
*/
private $filetype_analyzers = [];
private array $filetype_analyzers = [];

/**
* @var array<string, string>
*/
private $filetype_scanner_paths = [];
private array $filetype_scanner_paths = [];

/**
* @var array<string, string>
*/
private $filetype_analyzer_paths = [];
private array $filetype_analyzer_paths = [];

/**
* @var array<string, IssueHandler>
*/
private $issue_handlers = [];
private array $issue_handlers = [];

/**
* @var array<int, string>
*/
private $mock_classes = [];
private array $mock_classes = [];

/**
* @var array<string, string>
*/
private $preloaded_stub_files = [];
private array $preloaded_stub_files = [];

/**
* @var array<string, string>
*/
private $stub_files = [];
private array $stub_files = [];

/**
* @var bool
Expand Down Expand Up @@ -503,7 +501,7 @@ class Config
/**
* @var array<array{class:string,config:?SimpleXMLElement}>
*/
private $plugin_classes = [];
private array $plugin_classes = [];

/**
* @var bool
Expand All @@ -516,13 +514,12 @@ class Config
public $allow_named_arg_calls = true;

/** @var array<string, mixed> */
private $predefined_constants = [];
private array $predefined_constants = [];

/** @var array<callable-string, bool> */
private $predefined_functions = [];
private array $predefined_functions = [];

/** @var ClassLoader|null */
private $composer_class_loader;
private ?ClassLoader $composer_class_loader = null;

/**
* @var string
Expand Down Expand Up @@ -550,8 +547,7 @@ class Config
*/
public $max_string_length = 1_000;

/** @var ?IncludeCollector */
private $include_collector;
private ?IncludeCollector $include_collector = null;

/**
* @var TaintAnalysisFileFilter|null
Expand Down Expand Up @@ -631,7 +627,7 @@ class Config
/**
* @var array<class-string, PluginInterface>
*/
private $plugins = [];
private array $plugins = [];

/** @internal */
protected function __construct()
Expand Down
5 changes: 1 addition & 4 deletions src/Psalm/Config/ErrorLevelFileFilter.php
Expand Up @@ -11,10 +11,7 @@
/** @internal */
final class ErrorLevelFileFilter extends FileFilter
{
/**
* @var string
*/
private $error_level = '';
private string $error_level = '';

/**
* @return static
Expand Down
7 changes: 2 additions & 5 deletions src/Psalm/Config/IssueHandler.php
Expand Up @@ -19,15 +19,12 @@
/** @internal */
final class IssueHandler
{
/**
* @var string
*/
private $error_level = Config::REPORT_ERROR;
private string $error_level = Config::REPORT_ERROR;

/**
* @var array<ErrorLevelFileFilter>
*/
private $custom_levels = [];
private array $custom_levels = [];

public static function loadFromXMLElement(SimpleXMLElement $e, string $base_dir): IssueHandler
{
Expand Down
5 changes: 1 addition & 4 deletions src/Psalm/Config/ProjectFileFilter.php
Expand Up @@ -11,10 +11,7 @@
/** @internal */
final class ProjectFileFilter extends FileFilter
{
/**
* @var ProjectFileFilter|null
*/
private $file_filter;
private ?ProjectFileFilter $file_filter = null;

/**
* @return static
Expand Down
9 changes: 3 additions & 6 deletions src/Psalm/FileBasedPluginAdapter.php
Expand Up @@ -19,14 +19,11 @@
/** @internal */
final class FileBasedPluginAdapter implements PluginEntryPointInterface
{
/** @var string */
private $path;
private string $path;

/** @var Codebase */
private $codebase;
private Codebase $codebase;

/** @var Config */
private $config;
private Config $config;

public function __construct(string $path, Config $config, Codebase $codebase)
{
Expand Down
23 changes: 9 additions & 14 deletions src/Psalm/Internal/Analyzer/FileAnalyzer.php
Expand Up @@ -67,32 +67,32 @@ class FileAnalyzer extends SourceAnalyzer
/**
* @var array<string, bool>
*/
private $required_file_paths = [];
private array $required_file_paths = [];

/**
* @var array<string, bool>
*/
private $parent_file_paths = [];
private array $parent_file_paths = [];

/**
* @var array<string>
*/
private $suppressed_issues = [];
private array $suppressed_issues = [];

/**
* @var array<string, array<string, string>>
*/
private $namespace_aliased_classes = [];
private array $namespace_aliased_classes = [];

/**
* @var array<string, array<lowercase-string, string>>
*/
private $namespace_aliased_classes_flipped = [];
private array $namespace_aliased_classes_flipped = [];

/**
* @var array<string, array<string, string>>
*/
private $namespace_aliased_classes_flipped_replaceable = [];
private array $namespace_aliased_classes_flipped_replaceable = [];

/**
* @var array<lowercase-string, InterfaceAnalyzer>
Expand All @@ -119,16 +119,11 @@ class FileAnalyzer extends SourceAnalyzer
*/
public $codebase;

/**
* @var int
*/
private $first_statement_offset = -1;
private int $first_statement_offset = -1;

/** @var ?NodeDataProvider */
private $node_data;
private ?NodeDataProvider $node_data = null;

/** @var ?Union */
private $return_type;
private ?Union $return_type = null;

public function __construct(ProjectAnalyzer $project_analyzer, string $file_path, string $file_name)
{
Expand Down
5 changes: 1 addition & 4 deletions src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
Expand Up @@ -116,10 +116,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
*/
protected $return_vars_possibly_in_scope = [];

/**
* @var Union|null
*/
private $local_return_type;
private ?Union $local_return_type = null;

/**
* @var array<string, bool>
Expand Down
10 changes: 2 additions & 8 deletions src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php
Expand Up @@ -33,15 +33,9 @@ class NamespaceAnalyzer extends SourceAnalyzer
*/
protected $source;

/**
* @var Namespace_
*/
private $namespace;
private Namespace_ $namespace;

/**
* @var string
*/
private $namespace_name;
private string $namespace_name;

/**
* A lookup table for public namespace constants
Expand Down
26 changes: 9 additions & 17 deletions src/Psalm/Internal/Analyzer/ProjectAnalyzer.php
Expand Up @@ -111,10 +111,8 @@ class ProjectAnalyzer
{
/**
* Cached config
*
* @var Config
*/
private $config;
private Config $config;

/**
* @var self
Expand All @@ -123,25 +121,19 @@ class ProjectAnalyzer

/**
* An object representing everything we know about the code
*
* @var Codebase
*/
private $codebase;
private Codebase $codebase;

/** @var FileProvider */
private $file_provider;
private FileProvider $file_provider;

/** @var ClassLikeStorageProvider */
private $classlike_storage_provider;
private ClassLikeStorageProvider $classlike_storage_provider;

/** @var ?ParserCacheProvider */
private $parser_cache_provider;
private ?ParserCacheProvider $parser_cache_provider;

/** @var ?ProjectCacheProvider */
public $project_cache_provider;

/** @var FileReferenceProvider */
private $file_reference_provider;
private FileReferenceProvider $file_reference_provider;

/**
* @var Progress
Expand Down Expand Up @@ -169,7 +161,7 @@ class ProjectAnalyzer
/**
* @var array<string, bool>
*/
private $issues_to_fix = [];
private array $issues_to_fix = [];

/**
* @var bool
Expand Down Expand Up @@ -204,12 +196,12 @@ class ProjectAnalyzer
/**
* @var array<string,string>
*/
private $project_files = [];
private array $project_files = [];

/**
* @var array<string,string>
*/
private $extra_files = [];
private array $extra_files = [];

/**
* @var array<string, string>
Expand Down
Expand Up @@ -27,7 +27,7 @@ class UnusedAssignmentRemover
/**
* @var array<string, CodeLocation>
*/
private $removed_unref_vars = [];
private array $removed_unref_vars = [];

/**
* @param array<PhpParser\Node\Stmt> $stmts
Expand Down