1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Merge pull request #10801 from weirdan/fix-trailing-commas-after-anon-functions

This commit is contained in:
Bruce Weirdan 2024-03-09 19:38:57 +01:00 committed by GitHub
commit 02b58a592f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 39 additions and 43 deletions

View File

@ -946,7 +946,7 @@ final class ClassAnalyzer extends ClassLikeAnalyzer
$stmts,
static fn($stmt): bool => $stmt instanceof PhpParser\Node\Stmt\Property
&& isset($stmt->props[0]->name->name)
&& $stmt->props[0]->name->name === $property_name
&& $stmt->props[0]->name->name === $property_name,
);
$suppressed = [];

View File

@ -245,7 +245,7 @@ final class ReturnTypeAnalyzer
if (count($inferred_return_type_parts) > 1) {
$inferred_return_type_parts = array_filter(
$inferred_return_type_parts,
static fn(Union $union_type): bool => !$union_type->isNever()
static fn(Union $union_type): bool => !$union_type->isNever(),
);
}
$inferred_return_type_parts = array_values($inferred_return_type_parts);

View File

@ -78,7 +78,7 @@ final class IfConditionalAnalyzer
$entry_clauses,
static fn(Clause $c): bool => count($c->possibilities) > 1
|| $c->wedge
|| !isset($changed_var_ids[array_key_first($c->possibilities)])
|| !isset($changed_var_ids[array_key_first($c->possibilities)]),
),
);
}

View File

@ -144,7 +144,7 @@ final class ElseIfAnalyzer
$elseif_context_clauses = array_values(
array_filter(
$elseif_context_clauses,
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses, true)
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses, true),
),
);
}

View File

@ -182,7 +182,7 @@ final class IfElseAnalyzer
$if_context->clauses = array_values(
array_filter(
$if_context->clauses,
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses)
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses),
),
);

View File

@ -105,7 +105,7 @@ final class AndAnalyzer
$context_clauses = array_values(
array_filter(
$context_clauses,
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses, true)
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses, true),
),
);

View File

@ -173,7 +173,7 @@ final class OrAnalyzer
$negated_left_clauses = array_values(
array_filter(
$negated_left_clauses,
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses)
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses),
),
);

View File

@ -446,7 +446,7 @@ final class ExistingAtomicMethodCallAnalyzer extends CallAnalyzer
$possibilities,
static fn(Possibilities $assertion): bool => !(is_string($assertion->var_id)
&& strpos($assertion->var_id, '$this->') === 0
)
),
);
}
$statements_analyzer->node_data->setIfTrueAssertions(
@ -469,7 +469,7 @@ final class ExistingAtomicMethodCallAnalyzer extends CallAnalyzer
$possibilities,
static fn(Possibilities $assertion): bool => !(is_string($assertion->var_id)
&& strpos($assertion->var_id, '$this->') === 0
)
),
);
}
$statements_analyzer->node_data->setIfFalseAssertions(

View File

@ -238,7 +238,7 @@ final class MethodCallAnalyzer extends CallAnalyzer
if (count($possible_new_class_types) > 0) {
$class_type = array_reduce(
$possible_new_class_types,
static fn(?Union $type_1, Union $type_2): Union => Type::combineUnionTypes($type_1, $type_2, $codebase)
static fn(?Union $type_1, Union $type_2): Union => Type::combineUnionTypes($type_1, $type_2, $codebase),
);
}

View File

@ -419,7 +419,7 @@ final class AtomicStaticCallAnalyzer
$mixin_candidates_no_generic = array_filter(
$mixin_candidates,
static fn(Atomic $check): bool => !($check instanceof TGenericObject)
static fn(Atomic $check): bool => !($check instanceof TGenericObject),
);
// $mixin_candidates_no_generic will only be empty when there are TGenericObject entries.

View File

@ -139,7 +139,7 @@ final class TernaryAnalyzer
$ternary_context_clauses = array_values(
array_filter(
$ternary_context_clauses,
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses)
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses),
),
);

View File

@ -282,7 +282,7 @@ final class LanguageServer
// we ignore the FQN because of a hack in scoper.inc that needs full path
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
static fn(): ?\Composer\Autoload\ClassLoader =>
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir)
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir),
);
if (array_key_exists('v', $options)) {

View File

@ -226,7 +226,7 @@ final class Psalm
// we ignore the FQN because of a hack in scoper.inc that needs full path
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
static fn(): ?\Composer\Autoload\ClassLoader =>
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir)
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir),
);
$run_taint_analysis = self::shouldRunTaintAnalysis($options);
@ -502,7 +502,7 @@ final class Psalm
&& $arg !== '--debug-emitted-issues'
&& strpos($arg, '--disable-extension=') !== 0
&& strpos($arg, '--root=') !== 0
&& strpos($arg, '--r=') !== 0
&& strpos($arg, '--r=') !== 0,
));
$init_level = null;

View File

@ -221,7 +221,7 @@ final class Psalter
// we ignore the FQN because of a hack in scoper.inc that needs full path
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
static fn(): ?\Composer\Autoload\ClassLoader =>
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir)
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir),
);
$ini_handler = new PsalmRestarter('PSALTER');
$ini_handler->disableExtensions([

View File

@ -192,7 +192,7 @@ final class Refactor
// we ignore the FQN because of a hack in scoper.inc that needs full path
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
static fn(): ?\Composer\Autoload\ClassLoader =>
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir)
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir),
);
// If Xdebug is enabled, restart without it

View File

@ -549,7 +549,7 @@ final class CliUtils
$missing_extensions = array_filter(
$required_extensions,
static fn(string $ext) => !extension_loaded($ext)
static fn(string $ext) => !extension_loaded($ext),
);
if ($missing_extensions) {

View File

@ -1599,7 +1599,7 @@ final class ClassLikes
$storage->constants,
static fn(ClassConstantStorage $constant): bool => $constant->type
&& ($constant->visibility === ClassLikeAnalyzer::VISIBILITY_PUBLIC
|| $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PROTECTED)
|| $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PROTECTED),
);
}
@ -2410,7 +2410,7 @@ final class ClassLikes
fn(ClassConstantStorage $resolved_constant) => $this->filterConstantNameByVisibility(
$resolved_constant,
$visibility,
)
),
);
if ($filtered_constants_by_visibility === []) {

View File

@ -61,7 +61,7 @@ final class PsalmRestarter extends XdebugHandler
{
$this->required = (bool) array_filter(
$this->disabled_extensions,
static fn(string $extension): bool => extension_loaded($extension)
static fn(string $extension): bool => extension_loaded($extension),
);
$opcache_loaded = extension_loaded('opcache') || extension_loaded('Zend OPcache');

View File

@ -145,8 +145,6 @@ final class LanguageClient
/**
* Configuration Refreshed from Client
*
* @param array $config
*/
private function configurationRefreshed(array $config): void
{

View File

@ -422,7 +422,7 @@ final class ClassLikeNodeScanner
usort(
$docblock_info->templates,
static fn(array $l, array $r): int => $l[4] > $r[4] ? 1 : -1
static fn(array $l, array $r): int => $l[4] > $r[4] ? 1 : -1,
);
foreach ($docblock_info->templates as $i => $template_map) {

View File

@ -917,7 +917,7 @@ final class FunctionLikeDocblockScanner
$params_without_docblock_type = array_filter(
$storage->params,
static fn(FunctionLikeParameter $p): bool => !$p->has_docblock_type && (!$p->type || $p->type->hasArray())
static fn(FunctionLikeParameter $p): bool => !$p->has_docblock_type && (!$p->type || $p->type->hasArray()),
);
if ($params_without_docblock_type) {

View File

@ -180,7 +180,7 @@ final class FileReferenceProvider
if (self::$deleted_files === null) {
self::$deleted_files = array_filter(
array_keys(self::$file_references),
fn(string $file_name): bool => !$this->file_provider->fileExists($file_name)
fn(string $file_name): bool => !$this->file_provider->fileExists($file_name),
);
}

View File

@ -106,7 +106,7 @@ final class ArrayFilterReturnTypeProvider implements FunctionReturnTypeProviderI
},
$first_arg_array->properties,
),
static fn($keyed_type) => !$keyed_type->isNever()
static fn($keyed_type) => !$keyed_type->isNever(),
);
if (!$new_properties) {

View File

@ -634,7 +634,7 @@ final class TypeExpander
if ($container_class_storage->template_types
&& array_filter(
$container_class_storage->template_types,
static fn($type_map): bool => !reset($type_map)->hasMixed()
static fn($type_map): bool => !reset($type_map)->hasMixed(),
)
) {
$return_type = new TGenericObject(

View File

@ -575,7 +575,7 @@ final class IssueBuffer
$file_issues,
static fn(IssueData $d1, IssueData $d2): int => [$d1->file_path, $d1->line_from, $d1->column_from]
<=>
[$d2->file_path, $d2->line_from, $d2->column_from]
[$d2->file_path, $d2->line_from, $d2->column_from],
);
self::$issues_data[$file_path] = $file_issues;
}

View File

@ -453,7 +453,7 @@ abstract class Atomic implements TypeNode
&& ($this->as->hasNamedObjectType()
|| array_filter(
$this->extra_types,
static fn($extra_type): bool => $extra_type->isNamedObjectType()
static fn($extra_type): bool => $extra_type->isNamedObjectType(),
)
)
);
@ -545,7 +545,7 @@ abstract class Atomic implements TypeNode
$this->extra_types
&& array_filter(
$this->extra_types,
static fn(Atomic $a): bool => $a->hasTraversableInterface($codebase)
static fn(Atomic $a): bool => $a->hasTraversableInterface($codebase),
)
)
);
@ -568,7 +568,7 @@ abstract class Atomic implements TypeNode
$this->extra_types
&& array_filter(
$this->extra_types,
static fn(Atomic $a): bool => $a->hasCountableInterface($codebase)
static fn(Atomic $a): bool => $a->hasCountableInterface($codebase),
)
)
);
@ -606,7 +606,7 @@ abstract class Atomic implements TypeNode
$this->extra_types
&& array_filter(
$this->extra_types,
static fn(Atomic $a): bool => $a->hasArrayAccessInterface($codebase)
static fn(Atomic $a): bool => $a->hasArrayAccessInterface($codebase),
)
)
);

View File

@ -381,7 +381,7 @@ trait UnionTrait
return !array_filter(
$types,
static fn($atomic_type): bool => !$atomic_type->canBeFullyExpressedInPhp($analysis_php_version_id)
static fn($atomic_type): bool => !$atomic_type->canBeFullyExpressedInPhp($analysis_php_version_id),
);
}
@ -459,7 +459,7 @@ trait UnionTrait
{
return (bool)array_filter(
$this->types,
static fn($type): bool => $type->hasArrayAccessInterface($codebase)
static fn($type): bool => $type->hasArrayAccessInterface($codebase),
);
}
@ -750,7 +750,7 @@ trait UnionTrait
$type->extra_types,
static fn($t): bool => $t instanceof TTemplateParam,
)
)
),
);
}
@ -782,7 +782,7 @@ trait UnionTrait
)
)
)
)
),
);
}
@ -993,7 +993,7 @@ trait UnionTrait
|| ($check_templates
&& $type instanceof TTemplateParam
&& $type->as->isInt()
)
),
),
) === count($this->types);
}
@ -1024,7 +1024,7 @@ trait UnionTrait
|| ($check_templates
&& $type instanceof TTemplateParam
&& $type->as->isString()
)
),
),
) === count($this->types);
}
@ -1043,7 +1043,7 @@ trait UnionTrait
|| ($check_templates
&& $type instanceof TTemplateParam
&& $type->as->isNonEmptyString()
)
),
),
) === count($this->types);
}

View File

@ -349,7 +349,7 @@ class DocumentationTest extends TestCase
$duplicate_shortcodes = array_filter(
$all_shortcodes,
static fn($issues): bool => count($issues) > 1
static fn($issues): bool => count($issues) > 1,
);
$this->assertEquals(

View File

@ -17,8 +17,6 @@ abstract class Message extends AdvancedJsonRpcMessage
{
/**
* Returns the appropriate Message subclass
*
* @param array $msg
*/
public static function parseArray(array $msg): AdvancedJsonRpcMessage
{