From 73f6fcde48b3970ea750c8806158fcde9e0ee2ea Mon Sep 17 00:00:00 2001 From: orklah Date: Wed, 2 Sep 2020 06:17:41 +0200 Subject: [PATCH] Short list syntax (#4102) * Short list syntax * revert unrelated CS --- examples/TemplateScanner.php | 2 +- src/Psalm/Codebase.php | 22 +++++++-------- src/Psalm/DocComment.php | 4 +-- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 6 ++-- .../Internal/Analyzer/ClassLikeAnalyzer.php | 2 +- .../Analyzer/FunctionLikeAnalyzer.php | 6 ++-- .../Internal/Analyzer/ProjectAnalyzer.php | 2 +- .../StaticPropertyAssignmentAnalyzer.php | 4 +-- .../Expression/Call/ArgumentAnalyzer.php | 4 +-- .../Call/ArrayFunctionArgumentsAnalyzer.php | 2 +- .../Call/ClassTemplateParamCollector.php | 2 +- .../Expression/Call/FunctionCallAnalyzer.php | 2 +- .../Call/Method/AtomicMethodCallAnalyzer.php | 2 +- .../Expression/Call/StaticCallAnalyzer.php | 2 +- .../Statements/Expression/CallAnalyzer.php | 6 ++-- .../Fetch/ClassConstFetchAnalyzer.php | 2 +- .../Fetch/StaticPropertyFetchAnalyzer.php | 4 +-- .../Analyzer/Statements/ReturnAnalyzer.php | 2 +- .../Internal/Analyzer/StatementsAnalyzer.php | 2 +- src/Psalm/Internal/Codebase/Analyzer.php | 28 +++++++++---------- src/Psalm/Internal/Codebase/ClassLikes.php | 15 +++++----- src/Psalm/Internal/Codebase/Properties.php | 10 +++---- src/Psalm/Internal/Codebase/Scanner.php | 4 +-- .../Internal/Diff/ClassStatementsDiffer.php | 2 +- src/Psalm/Internal/Diff/FileDiffer.php | 2 +- .../Internal/Diff/FileStatementsDiffer.php | 2 +- .../Diff/NamespaceStatementsDiffer.php | 2 +- .../ExecutionEnvironment/GitInfoCollector.php | 4 +-- .../FileManipulationBuffer.php | 4 +-- src/Psalm/Internal/Fork/Pool.php | 4 +-- .../LanguageServer/Server/TextDocument.php | 6 ++-- .../PhpVisitor/PartialParserVisitor.php | 4 +-- .../Internal/PhpVisitor/ReflectorVisitor.php | 2 +- .../PhpVisitor/SimpleNameResolver.php | 2 +- .../ArrayReduceReturnTypeProvider.php | 2 +- .../Internal/Provider/StatementsProvider.php | 2 +- src/Psalm/Internal/Scanner/DocblockParser.php | 6 ++-- .../Type/SimpleAssertionReconciler.php | 4 +-- src/Psalm/Internal/Type/TypeParser.php | 2 +- src/Psalm/Storage/Assertion.php | 2 +- src/Psalm/Type/Reconciler.php | 2 +- src/psalm-refactor.php | 2 +- src/psalter.php | 2 +- tests/CodebaseTest.php | 2 +- tests/LanguageServer/SymbolLookupTest.php | 2 +- tests/fixtures/stubs/class_alias.php | 2 +- 46 files changed, 100 insertions(+), 99 deletions(-) diff --git a/examples/TemplateScanner.php b/examples/TemplateScanner.php index 2575d661a..c95cb1b06 100644 --- a/examples/TemplateScanner.php +++ b/examples/TemplateScanner.php @@ -50,7 +50,7 @@ class TemplateScanner extends Psalm\Internal\Scanner\FileScanner throw new \InvalidArgumentException('Could not interpret doc comment correctly'); } - list($fq_class_name) = explode('::', $matches[1]); + [$fq_class_name] = explode('::', $matches[1]); $codebase->scanner->queueClassLikeForScanning( $fq_class_name, diff --git a/src/Psalm/Codebase.php b/src/Psalm/Codebase.php index 3e8b6f7d2..dfec021f1 100644 --- a/src/Psalm/Codebase.php +++ b/src/Psalm/Codebase.php @@ -608,7 +608,7 @@ class Codebase */ public function findReferencesToProperty(string $property_id) { - list($fq_class_name, $property_name) = explode('::', $property_id); + [$fq_class_name, $property_name] = explode('::', $property_id); return $this->file_reference_provider->getClassPropertyLocations( strtolower($fq_class_name) . '::' . $property_name @@ -1055,7 +1055,7 @@ class Codebase return 'getSignature(true); } - list(, $symbol_name) = explode('::', $symbol); + [, $symbol_name] = explode('::', $symbol); if (strpos($symbol, '$') !== false) { $storage = $this->properties->getStorage($symbol); @@ -1063,7 +1063,7 @@ class Codebase return 'getInfo() . ' ' . $symbol_name; } - list($fq_classlike_name, $const_name) = explode('::', $symbol); + [$fq_classlike_name, $const_name] = explode('::', $symbol); $class_constants = $this->classlikes->getConstantsForClass( $fq_classlike_name, @@ -1149,7 +1149,7 @@ class Codebase return $storage->location; } - list($fq_classlike_name, $const_name) = explode('::', $symbol); + [$fq_classlike_name, $const_name] = explode('::', $symbol); $class_constants = $this->classlikes->getConstantsForClass( $fq_classlike_name, @@ -1209,7 +1209,7 @@ class Codebase $offset = $position->toOffset($file_contents); - list($reference_map, $type_map) = $this->analyzer->getMapsForFile($file_path); + [$reference_map, $type_map] = $this->analyzer->getMapsForFile($file_path); $reference = null; @@ -1222,7 +1222,7 @@ class Codebase ksort($reference_map); - foreach ($reference_map as $start_pos => list($end_pos, $possible_reference)) { + foreach ($reference_map as $start_pos => [$end_pos, $possible_reference]) { if ($offset < $start_pos) { break; } @@ -1262,7 +1262,7 @@ class Codebase $offset = $position->toOffset($file_contents); - list(, , $argument_map) = $this->analyzer->getMapsForFile($file_path); + [, , $argument_map] = $this->analyzer->getMapsForFile($file_path); $reference = null; $argument_number = null; @@ -1276,7 +1276,7 @@ class Codebase ksort($argument_map); - foreach ($argument_map as $start_pos => list($end_pos, $possible_reference, $possible_argument_number)) { + foreach ($argument_map as $start_pos => [$end_pos, $possible_reference, $possible_argument_number]) { if ($offset < $start_pos) { break; } @@ -1377,7 +1377,7 @@ class Codebase $offset = $position->toOffset($file_contents); - list($reference_map, $type_map) = $this->analyzer->getMapsForFile($file_path); + [$reference_map, $type_map] = $this->analyzer->getMapsForFile($file_path); if (!$reference_map && !$type_map) { return null; @@ -1385,7 +1385,7 @@ class Codebase krsort($type_map); - foreach ($type_map as $start_pos => list($end_pos_excluding_whitespace, $possible_type)) { + foreach ($type_map as $start_pos => [$end_pos_excluding_whitespace, $possible_type]) { if ($offset < $start_pos) { continue; } @@ -1411,7 +1411,7 @@ class Codebase } } - foreach ($reference_map as $start_pos => list($end_pos, $possible_reference)) { + foreach ($reference_map as $start_pos => [$end_pos, $possible_reference]) { if ($offset < $start_pos || $possible_reference[0] !== '*') { continue; } diff --git a/src/Psalm/DocComment.php b/src/Psalm/DocComment.php index 5a2889f3b..6eeb0ddf8 100644 --- a/src/Psalm/DocComment.php +++ b/src/Psalm/DocComment.php @@ -100,7 +100,7 @@ class DocComment if ($preserve_format) { foreach ($lines as $m => $line) { if (preg_match('/^\s?@([\w\-:]+)[\t ]*(.*)$/sm', $line, $matches)) { - list($full_match, $type, $data) = $matches; + [$full_match, $type, $data] = $matches; $docblock = str_replace($full_match, '', $docblock); @@ -121,7 +121,7 @@ class DocComment $docblock = preg_replace('/^\s?@([\w\-:]+)\s*([^\n]*)/m', '', $docblock); /** @var string[] $match */ foreach ($matches as $m => $match) { - list($_, $type, $data) = $match; + [$_, $type, $data] = $match; if (empty($special[$type])) { $special[$type] = []; diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index 34aaeb284..8e7396534 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -1007,7 +1007,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer if (isset($storage->overridden_property_ids[$property_name])) { foreach ($storage->overridden_property_ids[$property_name] as $overridden_property_id) { - list($guide_class_name) = explode('::$', $overridden_property_id); + [$guide_class_name] = explode('::$', $overridden_property_id); $guide_class_storage = $codebase->classlike_storage_provider->get($guide_class_name); $guide_property_storage = $guide_class_storage->properties[$property_name]; @@ -1226,7 +1226,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer } if ($codebase->diff_methods && $method_already_analyzed && $property->location) { - list($start, $end) = $property->location->getSelectionBounds(); + [$start, $end] = $property->location->getSelectionBounds(); $existing_issues = $codebase->analyzer->getExistingIssuesForFile( $this->getFilePath(), @@ -1396,7 +1396,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer ); foreach ($uninitialized_properties as $property_id => $property_storage) { - list(,$property_name) = explode('::$', $property_id); + [, $property_name] = explode('::$', $property_id); if (!isset($method_context->vars_in_scope['$this->' . $property_name])) { $end_type = Type::getVoid(); diff --git a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php index 4b1752ce5..d11f677f6 100644 --- a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php @@ -556,7 +556,7 @@ abstract class ClassLikeAnalyzer extends SourceAnalyzer implements StatementsSou array $suppressed_issues, $emit_issues = true ) { - list($fq_class_name, $property_name) = explode('::$', (string)$property_id); + [$fq_class_name, $property_name] = explode('::$', (string)$property_id); $codebase = $source->getCodebase(); diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index 2fa39b2f8..4c168976b 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -530,7 +530,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer } if ($storage->signature_return_type && $storage->signature_return_type_location) { - list($start, $end) = $storage->signature_return_type_location->getSelectionBounds(); + [$start, $end] = $storage->signature_return_type_location->getSelectionBounds(); $codebase->analyzer->addOffsetReference( $this->getFilePath(), @@ -951,7 +951,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer $unused_params = []; - foreach ($statements_analyzer->getUnusedVarLocations() as list($var_name, $original_location)) { + foreach ($statements_analyzer->getUnusedVarLocations() as [$var_name, $original_location]) { if (!array_key_exists(substr($var_name, 1), $storage->param_lookup)) { continue; } @@ -1089,7 +1089,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer $referenced_type = clone $referenced_type; $referenced_type->removeType('null'); } - list($start, $end) = $signature_type_location->getSelectionBounds(); + [$start, $end] = $signature_type_location->getSelectionBounds(); $codebase->analyzer->addOffsetReference( $this->getFilePath(), $start, diff --git a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php index a808c9580..3ac055a49 100644 --- a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php @@ -1333,7 +1333,7 @@ class ProjectAnalyzer throw new \UnexpectedValueException('Expecting a version number in the format x.y'); } - list($php_major_version, $php_minor_version) = explode('.', $version); + [$php_major_version, $php_minor_version] = explode('.', $version); $php_major_version = (int) $php_major_version; $php_minor_version = (int) $php_minor_version; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/StaticPropertyAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/StaticPropertyAssignmentAnalyzer.php index f70af9c78..3642cdd9b 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/StaticPropertyAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/StaticPropertyAssignmentAnalyzer.php @@ -116,8 +116,8 @@ class StaticPropertyAssignmentAnalyzer if (!$moved_class) { foreach ($codebase->property_transforms as $original_pattern => $transformation) { if ($declaring_property_id === $original_pattern) { - list($old_declaring_fq_class_name) = explode('::$', $declaring_property_id); - list($new_fq_class_name, $new_property_name) = explode('::$', $transformation); + [$old_declaring_fq_class_name] = explode('::$', $declaring_property_id); + [$new_fq_class_name, $new_property_name] = explode('::$', $transformation); $file_manipulations = []; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php index 36247d44b..f17e90268 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php @@ -885,7 +885,7 @@ class ArgumentAnalyzer $has_valid_method = false; foreach ($function_id_parts as $function_id_part) { - list($callable_fq_class_name, $method_name) = explode('::', $function_id_part); + [$callable_fq_class_name, $method_name] = explode('::', $function_id_part); switch ($callable_fq_class_name) { case 'self': @@ -1212,7 +1212,7 @@ class ArgumentAnalyzer ); if (strpos($cased_method_id, '::')) { - list($fq_classlike_name, $cased_method_name) = explode('::', $cased_method_id); + [$fq_classlike_name, $cased_method_name] = explode('::', $cased_method_id); $method_name = strtolower($cased_method_name); $class_storage = $codebase->classlike_storage_provider->get($fq_classlike_name); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php index 124dd1be8..8bd9f7efd 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php @@ -618,7 +618,7 @@ class ArrayFunctionArgumentsAnalyzer $function_id_parts = explode('&', $function_id); foreach ($function_id_parts as $function_id_part) { - list($callable_fq_class_name, $method_name) = explode('::', $function_id_part); + [$callable_fq_class_name, $method_name] = explode('::', $function_id_part); switch ($callable_fq_class_name) { case 'self': diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php index 712a82818..547409406 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php @@ -196,7 +196,7 @@ class ClassTemplateParamCollector } foreach ($template_types as $type_name => $type_map) { - foreach ($type_map as list($type)) { + foreach ($type_map as [$type]) { foreach ($candidate_class_storages as $candidate_class_storage) { if ($candidate_class_storage !== $static_class_storage && isset($e[$candidate_class_storage->name][$type_name]) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php index 92139b790..8d19dbf26 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php @@ -117,7 +117,7 @@ class FunctionCallAnalyzer extends CallAnalyzer $byref_uses = []; if ($function_name instanceof PhpParser\Node\Expr) { - list($expr_function_exists, $expr_function_name, $expr_function_params, $byref_uses) + [$expr_function_exists, $expr_function_name, $expr_function_params, $byref_uses] = self::getAnalyzeNamedExpression( $statements_analyzer, $codebase, diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php index 797cb5379..a4a2bc1f7 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php @@ -595,7 +595,7 @@ class AtomicMethodCallAnalyzer extends CallAnalyzer } if ($context->collect_initializations && $context->calling_method_id) { - list($calling_method_class) = explode('::', $context->calling_method_id); + [$calling_method_class] = explode('::', $context->calling_method_id); $codebase->file_reference_provider->addMethodReferenceToClassMember( $calling_method_class . '::__construct', strtolower((string) $method_id) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php index 2328e092f..3817ddb22 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php @@ -1251,7 +1251,7 @@ class StaticCallAnalyzer extends CallAnalyzer ) { $new_method_id = substr($transformation, 0, -4); $old_declaring_fq_class_name = $declaring_method_id->fq_class_name; - list($new_fq_class_name, $new_method_name) = explode('::', $new_method_id); + [$new_fq_class_name, $new_method_name] = explode('::', $new_method_id); if ($codebase->classlikes->handleClassLikeReferenceInMigration( $codebase, diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php index 4ad9725aa..90bb1ba2b 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php @@ -399,7 +399,7 @@ class CallAnalyzer } } elseif ($declaring_class_storage->template_types) { foreach ($declaring_class_storage->template_types as $template_name => $type_map) { - foreach ($type_map as $key => list($type)) { + foreach ($type_map as $key => [$type]) { $template_types[$template_name][$key] = [$type]; } } @@ -762,7 +762,7 @@ class CallAnalyzer if ($type_assertions) { foreach (($statements_analyzer->getTemplateTypeMap() ?: []) as $template_name => $map) { - foreach ($map as $ref => list($type)) { + foreach ($map as $ref => [$type]) { $template_type_map[$template_name][$ref] = [ new Type\Union([ new Type\Atomic\TTemplateParam( @@ -844,7 +844,7 @@ class CallAnalyzer ) : void { if ($template_result->upper_bounds && $template_result->lower_bounds) { foreach ($template_result->lower_bounds as $template_name => $defining_map) { - foreach ($defining_map as $defining_id => list($lower_bound_type)) { + foreach ($defining_map as $defining_id => [$lower_bound_type]) { if (isset($template_result->upper_bounds[$template_name][$defining_id])) { $upper_bound_type = $template_result->upper_bounds[$template_name][$defining_id][0]; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ClassConstFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ClassConstFetchAnalyzer.php index c7f99e504..aa0682a9a 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ClassConstFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ClassConstFetchAnalyzer.php @@ -281,7 +281,7 @@ class ClassConstFetchAnalyzer if ($codebase->alter_code && !$moved_class) { foreach ($codebase->class_constant_transforms as $original_pattern => $transformation) { if ($declaring_const_id === $original_pattern) { - list($new_fq_class_name, $new_const_name) = explode('::', $transformation); + [$new_fq_class_name, $new_const_name] = explode('::', $transformation); $file_manipulations = []; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php index b00bafc9e..bff96c901 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php @@ -290,8 +290,8 @@ class StaticPropertyFetchAnalyzer if (!$moved_class) { foreach ($codebase->property_transforms as $original_pattern => $transformation) { if ($declaring_property_id === $original_pattern) { - list($old_declaring_fq_class_name) = explode('::$', $declaring_property_id); - list($new_fq_class_name, $new_property_name) = explode('::$', $transformation); + [$old_declaring_fq_class_name] = explode('::$', $declaring_property_id); + [$new_fq_class_name, $new_property_name] = explode('::$', $transformation); $file_manipulations = []; diff --git a/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php index 524796b87..6c900eee1 100644 --- a/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php @@ -224,7 +224,7 @@ class ReturnAnalyzer ); if ($storage instanceof \Psalm\Storage\MethodStorage) { - list($fq_class_name, $method_name) = explode('::', $cased_method_id); + [$fq_class_name, $method_name] = explode('::', $cased_method_id); $class_storage = $codebase->classlike_storage_provider->get($fq_class_name); diff --git a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php index 6ecabe41b..dac97558c 100644 --- a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php @@ -678,7 +678,7 @@ class StatementsAnalyzer extends SourceAnalyzer implements StatementsSource $unused_var_remover = new Statements\UnusedAssignmentRemover(); - foreach ($this->unused_var_locations as $hash => list($var_id, $original_location)) { + foreach ($this->unused_var_locations as $hash => [$var_id, $original_location]) { if (substr($var_id, 0, 2) === '$_' || isset($this->used_var_locations[$hash])) { continue; } diff --git a/src/Psalm/Internal/Codebase/Analyzer.php b/src/Psalm/Internal/Codebase/Analyzer.php index 8d6fc95dd..7a7b14603 100644 --- a/src/Psalm/Internal/Codebase/Analyzer.php +++ b/src/Psalm/Internal/Codebase/Analyzer.php @@ -546,7 +546,7 @@ class Analyzer $this->analyzed_methods = array_merge($pool_data['analyzed_methods'], $this->analyzed_methods); - foreach ($pool_data['mixed_counts'] as $file_path => list($mixed_count, $nonmixed_count)) { + foreach ($pool_data['mixed_counts'] as $file_path => [$mixed_count, $nonmixed_count]) { if (!isset($this->mixed_counts[$file_path])) { $this->mixed_counts[$file_path] = [$mixed_count, $nonmixed_count]; } else { @@ -580,7 +580,7 @@ class Analyzer } foreach ($pool_data['file_maps'] as $file_path => $file_maps) { - list($reference_map, $type_map, $argument_map) = $file_maps; + [$reference_map, $type_map, $argument_map] = $file_maps; $this->reference_map[$file_path] = $reference_map; $this->type_map[$file_path] = $type_map; $this->argument_map[$file_path] = $argument_map; @@ -615,7 +615,7 @@ class Analyzer $this->existing_issues = $codebase->file_reference_provider->getExistingIssues(); $file_maps = $codebase->file_reference_provider->getFileMaps(); - foreach ($file_maps as $file_path => list($reference_map, $type_map, $argument_map)) { + foreach ($file_maps as $file_path => [$reference_map, $type_map, $argument_map]) { $this->reference_map[$file_path] = $reference_map; $this->type_map[$file_path] = $type_map; $this->argument_map[$file_path] = $argument_map; @@ -658,7 +658,7 @@ class Analyzer continue; } - list($base_class, $trait) = explode('&', $changed_member); + [$base_class, $trait] = explode('&', $changed_member); foreach ($all_referencing_methods as $member_id => $_) { if (strpos($member_id, $base_class . '::') !== 0) { @@ -913,7 +913,7 @@ class Analyzer $matched = false; - foreach ($file_diff_map as list($from, $to, $file_offset, $line_offset)) { + foreach ($file_diff_map as [$from, $to, $file_offset, $line_offset]) { if ($issue_data->from >= $from && $issue_data->from <= $to && !$matched @@ -949,12 +949,12 @@ class Analyzer $first_diff_offset = $file_diff_map[0][0]; $last_diff_offset = $file_diff_map[count($file_diff_map) - 1][1]; - foreach ($reference_map as $reference_from => list($reference_to, $tag)) { + foreach ($reference_map as $reference_from => [$reference_to, $tag]) { if ($reference_to < $first_diff_offset || $reference_from > $last_diff_offset) { continue; } - foreach ($file_diff_map as list($from, $to, $file_offset)) { + foreach ($file_diff_map as [$from, $to, $file_offset]) { if ($reference_from >= $from && $reference_from <= $to) { unset($reference_map[$reference_from]); $reference_map[$reference_from += $file_offset] = [ @@ -981,12 +981,12 @@ class Analyzer $first_diff_offset = $file_diff_map[0][0]; $last_diff_offset = $file_diff_map[count($file_diff_map) - 1][1]; - foreach ($type_map as $type_from => list($type_to, $tag)) { + foreach ($type_map as $type_from => [$type_to, $tag]) { if ($type_to < $first_diff_offset || $type_from > $last_diff_offset) { continue; } - foreach ($file_diff_map as list($from, $to, $file_offset)) { + foreach ($file_diff_map as [$from, $to, $file_offset]) { if ($type_from >= $from && $type_from <= $to) { unset($type_map[$type_from]); $type_map[$type_from += $file_offset] = [ @@ -1013,12 +1013,12 @@ class Analyzer $first_diff_offset = $file_diff_map[0][0]; $last_diff_offset = $file_diff_map[count($file_diff_map) - 1][1]; - foreach ($argument_map as $argument_from => list($argument_to, $method_id, $argument_number)) { + foreach ($argument_map as $argument_from => [$argument_to, $method_id, $argument_number]) { if ($argument_to < $first_diff_offset || $argument_from > $last_diff_offset) { continue; } - foreach ($file_diff_map as list($from, $to, $file_offset)) { + foreach ($file_diff_map as [$from, $to, $file_offset]) { if ($argument_from >= $from && $argument_from <= $to) { unset($argument_map[$argument_from]); $argument_map[$argument_from += $file_offset] = [ @@ -1258,7 +1258,7 @@ class Analyzer continue; } - list($path_mixed_count, $path_nonmixed_count) = $counts; + [$path_mixed_count, $path_nonmixed_count] = $counts; if (isset($this->mixed_counts[$file_path])) { $mixed_count += $path_mixed_count; @@ -1284,7 +1284,7 @@ class Analyzer } } - list($mixed_count, $nonmixed_count) = $this->getTotalTypeCoverage($codebase); + [$mixed_count, $nonmixed_count] = $this->getTotalTypeCoverage($codebase); $total = $mixed_count + $nonmixed_count; @@ -1327,7 +1327,7 @@ class Analyzer foreach ($all_deep_scanned_files as $file_path => $_) { if (isset($this->mixed_counts[$file_path])) { - list($path_mixed_count, $path_nonmixed_count) = $this->mixed_counts[$file_path]; + [$path_mixed_count, $path_nonmixed_count] = $this->mixed_counts[$file_path]; if ($path_mixed_count + $path_nonmixed_count) { $stats .= number_format(100 * $path_nonmixed_count / ($path_mixed_count + $path_nonmixed_count), 0) diff --git a/src/Psalm/Internal/Codebase/ClassLikes.php b/src/Psalm/Internal/Codebase/ClassLikes.php index 63b9a2165..776cf2191 100644 --- a/src/Psalm/Internal/Codebase/ClassLikes.php +++ b/src/Psalm/Internal/Codebase/ClassLikes.php @@ -904,7 +904,7 @@ class ClassLikes continue; } - list($destination_fq_class_name, $destination_name) = explode('::', $destination); + [$destination_fq_class_name, $destination_name] = explode('::', $destination); try { $classlike_storage = $this->classlike_storage_provider->get($destination_fq_class_name); @@ -984,8 +984,8 @@ class ClassLikes continue; } - list($source_fq_class_name) = explode('::$', $source); - list($destination_fq_class_name, $destination_name) = explode('::$', $destination); + [$source_fq_class_name] = explode('::$', $source); + [$destination_fq_class_name, $destination_name] = explode('::$', $destination); $source_classlike_storage = $this->classlike_storage_provider->get($source_fq_class_name); $destination_classlike_storage = $this->classlike_storage_provider->get($destination_fq_class_name); @@ -1079,8 +1079,8 @@ class ClassLikes $code_migrations = []; foreach ($codebase->class_constants_to_move as $source => $destination) { - list($source_fq_class_name, $source_const_name) = explode('::', $source); - list($destination_fq_class_name, $destination_name) = explode('::', $destination); + [$source_fq_class_name, $source_const_name] = explode('::', $source); + [$destination_fq_class_name, $destination_name] = explode('::', $destination); $source_classlike_storage = $this->classlike_storage_provider->get($source_fq_class_name); $destination_classlike_storage = $this->classlike_storage_provider->get($destination_fq_class_name); @@ -2443,14 +2443,15 @@ class ClassLikes */ public function addThreadData(array $thread_data) { - list( + [ $existing_classlikes_lc, $existing_classes_lc, $existing_traits_lc, $existing_traits, $existing_interfaces_lc, $existing_interfaces, - $existing_classes) = $thread_data; + $existing_classes + ] = $thread_data; $this->existing_classlikes_lc = array_merge($existing_classlikes_lc, $this->existing_classlikes_lc); $this->existing_classes_lc = array_merge($existing_classes_lc, $this->existing_classes_lc); diff --git a/src/Psalm/Internal/Codebase/Properties.php b/src/Psalm/Internal/Codebase/Properties.php index f5369e005..3deb8d88c 100644 --- a/src/Psalm/Internal/Codebase/Properties.php +++ b/src/Psalm/Internal/Codebase/Properties.php @@ -77,7 +77,7 @@ class Properties // remove trailing backslash if it exists $property_id = preg_replace('/^\\\\/', '', $property_id); - list($fq_class_name, $property_name) = explode('::$', $property_id); + [$fq_class_name, $property_name] = explode('::$', $property_id); $fq_class_name_lc = strtolower($fq_class_name); if ($this->property_existence_provider->has($fq_class_name)) { @@ -163,7 +163,7 @@ class Properties */ public function getDeclaringClassForProperty($property_id, bool $read_mode, StatementsSource $source = null) { - list($fq_class_name, $property_name) = explode('::$', $property_id); + [$fq_class_name, $property_name] = explode('::$', $property_id); if ($this->property_existence_provider->has($fq_class_name)) { if ($this->property_existence_provider->doesPropertyExist( @@ -193,7 +193,7 @@ class Properties */ public function getAppearingClassForProperty($property_id, bool $read_mode, StatementsSource $source = null) { - list($fq_class_name, $property_name) = explode('::$', $property_id); + [$fq_class_name, $property_name] = explode('::$', $property_id); if ($this->property_existence_provider->has($fq_class_name)) { if ($this->property_existence_provider->doesPropertyExist( @@ -226,7 +226,7 @@ class Properties // remove trailing backslash if it exists $property_id = preg_replace('/^\\\\/', '', $property_id); - list($fq_class_name, $property_name) = explode('::$', $property_id); + [$fq_class_name, $property_name] = explode('::$', $property_id); $class_storage = $this->classlike_storage_provider->get($fq_class_name); @@ -256,7 +256,7 @@ class Properties // remove trailing backslash if it exists $property_id = preg_replace('/^\\\\/', '', $property_id); - list($fq_class_name, $property_name) = explode('::$', $property_id); + [$fq_class_name, $property_name] = explode('::$', $property_id); if ($this->property_type_provider->has($fq_class_name)) { $property_type = $this->property_type_provider->getPropertyType( diff --git a/src/Psalm/Internal/Codebase/Scanner.php b/src/Psalm/Internal/Codebase/Scanner.php index e9e293b83..10d71c05d 100644 --- a/src/Psalm/Internal/Codebase/Scanner.php +++ b/src/Psalm/Internal/Codebase/Scanner.php @@ -813,7 +813,7 @@ class Scanner */ public function addThreadData(array $thread_data) { - list( + [ $files_to_scan, $files_to_deep_scan, $classes_to_scan, @@ -823,7 +823,7 @@ class Scanner $deep_scanned_classlike_files, $scanned_files, $reflected_classlikes_lc - ) = $thread_data; + ] = $thread_data; $this->files_to_scan = array_merge($files_to_scan, $this->files_to_scan); $this->files_to_deep_scan = array_merge($files_to_deep_scan, $this->files_to_deep_scan); diff --git a/src/Psalm/Internal/Diff/ClassStatementsDiffer.php b/src/Psalm/Internal/Diff/ClassStatementsDiffer.php index 637ff90db..81e68d314 100644 --- a/src/Psalm/Internal/Diff/ClassStatementsDiffer.php +++ b/src/Psalm/Internal/Diff/ClassStatementsDiffer.php @@ -34,7 +34,7 @@ class ClassStatementsDiffer extends AstDiffer { $diff_map = []; - list($trace, $x, $y, $bc) = self::calculateTrace( + [$trace, $x, $y, $bc] = self::calculateTrace( /** * @param string $a_code * @param string $b_code diff --git a/src/Psalm/Internal/Diff/FileDiffer.php b/src/Psalm/Internal/Diff/FileDiffer.php index 3b501de1b..c3b471141 100644 --- a/src/Psalm/Internal/Diff/FileDiffer.php +++ b/src/Psalm/Internal/Diff/FileDiffer.php @@ -124,7 +124,7 @@ class FileDiffer { $a = explode("\n", $a_code); $b = explode("\n", $b_code); - list($trace, $x, $y) = self::calculateTrace($a, $b); + [$trace, $x, $y] = self::calculateTrace($a, $b); $diff = self::coalesceReplacements(self::extractDiff($trace, $x, $y, $a, $b)); diff --git a/src/Psalm/Internal/Diff/FileStatementsDiffer.php b/src/Psalm/Internal/Diff/FileStatementsDiffer.php index 4494251db..f8e2d9d40 100644 --- a/src/Psalm/Internal/Diff/FileStatementsDiffer.php +++ b/src/Psalm/Internal/Diff/FileStatementsDiffer.php @@ -29,7 +29,7 @@ class FileStatementsDiffer extends AstDiffer */ public static function diff(array $a, array $b, $a_code, $b_code) { - list($trace, $x, $y, $bc) = self::calculateTrace( + [$trace, $x, $y, $bc] = self::calculateTrace( /** * @param string $a_code * @param string $b_code diff --git a/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php b/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php index ae0e2b469..2d1527b24 100644 --- a/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php +++ b/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php @@ -30,7 +30,7 @@ class NamespaceStatementsDiffer extends AstDiffer */ public static function diff($name, array $a, array $b, $a_code, $b_code) { - list($trace, $x, $y, $bc) = self::calculateTrace( + [$trace, $x, $y, $bc] = self::calculateTrace( /** * @param string $a_code * @param string $b_code diff --git a/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php b/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php index a4806c04c..4a6b04cbb 100644 --- a/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php +++ b/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php @@ -113,7 +113,7 @@ class GitInfoCollector foreach ($remotesResult as $result) { if (strpos($result, ' ') !== false) { - list($remote) = explode(' ', $result, 2); + [$remote] = explode(' ', $result, 2); $results[] = $remote; } @@ -127,7 +127,7 @@ class GitInfoCollector foreach ($results as $result) { if (strpos($result, "\t") !== false) { - list($name, $url) = explode("\t", $result, 2); + [$name, $url] = explode("\t", $result, 2); $remote = new RemoteInfo(); $remotes[] = $remote->setName(trim($name))->setUrl(trim($url)); diff --git a/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php b/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php index 43e57d702..f4a5b05a6 100644 --- a/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php +++ b/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php @@ -195,7 +195,7 @@ class FileManipulationBuffer $code_migration_manipulations = []; foreach (self::$code_migrations as $code_migration) { - list($start_offset, $middle_offset) = self::getCodeOffsets( + [$start_offset, $middle_offset] = self::getCodeOffsets( $code_migration->source_file_path, $code_migration->source_start, $code_migration->source_end @@ -217,7 +217,7 @@ class FileManipulationBuffer $code_migration_manipulations[$code_migration->source_file_path][] = $delete_file_manipulation; - list($destination_start_offset) = self::getCodeOffsets( + [$destination_start_offset] = self::getCodeOffsets( $code_migration->destination_file_path, $code_migration->destination_start, $code_migration->destination_start diff --git a/src/Psalm/Internal/Fork/Pool.php b/src/Psalm/Internal/Fork/Pool.php index ca16c21d5..1a7ea35d6 100644 --- a/src/Psalm/Internal/Fork/Pool.php +++ b/src/Psalm/Internal/Fork/Pool.php @@ -254,7 +254,7 @@ class Pool */ private static function streamForParent(array $sockets) { - list($for_read, $for_write) = $sockets; + [$for_read, $for_write] = $sockets; // The parent will not use the write channel, so it // must be closed to prevent deadlock. @@ -280,7 +280,7 @@ class Pool */ private static function streamForChild(array $sockets) { - list($for_read, $for_write) = $sockets; + [$for_read, $for_write] = $sockets; // The while will not use the read channel, so it must // be closed to prevent deadlock. diff --git a/src/Psalm/Internal/LanguageServer/Server/TextDocument.php b/src/Psalm/Internal/LanguageServer/Server/TextDocument.php index 057ec2bf9..5ea2f57e6 100644 --- a/src/Psalm/Internal/LanguageServer/Server/TextDocument.php +++ b/src/Psalm/Internal/LanguageServer/Server/TextDocument.php @@ -167,7 +167,7 @@ class TextDocument return new Success(null); } - list($reference) = $reference_location; + [$reference] = $reference_location; $code_location = $this->codebase->getSymbolLocation($file_path, $reference); @@ -211,7 +211,7 @@ class TextDocument return new Success(null); } - list($reference, $range) = $reference_location; + [$reference, $range] = $reference_location; $symbol_information = $this->codebase->getSymbolInformation($file_path, $reference); @@ -260,7 +260,7 @@ class TextDocument return new Success([]); } - list($recent_type, $gap, $offset) = $completion_data; + [$recent_type, $gap, $offset] = $completion_data; if ($gap === '->' || $gap === '::') { $completion_items = $this->codebase->getCompletionItemsForClassishThing($recent_type, $gap); diff --git a/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php b/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php index 1d3fea84b..edbfa5bc7 100644 --- a/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php @@ -82,7 +82,7 @@ class PartialParserVisitor extends PhpParser\NodeVisitorAbstract implements PhpP $line_offset = 0; - foreach ($this->offset_map as list($a_s, $a_e, $b_s, $b_e, $line_diff)) { + foreach ($this->offset_map as [$a_s, $a_e, $b_s, $b_e, $line_diff]) { if ($a_s > $stmt_end_pos) { break; } @@ -107,7 +107,7 @@ class PartialParserVisitor extends PhpParser\NodeVisitorAbstract implements PhpP ) { if ($node instanceof PhpParser\Node\Stmt\ClassMethod) { if ($a_s >= $stmt_start_pos && $a_e <= $stmt_end_pos) { - foreach ($this->offset_map as list($a_s2, $a_e2, $b_s2, $b_e2)) { + foreach ($this->offset_map as [$a_s2, $a_e2, $b_s2, $b_e2]) { if ($a_s2 > $stmt_end_pos) { break; } diff --git a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php index 2ec748b8b..6671b0cff 100644 --- a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php @@ -904,7 +904,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse continue; } - list($callable_fqcln) = explode('::', $potential_method_id); + [$callable_fqcln] = explode('::', $potential_method_id); if (!in_array(strtolower($callable_fqcln), ['self', 'parent', 'static'], true)) { $this->codebase->scanner->queueClassLikeForScanning( diff --git a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php index 72326fe5f..0a48b64d7 100644 --- a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php +++ b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php @@ -42,7 +42,7 @@ class SimpleNameResolver extends NodeVisitorAbstract public function __construct(ErrorHandler $errorHandler, array $offset_map = null) { if ($offset_map) { - foreach ($offset_map as list(, , $b_s, $b_e)) { + foreach ($offset_map as [, , $b_s, $b_e]) { if ($this->start_change === null) { $this->start_change = $b_s; } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php index 59b7d5711..ebeaaeb2d 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php @@ -218,7 +218,7 @@ class ArrayReduceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn $mapping_function_id_part = \substr($mapping_function_id_part, 1); } - list($callable_fq_class_name, $method_name) = explode('::', $mapping_function_id_part); + [$callable_fq_class_name, $method_name] = explode('::', $mapping_function_id_part); if (in_array($callable_fq_class_name, ['self', 'static', 'parent'], true)) { continue; diff --git a/src/Psalm/Internal/Provider/StatementsProvider.php b/src/Psalm/Internal/Provider/StatementsProvider.php index 048ded980..2ef809a90 100644 --- a/src/Psalm/Internal/Provider/StatementsProvider.php +++ b/src/Psalm/Internal/Provider/StatementsProvider.php @@ -173,7 +173,7 @@ class StatementsProvider ); if ($existing_file_contents && $existing_statements) { - list($unchanged_members, $unchanged_signature_members, $changed_members, $diff_map) + [$unchanged_members, $unchanged_signature_members, $changed_members, $diff_map] = \Psalm\Internal\Diff\FileStatementsDiffer::diff( $existing_statements, $stmts, diff --git a/src/Psalm/Internal/Scanner/DocblockParser.php b/src/Psalm/Internal/Scanner/DocblockParser.php index 7828a5b22..13646eabe 100644 --- a/src/Psalm/Internal/Scanner/DocblockParser.php +++ b/src/Psalm/Internal/Scanner/DocblockParser.php @@ -64,10 +64,10 @@ class DocblockParser if (preg_match('/^[ \t]*\*?\s*@([\w\-:]+)[\t ]*(.*)$/sm', $line, $matches, PREG_OFFSET_CAPTURE)) { /** @var array $matches */ - list($_, $type_info, $data_info) = $matches; + [$_, $type_info, $data_info] = $matches; - list($type) = $type_info; - list($data, $data_offset) = $data_info; + [$type] = $type_info; + [$data, $data_offset] = $data_info; if (strpos($data, '*')) { $data = rtrim(preg_replace('/^[ \t]*\*\s*$/m', '', $data)); diff --git a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php index bb07a0988..0c120fca9 100644 --- a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php @@ -1382,7 +1382,7 @@ class SimpleAssertionReconciler extends \Psalm\Type\Reconciler string $assertion ) : Union { if (strpos($assertion, '::')) { - list($fq_classlike_name, $const_name) = explode('::', $assertion); + [$fq_classlike_name, $const_name] = explode('::', $assertion); $class_constant_type = $codebase->classlikes->getConstantForClass( $fq_classlike_name, @@ -1429,7 +1429,7 @@ class SimpleAssertionReconciler extends \Psalm\Type\Reconciler $is_class_string = false; if (strpos($assertion, '::class')) { - list($assertion) = explode('::', $assertion); + [$assertion] = explode('::', $assertion); $is_class_string = true; } diff --git a/src/Psalm/Internal/Type/TypeParser.php b/src/Psalm/Internal/Type/TypeParser.php index 763c34f45..165a5dcd9 100644 --- a/src/Psalm/Internal/Type/TypeParser.php +++ b/src/Psalm/Internal/Type/TypeParser.php @@ -847,7 +847,7 @@ class TypeParser } if (strpos($parse_tree->value, '::')) { - list($fq_classlike_name, $const_name) = explode('::', $parse_tree->value); + [$fq_classlike_name, $const_name] = explode('::', $parse_tree->value); if (isset($template_type_map[$fq_classlike_name]) && $const_name === 'class') { $first_class = array_keys($template_type_map[$fq_classlike_name])[0]; diff --git a/src/Psalm/Storage/Assertion.php b/src/Psalm/Storage/Assertion.php index daf4e901e..d2b2b5da7 100644 --- a/src/Psalm/Storage/Assertion.php +++ b/src/Psalm/Storage/Assertion.php @@ -50,7 +50,7 @@ class Assertion foreach ($rule_tokens as &$rule_token) { if (isset($template_type_map[$rule_token[0]])) { - foreach ($template_type_map[$rule_token[0]] as list($type)) { + foreach ($template_type_map[$rule_token[0]] as [$type]) { $substitute = true; $first_type = \array_values($type->getAtomicTypes())[0]; diff --git a/src/Psalm/Type/Reconciler.php b/src/Psalm/Type/Reconciler.php index 0116f4723..a8b80b04b 100644 --- a/src/Psalm/Type/Reconciler.php +++ b/src/Psalm/Type/Reconciler.php @@ -520,7 +520,7 @@ class Reconciler if (!isset($existing_keys[$base_key])) { if (strpos($base_key, '::')) { - list($fq_class_name, $const_name) = explode('::', $base_key); + [$fq_class_name, $const_name] = explode('::', $base_key); if (!$codebase->classlikes->classOrInterfaceExists($fq_class_name)) { return null; diff --git a/src/psalm-refactor.php b/src/psalm-refactor.php index f071ef4c5..7bb9e1a97 100644 --- a/src/psalm-refactor.php +++ b/src/psalm-refactor.php @@ -221,7 +221,7 @@ foreach ($args as $arg) { foreach ($last_arg_parts as $last_arg_part) { if (strpos($last_arg_part, '::')) { - list(, $identifier_name) = explode('::', $last_arg_part); + [, $identifier_name] = explode('::', $last_arg_part); $to_refactor[$last_arg_part] = $arg . '::' . $identifier_name; } else { $namespace_parts = explode('\\', $last_arg_part); diff --git a/src/psalter.php b/src/psalter.php index 7f12f5732..5d9cf8ae0 100644 --- a/src/psalter.php +++ b/src/psalter.php @@ -347,7 +347,7 @@ if (isset($options['codeowner'])) { $codeowner_files = []; - foreach ($codeowner_lines as list($path, $owners)) { + foreach ($codeowner_lines as [$path, $owners]) { if (!file_exists($path)) { continue; } diff --git a/tests/CodebaseTest.php b/tests/CodebaseTest.php index 80df3a020..56c68d335 100644 --- a/tests/CodebaseTest.php +++ b/tests/CodebaseTest.php @@ -96,7 +96,7 @@ class CodebaseTest extends TestCase */ public function getKeyValueParamsForTraversableObject(string $input, array $expected) { - list($input) = array_values(Type::parseString($input)->getAtomicTypes()); + [$input] = array_values(Type::parseString($input)->getAtomicTypes()); $expected_key_type = Type::parseString($expected[0]); $expected_value_type = Type::parseString($expected[1]); diff --git a/tests/LanguageServer/SymbolLookupTest.php b/tests/LanguageServer/SymbolLookupTest.php index 7fb204f3e..9a403a1d3 100644 --- a/tests/LanguageServer/SymbolLookupTest.php +++ b/tests/LanguageServer/SymbolLookupTest.php @@ -508,7 +508,7 @@ class SymbolLookupTest extends \Psalm\Tests\TestCase if ($expected_symbol !== null) { $this->assertNotNull($reference_location); - list($symbol, $argument_number) = $reference_location; + [$symbol, $argument_number] = $reference_location; $this->assertSame($expected_symbol, $symbol); $this->assertSame($expected_argument_number, $argument_number); diff --git a/tests/fixtures/stubs/class_alias.php b/tests/fixtures/stubs/class_alias.php index 565cd9d11..d2e868334 100644 --- a/tests/fixtures/stubs/class_alias.php +++ b/tests/fixtures/stubs/class_alias.php @@ -30,7 +30,7 @@ $arr = [ [I::class, IAlias::class], ]; -foreach ($arr as list($orig, $alias)) { +foreach ($arr as [$orig, $alias]) { // Psalm cannot reason about this in the loading step class_alias($orig, $alias); }