mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Remove some array_values
This commit is contained in:
parent
04bbd2acba
commit
ee8c5c9c35
@ -130,28 +130,26 @@ class IfElseAnalyzer
|
||||
$if_clauses = [];
|
||||
}
|
||||
|
||||
$if_clauses = array_values(
|
||||
array_map(
|
||||
$if_clauses = array_map(
|
||||
/**
|
||||
* @return Clause
|
||||
*/
|
||||
function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause {
|
||||
$keys = array_keys($c->possibilities);
|
||||
function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause {
|
||||
$keys = array_keys($c->possibilities);
|
||||
|
||||
$mixed_var_ids = \array_diff($mixed_var_ids, $keys);
|
||||
$mixed_var_ids = \array_diff($mixed_var_ids, $keys);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
foreach ($mixed_var_ids as $mixed_var_id) {
|
||||
if (preg_match('/^' . preg_quote($mixed_var_id, '/') . '(\[|-)/', $key)) {
|
||||
return new Clause([], $cond_object_id, $cond_object_id, true);
|
||||
}
|
||||
foreach ($keys as $key) {
|
||||
foreach ($mixed_var_ids as $mixed_var_id) {
|
||||
if (preg_match('/^' . preg_quote($mixed_var_id, '/') . '(\[|-)/', $key)) {
|
||||
return new Clause([], $cond_object_id, $cond_object_id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $c;
|
||||
},
|
||||
$if_clauses
|
||||
)
|
||||
return $c;
|
||||
},
|
||||
$if_clauses
|
||||
);
|
||||
|
||||
$entry_clauses = $context->clauses;
|
||||
|
@ -377,7 +377,7 @@ class NamedFunctionCallHandler
|
||||
if ($first_arg_type->from_docblock) {
|
||||
if (IssueBuffer::accepts(
|
||||
new \Psalm\Issue\RedundantCastGivenDocblockType(
|
||||
'The call to array_values is unnecessary given the docblock type',
|
||||
'The call to array_values is unnecessary given the list docblock type '.$first_arg_type,
|
||||
new CodeLocation($statements_analyzer, $function_name)
|
||||
),
|
||||
$statements_analyzer->getSuppressedIssues()
|
||||
@ -387,7 +387,7 @@ class NamedFunctionCallHandler
|
||||
} else {
|
||||
if (IssueBuffer::accepts(
|
||||
new \Psalm\Issue\RedundantCast(
|
||||
'The call to array_values is unnecessary',
|
||||
'The call to array_values is unnecessary, '.$first_arg_type.' is already a list',
|
||||
new CodeLocation($statements_analyzer, $function_name)
|
||||
),
|
||||
$statements_analyzer->getSuppressedIssues()
|
||||
|
@ -209,7 +209,7 @@ class MatchAnalyzer
|
||||
}
|
||||
|
||||
$all_match_condition = self::convertCondsToConditional(
|
||||
\array_values($all_conds),
|
||||
$all_conds,
|
||||
$match_condition,
|
||||
$match_condition->getAttributes()
|
||||
);
|
||||
|
@ -83,28 +83,26 @@ class TernaryAnalyzer
|
||||
}
|
||||
}
|
||||
|
||||
$if_clauses = array_values(
|
||||
array_map(
|
||||
$if_clauses = array_map(
|
||||
/**
|
||||
* @return \Psalm\Internal\Clause
|
||||
*/
|
||||
function (\Psalm\Internal\Clause $c) use ($mixed_var_ids, $cond_id): \Psalm\Internal\Clause {
|
||||
$keys = array_keys($c->possibilities);
|
||||
function (\Psalm\Internal\Clause $c) use ($mixed_var_ids, $cond_id): \Psalm\Internal\Clause {
|
||||
$keys = array_keys($c->possibilities);
|
||||
|
||||
$mixed_var_ids = \array_diff($mixed_var_ids, $keys);
|
||||
$mixed_var_ids = \array_diff($mixed_var_ids, $keys);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
foreach ($mixed_var_ids as $mixed_var_id) {
|
||||
if (preg_match('/^' . preg_quote($mixed_var_id, '/') . '(\[|-)/', $key)) {
|
||||
return new \Psalm\Internal\Clause([], $cond_id, $cond_id, true);
|
||||
}
|
||||
foreach ($keys as $key) {
|
||||
foreach ($mixed_var_ids as $mixed_var_id) {
|
||||
if (preg_match('/^' . preg_quote($mixed_var_id, '/') . '(\[|-)/', $key)) {
|
||||
return new \Psalm\Internal\Clause([], $cond_id, $cond_id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $c;
|
||||
},
|
||||
$if_clauses
|
||||
)
|
||||
return $c;
|
||||
},
|
||||
$if_clauses
|
||||
);
|
||||
|
||||
// this will see whether any of the clauses in set A conflict with the clauses in set B
|
||||
|
@ -387,7 +387,7 @@ class Pool
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($terminationMessages);
|
||||
return $terminationMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,6 @@ use Psalm\Report\JsonReport;
|
||||
use Psalm\Report\ReportOptions;
|
||||
use Psalm\Tests\Internal\Provider;
|
||||
|
||||
use function array_values;
|
||||
use function file_get_contents;
|
||||
use function json_decode;
|
||||
use function ob_end_clean;
|
||||
@ -815,7 +814,7 @@ echo $a;';
|
||||
$json_report_options = ProjectAnalyzer::getFileReportOptions([__DIR__ . '/test-report.json'])[0];
|
||||
|
||||
$this->assertSame(
|
||||
array_values($issue_data),
|
||||
$issue_data,
|
||||
json_decode(IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $json_report_options), true)
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user