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

Document lowercase-string when possible #4904

Merged
merged 2 commits into from
Dec 29, 2020
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
16 changes: 8 additions & 8 deletions src/Psalm/Aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
class Aliases
{
/**
* @var array<string, string>
* @var array<lowercase-string, string>
*/
public $uses;

/**
* @var array<string, string>
* @var array<lowercase-string, string>
*/
public $uses_flipped;

/**
* @var array<string, non-empty-string>
* @var array<lowercase-string, non-empty-string>
*/
public $functions;

/**
* @var array<string, string>
* @var array<lowercase-string, string>
*/
public $functions_flipped;

Expand All @@ -46,11 +46,11 @@ class Aliases
public $uses_end;

/**
* @param array<string, string> $uses
* @param array<string, non-empty-string> $functions
* @param array<lowercase-string, string> $uses
* @param array<lowercase-string, non-empty-string> $functions
* @param array<string, string> $constants
* @param array<string, string> $uses_flipped
* @param array<string, string> $functions_flipped
* @param array<lowercase-string, string> $uses_flipped
* @param array<lowercase-string, string> $functions_flipped
* @param array<string, string> $constants_flipped
*/
public function __construct(
Expand Down
6 changes: 3 additions & 3 deletions src/Psalm/Codebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ class Codebase
* A map of fully-qualified use declarations to the files
* that reference them (keyed by filename)
*
* @var array<string, array<int, \Psalm\CodeLocation>>
* @var array<lowercase-string, array<int, \Psalm\CodeLocation>>
*/
public $use_referencing_locations = [];

/**
* A map of file names to the classes that they contain explicit references to
* used in collaboration with use_referencing_locations
*
* @var array<string, array<string, bool>>
* @var array<string, array<lowercase-string, bool>>
*/
public $use_referencing_files = [];

Expand Down Expand Up @@ -235,7 +235,7 @@ class Codebase
public $classes_to_move = [];

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

Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class Config
public $ensure_array_int_offsets_exist = false;

/**
* @var array<string, bool>
* @var array<lowercase-string, bool>
*/
public $forbidden_functions = [];

Expand Down Expand Up @@ -591,7 +591,7 @@ class Config
/**
* Custom functions that always exit
*
* @var array<string, bool>
* @var array<lowercase-string, bool>
*/
public $exit_functions = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Context
/**
* A list of classes checked with class_exists
*
* @var array<string,bool>
* @var array<lowercase-string,bool>
*/
public $phantom_classes = [];

Expand Down
12 changes: 6 additions & 6 deletions src/Psalm/Internal/Analyzer/CanAlias.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
trait CanAlias
{
/**
* @var array<string, string>
* @var array<lowercase-string, string>
*/
private $aliased_classes = [];

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

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

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

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

Expand Down Expand Up @@ -132,7 +132,7 @@ public function visitGroupUse(PhpParser\Node\Stmt\GroupUse $stmt): void
}

/**
* @return array<string, string>
* @return array<lowercase-string, string>
*/
public function getAliasedClassesFlipped(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public static function getFQCLNFromNameObject(
}

/**
* @return array<string, string>
* @return array<lowercase-string, string>
*/
public function getAliasedClassesFlipped(): array
{
Expand Down
8 changes: 4 additions & 4 deletions src/Psalm/Internal/Analyzer/FileAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class FileAnalyzer extends SourceAnalyzer
private $namespace_aliased_classes = [];

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

Expand All @@ -77,7 +77,7 @@ class FileAnalyzer extends SourceAnalyzer
private $namespace_aliased_classes_flipped_replaceable = [];

/**
* @var array<string, InterfaceAnalyzer>
* @var array<lowercase-string, InterfaceAnalyzer>
*/
public $interface_analyzers_to_analyze = [];

Expand Down Expand Up @@ -351,7 +351,7 @@ private function populateClassLikeAnalyzers(PhpParser\Node\Stmt\ClassLike $stmt)

$fq_class_name = $class_analyzer->getFQCLN();

$this->interface_analyzers_to_analyze[$fq_class_name] = $class_analyzer;
$this->interface_analyzers_to_analyze[strtolower($fq_class_name)] = $class_analyzer;
}
}

Expand Down Expand Up @@ -448,7 +448,7 @@ public function getNamespace(): ?string
}

/**
* @return array<string, string>
* @return array<lowercase-string, string>
*/
public function getAliasedClassesFlipped(?string $namespace_name = null): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,7 @@ public function getId() : string
}

/**
* @return array<string, string>
* @return array<lowercase-string, string>
*/
public function getAliasedClassesFlipped(): array
{
Expand Down
9 changes: 5 additions & 4 deletions src/Psalm/Internal/Analyzer/ScopeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ public static function doesEverBreak(array $stmts): bool
}

/**
* @param array<PhpParser\Node> $stmts
* @param bool $return_is_exit Exit and Throw statements are treated differently from return if this is false
* @param list<'loop'|'switch'> $break_types
* @param array<PhpParser\Node> $stmts
* @param array<lowercase-string, bool> $exit_functions
* @param list<'loop'|'switch'> $break_types
* @param bool $return_is_exit Exit and Throw statements are treated differently from return if this is false
*
* @return list<self::ACTION_*>
* @return list<self::ACTION_*>
*/
public static function getControlActions(
array $stmts,
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/SourceAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getAliases(): Aliases
}

/**
* @return array<string, string>
* @return array<lowercase-string, string>
*/
public function getAliasedClassesFlipped(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/TraitAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getAliases(): Aliases
}

/**
* @return array<string, string>
* @return array<lowercase-string, string>
*/
public function getAliasedClassesFlipped(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Codebase/ClassLikes.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class ClassLikes
private $existing_traits = [];

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

Expand Down Expand Up @@ -557,7 +557,7 @@ public function interfaceExtends(string $interface_name, string $possible_parent
}

/**
* @return array<string, string> all interfaces extended by $interface_name
* @return array<lowercase-string, string> all interfaces extended by $interface_name
*/
public function getParentInterfaces(string $fq_interface_name): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Codebase/InternalCallMapHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class InternalCallMapHandler
private static $loaded_php_minor_version = null;

/**
* @var array<array<int|string,string>>|null
* @var array<lowercase-string, array<int|string,string>>|null
*/
private static $call_map = null;

Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Codebase/PropertyMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
class PropertyMap
{
/**
* @var array<string, array<string, string>>|null
* @var array<lowercase-string, array<string, string>>|null
*/
private static $property_map;

/**
* Gets the method/function call map
*
* @return array<string, array<string, string>>
* @return array<lowercase-string, array<string, string>>
*/
public static function getPropertyMap(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Codebase/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* unchanged_signature_members:array<string, array<string, bool>>,
* diff_map:array<string, array<int, array{0:int, 1:int, 2:int, 3:int}>>,
* classlike_storage:array<string, \Psalm\Storage\ClassLikeStorage>,
* file_storage:array<string, \Psalm\Storage\FileStorage>,
* file_storage:array<lowercase-string, \Psalm\Storage\FileStorage>,
* new_file_content_hashes: array<string, string>,
* taint_data: ?TaintFlowGraph
* }
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Provider/FileProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
class FileProvider
{
/**
* @var array<string, string>
* @var array<lowercase-string, string>
*/
protected $temp_files = [];

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

Expand Down
7 changes: 3 additions & 4 deletions src/Psalm/Internal/Provider/FileStorageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class FileStorageProvider
* A list of data useful to analyse files
* Storing this statically is much faster (at least in PHP 7.2.1)
*
* @var array<string, FileStorage>
* @var array<lowercase-string, FileStorage>
*/
private static $storage = [];

Expand Down Expand Up @@ -81,7 +81,7 @@ public function has(string $file_path, ?string $file_contents = null): bool
}

/**
* @return array<string, FileStorage>
* @return array<lowercase-string, FileStorage>
*/
public function getAll(): array
{
Expand All @@ -97,8 +97,7 @@ public function getNew(): array
}

/**
* @param array<string, FileStorage> $more
*
* @param array<lowercase-string, FileStorage> $more
*/
public function addMore(array $more): void
{
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Provider/FunctionExistenceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class FunctionExistenceProvider
{
/**
* @var array<
* string,
* lowercase-string,
* array<\Closure(
* StatementsSource,
* string
Expand Down Expand Up @@ -38,7 +38,7 @@ public function registerClass(string $class): void
}

/**
* /**
* @param lowercase-string $function_id
* @param \Closure(
* StatementsSource,
* string
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Provider/FunctionParamsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FunctionParamsProvider
{
/**
* @var array<
* string,
* lowercase-string,
* array<\Closure(
* StatementsSource,
* string,
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class FunctionReturnTypeProvider
{
/**
* @var array<
* string,
* lowercase-string,
* array<\Closure(
* StatementsSource,
* non-empty-string,
Expand Down Expand Up @@ -72,7 +72,7 @@ public function registerClass(string $class): void
}

/**
* /**
* @param lowercase-string $function_id
* @param \Closure(
* StatementsSource,
* non-empty-string,
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Provider/MethodExistenceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class MethodExistenceProvider
{
/**
* @var array<
* string,
* lowercase-string,
* array<\Closure(
* string,
* string,
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Provider/MethodParamsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MethodParamsProvider
{
/**
* @var array<
* string,
* lowercase-string,
* array<\Closure(
* string,
* string,
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Provider/MethodReturnTypeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MethodReturnTypeProvider
{
/**
* @var array<
* string,
* lowercase-string,
* array<\Closure(
* StatementsSource,
* string,
Expand Down