Skip to content

Commit 8e1aa46

Browse files
committed
CS fix
- trailing commas in calls with anon functions - useless array docblock Refs slevomat/coding-standard@8d0f603 Refs slevomat/coding-standard@6ea0278
1 parent dca888c commit 8e1aa46

29 files changed

+39
-43
lines changed

src/Psalm/Internal/Analyzer/ClassAnalyzer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ public static function addContextProperties(
946946
$stmts,
947947
static fn($stmt): bool => $stmt instanceof PhpParser\Node\Stmt\Property
948948
&& isset($stmt->props[0]->name->name)
949-
&& $stmt->props[0]->name->name === $property_name
949+
&& $stmt->props[0]->name->name === $property_name,
950950
);
951951

952952
$suppressed = [];

src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public static function verifyReturnType(
245245
if (count($inferred_return_type_parts) > 1) {
246246
$inferred_return_type_parts = array_filter(
247247
$inferred_return_type_parts,
248-
static fn(Union $union_type): bool => !$union_type->isNever()
248+
static fn(Union $union_type): bool => !$union_type->isNever(),
249249
);
250250
}
251251
$inferred_return_type_parts = array_values($inferred_return_type_parts);

src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static function analyze(
7878
$entry_clauses,
7979
static fn(Clause $c): bool => count($c->possibilities) > 1
8080
|| $c->wedge
81-
|| !isset($changed_var_ids[array_key_first($c->possibilities)])
81+
|| !isset($changed_var_ids[array_key_first($c->possibilities)]),
8282
),
8383
);
8484
}

src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public static function analyze(
144144
$elseif_context_clauses = array_values(
145145
array_filter(
146146
$elseif_context_clauses,
147-
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses, true)
147+
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses, true),
148148
),
149149
);
150150
}

src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public static function analyze(
182182
$if_context->clauses = array_values(
183183
array_filter(
184184
$if_context->clauses,
185-
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses)
185+
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses),
186186
),
187187
);
188188

src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function analyze(
105105
$context_clauses = array_values(
106106
array_filter(
107107
$context_clauses,
108-
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses, true)
108+
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses, true),
109109
),
110110
);
111111

src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public static function analyze(
173173
$negated_left_clauses = array_values(
174174
array_filter(
175175
$negated_left_clauses,
176-
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses)
176+
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses),
177177
),
178178
);
179179

src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/ExistingAtomicMethodCallAnalyzer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ public static function analyze(
446446
$possibilities,
447447
static fn(Possibilities $assertion): bool => !(is_string($assertion->var_id)
448448
&& strpos($assertion->var_id, '$this->') === 0
449-
)
449+
),
450450
);
451451
}
452452
$statements_analyzer->node_data->setIfTrueAssertions(
@@ -469,7 +469,7 @@ public static function analyze(
469469
$possibilities,
470470
static fn(Possibilities $assertion): bool => !(is_string($assertion->var_id)
471471
&& strpos($assertion->var_id, '$this->') === 0
472-
)
472+
),
473473
);
474474
}
475475
$statements_analyzer->node_data->setIfFalseAssertions(

src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public static function analyze(
238238
if (count($possible_new_class_types) > 0) {
239239
$class_type = array_reduce(
240240
$possible_new_class_types,
241-
static fn(?Union $type_1, Union $type_2): Union => Type::combineUnionTypes($type_1, $type_2, $codebase)
241+
static fn(?Union $type_1, Union $type_2): Union => Type::combineUnionTypes($type_1, $type_2, $codebase),
242242
);
243243
}
244244

src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ private static function handleNamedCall(
419419

420420
$mixin_candidates_no_generic = array_filter(
421421
$mixin_candidates,
422-
static fn(Atomic $check): bool => !($check instanceof TGenericObject)
422+
static fn(Atomic $check): bool => !($check instanceof TGenericObject),
423423
);
424424

425425
// $mixin_candidates_no_generic will only be empty when there are TGenericObject entries.

src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause {
139139
$ternary_context_clauses = array_values(
140140
array_filter(
141141
$ternary_context_clauses,
142-
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses)
142+
static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses),
143143
),
144144
);
145145

src/Psalm/Internal/Cli/LanguageServer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ static function (string $arg) use ($valid_long_options): void {
282282
// we ignore the FQN because of a hack in scoper.inc that needs full path
283283
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
284284
static fn(): ?\Composer\Autoload\ClassLoader =>
285-
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir)
285+
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir),
286286
);
287287

288288
if (array_key_exists('v', $options)) {

src/Psalm/Internal/Cli/Psalm.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public static function run(array $argv): void
226226
// we ignore the FQN because of a hack in scoper.inc that needs full path
227227
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
228228
static fn(): ?\Composer\Autoload\ClassLoader =>
229-
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir)
229+
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir),
230230
);
231231

232232
$run_taint_analysis = self::shouldRunTaintAnalysis($options);
@@ -502,7 +502,7 @@ private static function generateConfig(string $current_dir, array &$args): void
502502
&& $arg !== '--debug-emitted-issues'
503503
&& strpos($arg, '--disable-extension=') !== 0
504504
&& strpos($arg, '--root=') !== 0
505-
&& strpos($arg, '--r=') !== 0
505+
&& strpos($arg, '--r=') !== 0,
506506
));
507507

508508
$init_level = null;

src/Psalm/Internal/Cli/Psalter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public static function run(array $argv): void
221221
// we ignore the FQN because of a hack in scoper.inc that needs full path
222222
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
223223
static fn(): ?\Composer\Autoload\ClassLoader =>
224-
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir)
224+
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir),
225225
);
226226
$ini_handler = new PsalmRestarter('PSALTER');
227227
$ini_handler->disableExtensions([

src/Psalm/Internal/Cli/Refactor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static function (string $arg) use ($valid_long_options): void {
192192
// we ignore the FQN because of a hack in scoper.inc that needs full path
193193
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
194194
static fn(): ?\Composer\Autoload\ClassLoader =>
195-
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir)
195+
CliUtils::requireAutoloaders($current_dir, isset($options['r']), $vendor_dir),
196196
);
197197

198198
// If Xdebug is enabled, restart without it

src/Psalm/Internal/CliUtils.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ public static function checkRuntimeRequirements(): void
549549

550550
$missing_extensions = array_filter(
551551
$required_extensions,
552-
static fn(string $ext) => !extension_loaded($ext)
552+
static fn(string $ext) => !extension_loaded($ext),
553553
);
554554

555555
if ($missing_extensions) {

src/Psalm/Internal/Codebase/ClassLikes.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ public function getConstantsForClass(string $class_name, int $visibility): array
15991599
$storage->constants,
16001600
static fn(ClassConstantStorage $constant): bool => $constant->type
16011601
&& ($constant->visibility === ClassLikeAnalyzer::VISIBILITY_PUBLIC
1602-
|| $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PROTECTED)
1602+
|| $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PROTECTED),
16031603
);
16041604
}
16051605

@@ -2410,7 +2410,7 @@ private function getConstantType(
24102410
fn(ClassConstantStorage $resolved_constant) => $this->filterConstantNameByVisibility(
24112411
$resolved_constant,
24122412
$visibility,
2413-
)
2413+
),
24142414
);
24152415

24162416
if ($filtered_constants_by_visibility === []) {

src/Psalm/Internal/Fork/PsalmRestarter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected function requiresRestart($default): bool
6161
{
6262
$this->required = (bool) array_filter(
6363
$this->disabled_extensions,
64-
static fn(string $extension): bool => extension_loaded($extension)
64+
static fn(string $extension): bool => extension_loaded($extension),
6565
);
6666

6767
$opcache_loaded = extension_loaded('opcache') || extension_loaded('Zend OPcache');

src/Psalm/Internal/LanguageServer/LanguageClient.php

-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ public function makeProgress(string $token): ProgressInterface
145145

146146
/**
147147
* Configuration Refreshed from Client
148-
*
149-
* @param array $config
150148
*/
151149
private function configurationRefreshed(array $config): void
152150
{

src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool
422422

423423
usort(
424424
$docblock_info->templates,
425-
static fn(array $l, array $r): int => $l[4] > $r[4] ? 1 : -1
425+
static fn(array $l, array $r): int => $l[4] > $r[4] ? 1 : -1,
426426
);
427427

428428
foreach ($docblock_info->templates as $i => $template_map) {

src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ private static function improveParamsFromDocblock(
917917

918918
$params_without_docblock_type = array_filter(
919919
$storage->params,
920-
static fn(FunctionLikeParameter $p): bool => !$p->has_docblock_type && (!$p->type || $p->type->hasArray())
920+
static fn(FunctionLikeParameter $p): bool => !$p->has_docblock_type && (!$p->type || $p->type->hasArray()),
921921
);
922922

923923
if ($params_without_docblock_type) {

src/Psalm/Internal/Provider/FileReferenceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function getDeletedReferencedFiles(): array
180180
if (self::$deleted_files === null) {
181181
self::$deleted_files = array_filter(
182182
array_keys(self::$file_references),
183-
fn(string $file_name): bool => !$this->file_provider->fileExists($file_name)
183+
fn(string $file_name): bool => !$this->file_provider->fileExists($file_name),
184184
);
185185
}
186186

src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static function ($keyed_type) use ($statements_source, $context) {
106106
},
107107
$first_arg_array->properties,
108108
),
109-
static fn($keyed_type) => !$keyed_type->isNever()
109+
static fn($keyed_type) => !$keyed_type->isNever(),
110110
);
111111

112112
if (!$new_properties) {

src/Psalm/Internal/Type/TypeExpander.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ private static function expandNamedObject(
634634
if ($container_class_storage->template_types
635635
&& array_filter(
636636
$container_class_storage->template_types,
637-
static fn($type_map): bool => !reset($type_map)->hasMixed()
637+
static fn($type_map): bool => !reset($type_map)->hasMixed(),
638638
)
639639
) {
640640
$return_type = new TGenericObject(

src/Psalm/IssueBuffer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ public static function finish(
575575
$file_issues,
576576
static fn(IssueData $d1, IssueData $d2): int => [$d1->file_path, $d1->line_from, $d1->column_from]
577577
<=>
578-
[$d2->file_path, $d2->line_from, $d2->column_from]
578+
[$d2->file_path, $d2->line_from, $d2->column_from],
579579
);
580580
self::$issues_data[$file_path] = $file_issues;
581581
}

src/Psalm/Type/Atomic.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ public function isNamedObjectType(): bool
453453
&& ($this->as->hasNamedObjectType()
454454
|| array_filter(
455455
$this->extra_types,
456-
static fn($extra_type): bool => $extra_type->isNamedObjectType()
456+
static fn($extra_type): bool => $extra_type->isNamedObjectType(),
457457
)
458458
)
459459
);
@@ -545,7 +545,7 @@ public function hasTraversableInterface(Codebase $codebase): bool
545545
$this->extra_types
546546
&& array_filter(
547547
$this->extra_types,
548-
static fn(Atomic $a): bool => $a->hasTraversableInterface($codebase)
548+
static fn(Atomic $a): bool => $a->hasTraversableInterface($codebase),
549549
)
550550
)
551551
);
@@ -568,7 +568,7 @@ public function hasCountableInterface(Codebase $codebase): bool
568568
$this->extra_types
569569
&& array_filter(
570570
$this->extra_types,
571-
static fn(Atomic $a): bool => $a->hasCountableInterface($codebase)
571+
static fn(Atomic $a): bool => $a->hasCountableInterface($codebase),
572572
)
573573
)
574574
);
@@ -606,7 +606,7 @@ public function hasArrayAccessInterface(Codebase $codebase): bool
606606
$this->extra_types
607607
&& array_filter(
608608
$this->extra_types,
609-
static fn(Atomic $a): bool => $a->hasArrayAccessInterface($codebase)
609+
static fn(Atomic $a): bool => $a->hasArrayAccessInterface($codebase),
610610
)
611611
)
612612
);

src/Psalm/Type/UnionTrait.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool
381381

382382
return !array_filter(
383383
$types,
384-
static fn($atomic_type): bool => !$atomic_type->canBeFullyExpressedInPhp($analysis_php_version_id)
384+
static fn($atomic_type): bool => !$atomic_type->canBeFullyExpressedInPhp($analysis_php_version_id),
385385
);
386386
}
387387

@@ -459,7 +459,7 @@ public function hasArrayAccessInterface(Codebase $codebase): bool
459459
{
460460
return (bool)array_filter(
461461
$this->types,
462-
static fn($type): bool => $type->hasArrayAccessInterface($codebase)
462+
static fn($type): bool => $type->hasArrayAccessInterface($codebase),
463463
);
464464
}
465465

@@ -750,7 +750,7 @@ public function hasTemplate(): bool
750750
$type->extra_types,
751751
static fn($t): bool => $t instanceof TTemplateParam,
752752
)
753-
)
753+
),
754754
);
755755
}
756756

@@ -782,7 +782,7 @@ public function hasTemplateOrStatic(): bool
782782
)
783783
)
784784
)
785-
)
785+
),
786786
);
787787
}
788788

@@ -993,7 +993,7 @@ public function isInt(bool $check_templates = false): bool
993993
|| ($check_templates
994994
&& $type instanceof TTemplateParam
995995
&& $type->as->isInt()
996-
)
996+
),
997997
),
998998
) === count($this->types);
999999
}
@@ -1024,7 +1024,7 @@ public function isString(bool $check_templates = false): bool
10241024
|| ($check_templates
10251025
&& $type instanceof TTemplateParam
10261026
&& $type->as->isString()
1027-
)
1027+
),
10281028
),
10291029
) === count($this->types);
10301030
}
@@ -1043,7 +1043,7 @@ public function isNonEmptyString(bool $check_templates = false): bool
10431043
|| ($check_templates
10441044
&& $type instanceof TTemplateParam
10451045
&& $type->as->isNonEmptyString()
1046-
)
1046+
),
10471047
),
10481048
) === count($this->types);
10491049
}

tests/DocumentationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public function testShortcodesAreUnique(): void
349349

350350
$duplicate_shortcodes = array_filter(
351351
$all_shortcodes,
352-
static fn($issues): bool => count($issues) > 1
352+
static fn($issues): bool => count($issues) > 1,
353353
);
354354

355355
$this->assertEquals(

tests/LanguageServer/Message.php

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ abstract class Message extends AdvancedJsonRpcMessage
1717
{
1818
/**
1919
* Returns the appropriate Message subclass
20-
*
21-
* @param array $msg
2220
*/
2321
public static function parseArray(array $msg): AdvancedJsonRpcMessage
2422
{

0 commit comments

Comments
 (0)