Skip to content

Commit

Permalink
CS fix
Browse files Browse the repository at this point in the history
- trailing commas in calls with anon functions
- useless array docblock

Refs slevomat/coding-standard@8d0f603
Refs slevomat/coding-standard@6ea0278
  • Loading branch information
weirdan committed Mar 9, 2024
1 parent dca888c commit 8e1aa46
Show file tree
Hide file tree
Showing 29 changed files with 39 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/ClassAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ public static function addContextProperties(
$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 = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public static function verifyReturnType(
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static function analyze(
$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)]),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static function analyze(
$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),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public static function analyze(
$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),
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static function analyze(
$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),
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static function analyze(
$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),
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public static function analyze(
$possibilities,
static fn(Possibilities $assertion): bool => !(is_string($assertion->var_id)
&& strpos($assertion->var_id, '$this->') === 0
)
),
);
}
$statements_analyzer->node_data->setIfTrueAssertions(
Expand All @@ -469,7 +469,7 @@ public static function analyze(
$possibilities,
static fn(Possibilities $assertion): bool => !(is_string($assertion->var_id)
&& strpos($assertion->var_id, '$this->') === 0
)
),
);
}
$statements_analyzer->node_data->setIfFalseAssertions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public static function analyze(
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),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ private static function handleNamedCall(

$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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause {
$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),
),
);

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Cli/LanguageServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ static function (string $arg) use ($valid_long_options): void {
// 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)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Cli/Psalm.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public static function run(array $argv): void
// 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);
Expand Down Expand Up @@ -502,7 +502,7 @@ private static function generateConfig(string $current_dir, array &$args): void
&& $arg !== '--debug-emitted-issues'
&& strpos($arg, '--disable-extension=') !== 0
&& strpos($arg, '--root=') !== 0
&& strpos($arg, '--r=') !== 0
&& strpos($arg, '--r=') !== 0,
));

$init_level = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Cli/Psalter.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public static function run(array $argv): void
// 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([
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Cli/Refactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static function (string $arg) use ($valid_long_options): void {
// 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
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/CliUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ public static function checkRuntimeRequirements(): void

$missing_extensions = array_filter(
$required_extensions,
static fn(string $ext) => !extension_loaded($ext)
static fn(string $ext) => !extension_loaded($ext),
);

if ($missing_extensions) {
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Codebase/ClassLikes.php
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@ public function getConstantsForClass(string $class_name, int $visibility): array
$storage->constants,
static fn(ClassConstantStorage $constant): bool => $constant->type
&& ($constant->visibility === ClassLikeAnalyzer::VISIBILITY_PUBLIC
|| $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PROTECTED)
|| $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PROTECTED),
);
}

Expand Down Expand Up @@ -2410,7 +2410,7 @@ private function getConstantType(
fn(ClassConstantStorage $resolved_constant) => $this->filterConstantNameByVisibility(
$resolved_constant,
$visibility,
)
),
);

if ($filtered_constants_by_visibility === []) {
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Fork/PsalmRestarter.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function requiresRestart($default): bool
{
$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');
Expand Down
2 changes: 0 additions & 2 deletions src/Psalm/Internal/LanguageServer/LanguageClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ public function makeProgress(string $token): ProgressInterface

/**
* Configuration Refreshed from Client
*
* @param array $config
*/
private function configurationRefreshed(array $config): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ private static function improveParamsFromDocblock(

$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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Provider/FileReferenceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function getDeletedReferencedFiles(): array
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),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static function ($keyed_type) use ($statements_source, $context) {
},
$first_arg_array->properties,
),
static fn($keyed_type) => !$keyed_type->isNever()
static fn($keyed_type) => !$keyed_type->isNever(),
);

if (!$new_properties) {
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Type/TypeExpander.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ private static function expandNamedObject(
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(
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/IssueBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ public static function finish(
$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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Psalm/Type/Atomic.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public function isNamedObjectType(): bool
&& ($this->as->hasNamedObjectType()
|| array_filter(
$this->extra_types,
static fn($extra_type): bool => $extra_type->isNamedObjectType()
static fn($extra_type): bool => $extra_type->isNamedObjectType(),
)
)
);
Expand Down Expand Up @@ -545,7 +545,7 @@ public function hasTraversableInterface(Codebase $codebase): bool
$this->extra_types
&& array_filter(
$this->extra_types,
static fn(Atomic $a): bool => $a->hasTraversableInterface($codebase)
static fn(Atomic $a): bool => $a->hasTraversableInterface($codebase),
)
)
);
Expand All @@ -568,7 +568,7 @@ public function hasCountableInterface(Codebase $codebase): bool
$this->extra_types
&& array_filter(
$this->extra_types,
static fn(Atomic $a): bool => $a->hasCountableInterface($codebase)
static fn(Atomic $a): bool => $a->hasCountableInterface($codebase),
)
)
);
Expand Down Expand Up @@ -606,7 +606,7 @@ public function hasArrayAccessInterface(Codebase $codebase): bool
$this->extra_types
&& array_filter(
$this->extra_types,
static fn(Atomic $a): bool => $a->hasArrayAccessInterface($codebase)
static fn(Atomic $a): bool => $a->hasArrayAccessInterface($codebase),
)
)
);
Expand Down
14 changes: 7 additions & 7 deletions src/Psalm/Type/UnionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool

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),
);
}

Expand Down Expand Up @@ -459,7 +459,7 @@ public function hasArrayAccessInterface(Codebase $codebase): bool
{
return (bool)array_filter(
$this->types,
static fn($type): bool => $type->hasArrayAccessInterface($codebase)
static fn($type): bool => $type->hasArrayAccessInterface($codebase),
);
}

Expand Down Expand Up @@ -750,7 +750,7 @@ public function hasTemplate(): bool
$type->extra_types,
static fn($t): bool => $t instanceof TTemplateParam,
)
)
),
);
}

Expand Down Expand Up @@ -782,7 +782,7 @@ public function hasTemplateOrStatic(): bool
)
)
)
)
),
);
}

Expand Down Expand Up @@ -993,7 +993,7 @@ public function isInt(bool $check_templates = false): bool
|| ($check_templates
&& $type instanceof TTemplateParam
&& $type->as->isInt()
)
),
),
) === count($this->types);
}
Expand Down Expand Up @@ -1024,7 +1024,7 @@ public function isString(bool $check_templates = false): bool
|| ($check_templates
&& $type instanceof TTemplateParam
&& $type->as->isString()
)
),
),
) === count($this->types);
}
Expand All @@ -1043,7 +1043,7 @@ public function isNonEmptyString(bool $check_templates = false): bool
|| ($check_templates
&& $type instanceof TTemplateParam
&& $type->as->isNonEmptyString()
)
),
),
) === count($this->types);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/DocumentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public function testShortcodesAreUnique(): void

$duplicate_shortcodes = array_filter(
$all_shortcodes,
static fn($issues): bool => count($issues) > 1
static fn($issues): bool => count($issues) > 1,
);

$this->assertEquals(
Expand Down
2 changes: 0 additions & 2 deletions tests/LanguageServer/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ abstract class Message extends AdvancedJsonRpcMessage
{
/**
* Returns the appropriate Message subclass
*
* @param array $msg
*/
public static function parseArray(array $msg): AdvancedJsonRpcMessage
{
Expand Down

0 comments on commit 8e1aa46

Please sign in to comment.