mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Re-add short closure sniff
This commit is contained in:
parent
a52f35e5e1
commit
9ce31a7709
@ -30,9 +30,7 @@ mt_srand(4); // chosen by fair dice roll.
|
||||
// -- xkcd:221
|
||||
|
||||
$order = array_map(
|
||||
function (): int {
|
||||
return mt_rand();
|
||||
},
|
||||
fn(): int => mt_rand(),
|
||||
$files
|
||||
);
|
||||
array_multisort($order, $files);
|
||||
|
@ -100,9 +100,7 @@ foreach ($files as $file) {
|
||||
$file,
|
||||
get_class($exception),
|
||||
$exception->getMessage(),
|
||||
implode("\n", array_map(function (LibXMLError $error): string {
|
||||
return $error->message;
|
||||
}, libxml_get_errors()))
|
||||
implode("\n", array_map(fn(LibXMLError $error): string => $error->message, libxml_get_errors()))
|
||||
);
|
||||
libxml_clear_errors();
|
||||
continue;
|
||||
@ -159,9 +157,7 @@ foreach ($files as $file) {
|
||||
|
||||
function serializeArray(array $array, string $prefix): string
|
||||
{
|
||||
uksort($array, function (string $first, string $second): int {
|
||||
return strtolower($first) <=> strtolower($second);
|
||||
});
|
||||
uksort($array, fn(string $first, string $second): int => strtolower($first) <=> strtolower($second));
|
||||
$result = "[\n";
|
||||
$localPrefix = $prefix . ' ';
|
||||
foreach ($array as $key => $value) {
|
||||
|
@ -228,6 +228,9 @@
|
||||
-->
|
||||
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
|
||||
|
||||
<!-- https://github.com/slevomat/coding-standard/blob/master/doc/functions.md#slevomatcodingstandardfunctionsrequirearrowfunction- -->
|
||||
<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction"/>
|
||||
|
||||
<!--
|
||||
Forces uniform arrow function style
|
||||
https://github.com/slevomat/coding-standard/blob/master/doc/functions.md#slevomatcodingstandardfunctionsarrowfunctiondeclaration-
|
||||
|
@ -265,8 +265,7 @@ class TryAnalyzer
|
||||
|
||||
$catch_context->vars_in_scope[$catch_var_id] = new Union(
|
||||
array_map(
|
||||
static function (string $fq_catch_class) use ($codebase): TNamedObject {
|
||||
return new TNamedObject(
|
||||
static fn(string $fq_catch_class): TNamedObject => new TNamedObject(
|
||||
$fq_catch_class,
|
||||
false,
|
||||
false,
|
||||
@ -275,9 +274,8 @@ class TryAnalyzer
|
||||
&& $codebase->interfaceExists($fq_catch_class)
|
||||
&& !$codebase->interfaceExtends($fq_catch_class, 'Throwable')
|
||||
? ['Throwable' => new TNamedObject('Throwable')]
|
||||
: []
|
||||
);
|
||||
},
|
||||
: [],
|
||||
),
|
||||
$fq_catch_classes
|
||||
)
|
||||
);
|
||||
|
@ -391,9 +391,9 @@ class FunctionDocblockManipulator
|
||||
$modified_docblock = true;
|
||||
$inferredThrowsClause = array_reduce(
|
||||
$this->throwsExceptions,
|
||||
function (string $throwsClause, string $exception) {
|
||||
return $throwsClause === '' ? $exception : $throwsClause.'|'.$exception;
|
||||
},
|
||||
fn(string $throwsClause, string $exception) => $throwsClause === ''
|
||||
? $exception
|
||||
: $throwsClause.'|'.$exception,
|
||||
''
|
||||
);
|
||||
if (array_key_exists('throws', $parsed_docblock->tags)) {
|
||||
|
@ -179,13 +179,12 @@ HEADING;
|
||||
|
||||
private function sortIssuesByLevelAndType(): void
|
||||
{
|
||||
usort($this->issues_data, function (IssueData $left, IssueData $right): int {
|
||||
// negative error levels go to the top, followed by large positive levels, with level 1 at the bottom.
|
||||
return [$left->error_level > 0, -$left->error_level, $left->type,
|
||||
$left->file_path, $left->file_name, $left->line_from]
|
||||
<=>
|
||||
[$right->error_level > 0, -$right->error_level, $right->type,
|
||||
$right->file_path, $right->file_name, $right->line_from];
|
||||
});
|
||||
usort(
|
||||
$this->issues_data,
|
||||
fn(IssueData $left, IssueData $right): int => [$left->error_level > 0, -$left->error_level,
|
||||
$left->type, $left->file_path, $left->file_name, $left->line_from]
|
||||
<=> [$right->error_level > 0, -$right->error_level, $right->type, $right->file_path, $right->file_name,
|
||||
$right->line_from],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user