Skip to content

Commit

Permalink
Merge pull request #8737 from weirdan/enforce-arrow-function-formatting
Browse files Browse the repository at this point in the history
Enforce arrow function formatting
  • Loading branch information
orklah committed Nov 23, 2022
2 parents 54db596 + 026354a commit 3b6faf9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
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

0 comments on commit 3b6faf9

Please sign in to comment.