Skip to content

Commit

Permalink
SlevomatCodingStandard.ControlStructures.DisallowYodaComparison/Requi…
Browse files Browse the repository at this point in the history
…reYodaComparison: Fixed support for condition in arrow function
  • Loading branch information
kukulich committed Sep 21, 2022
1 parent 4131db1 commit 82a0002
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions SlevomatCodingStandard/Helpers/YodaHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use const T_DOUBLE_CAST;
use const T_DOUBLE_COLON;
use const T_FALSE;
use const T_FN_ARROW;
use const T_INLINE_ELSE;
use const T_INLINE_THEN;
use const T_INT_CAST;
Expand Down Expand Up @@ -346,6 +347,7 @@ private static function getStopTokenCodes(): array
T_COMMA => true,
T_CLOSE_CURLY_BRACKET => true,
T_MATCH_ARROW => true,
T_FN_ARROW => true,
];

$stopTokenCodes += array_fill_keys(array_keys(Tokens::$assignmentTokens), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ function ($condition, $actual) {
default => false,
};
};

$event = $actualEvents->find(
static fn (SpaceflowEvent $event): bool => $expectedEvent::class === $event::class,
);
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ function ($condition, $actual) {
default => false,
};
};

$event = $actualEvents->find(
static fn (SpaceflowEvent $event): bool => $expectedEvent::class === $event::class,
);

0 comments on commit 82a0002

Please sign in to comment.