Skip to content

Commit

Permalink
Disallow ksorting lists
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Nov 29, 2021
1 parent ad23ab3 commit b0a336d
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -364,7 +364,7 @@ function (array $_) : bool {
return;
}

if ($first_arg && $function_id === 'array_values') {
if ($first_arg && ($function_id === 'array_values' || $function_id === 'ksort')) {
$first_arg_type = $statements_analyzer->node_data->getType($first_arg->value);

if ($first_arg_type
Expand All @@ -377,7 +377,7 @@ function (array $_) : bool {
if ($first_arg_type->from_docblock) {
if (IssueBuffer::accepts(
new \Psalm\Issue\RedundantCastGivenDocblockType(
'The call to array_values is unnecessary given the list docblock type '.$first_arg_type,
"The call to $function_id is unnecessary given the list docblock type $first_arg_type",
new CodeLocation($statements_analyzer, $function_name)
),
$statements_analyzer->getSuppressedIssues()
Expand All @@ -387,7 +387,7 @@ function (array $_) : bool {
} else {
if (IssueBuffer::accepts(
new \Psalm\Issue\RedundantCast(
'The call to array_values is unnecessary, '.$first_arg_type.' is already a list',
"The call to $function_id is unnecessary, $first_arg_type is already a list",
new CodeLocation($statements_analyzer, $function_name)
),
$statements_analyzer->getSuppressedIssues()
Expand Down

0 comments on commit b0a336d

Please sign in to comment.