Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce arrow function formatting #8737

Merged
merged 1 commit into from Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions phpcs.xml
Expand Up @@ -245,4 +245,17 @@
<property name="allowNested" value="true"/>
</properties>
</rule>

<!--
Forces uniform arrow function style
https://github.com/slevomat/coding-standard/blob/master/doc/functions.md#slevomatcodingstandardfunctionsarrowfunctiondeclaration-
-->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="0"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
<property name="allowMultiLine" value="true"/>
</properties>
</rule>
</ruleset>
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/MethodComparator.php
Expand Up @@ -127,7 +127,7 @@ public static function compare(
&& !$implementer_method_storage->signature_return_type
&& !array_filter(
$implementer_method_storage->attributes,
static fn (AttributeStorage $s): bool => $s->fq_class_name === 'ReturnTypeWillChange'
static fn(AttributeStorage $s): bool => $s->fq_class_name === 'ReturnTypeWillChange'
)
) {
IssueBuffer::maybeAdd(
Expand Down
Expand Up @@ -100,7 +100,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev
/** @param non-empty-array<?Union> $sub */
function (array $sub) use ($null) {
$sub = array_map(
fn (?Union $t) => $t ?? $null,
fn(?Union $t) => $t ?? $null,
$sub
);
return new Union([new TKeyedArray($sub, null, null, true)]);
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Type/SimpleAssertionReconciler.php
Expand Up @@ -649,7 +649,7 @@ private static function reconcileNonEmptyCountable(
$existing_var_type->removeType('array');
$existing_var_type->addType($array_atomic_type->setProperties(
array_map(
fn (Union $union) => $union->setPossiblyUndefined(false),
fn(Union $union) => $union->setPossiblyUndefined(false),
$array_atomic_type->properties
)
));
Expand Down Expand Up @@ -740,7 +740,7 @@ private static function reconcileExactlyCountable(
$existing_var_type->removeType('array');
$existing_var_type->addType($array_atomic_type->setProperties(
array_map(
fn (Union $union) => $union->setPossiblyUndefined(false),
fn(Union $union) => $union->setPossiblyUndefined(false),
$array_atomic_type->properties
)
));
Expand Down