1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Short list syntax (#4102)

* Short list syntax

* revert unrelated CS
This commit is contained in:
orklah 2020-09-02 06:17:41 +02:00 committed by GitHub
parent 6f92846fd6
commit 73f6fcde48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 100 additions and 99 deletions

View File

@ -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,

View File

@ -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 '<?php ' . $storage->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 '<?php ' . $storage->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;
}

View File

@ -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] = [];

View File

@ -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();

View File

@ -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();

View File

@ -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,

View File

@ -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;

View File

@ -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 = [];

View File

@ -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);

View File

@ -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':

View File

@ -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])

View File

@ -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,

View File

@ -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)

View File

@ -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,

View File

@ -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];

View File

@ -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 = [];

View File

@ -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 = [];

View File

@ -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);

View File

@ -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;
}

View File

@ -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)

View File

@ -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);

View File

@ -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(

View File

@ -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);

View File

@ -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

View File

@ -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));

View File

@ -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

View File

@ -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

View File

@ -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));

View File

@ -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

View File

@ -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.

View File

@ -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);

View File

@ -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;
}

View File

@ -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(

View File

@ -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;
}

View File

@ -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;

View File

@ -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,

View File

@ -64,10 +64,10 @@ class DocblockParser
if (preg_match('/^[ \t]*\*?\s*@([\w\-:]+)[\t ]*(.*)$/sm', $line, $matches, PREG_OFFSET_CAPTURE)) {
/** @var array<int, array{string, int}> $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));

View File

@ -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;
}

View File

@ -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];

View File

@ -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];

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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]);

View File

@ -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);

View File

@ -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);
}