Skip to content

Commit e8dfe9b

Browse files
authored
Enforce non-yoda style (#1074)
1 parent cf0c693 commit e8dfe9b

File tree

118 files changed

+590
-585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+590
-585
lines changed

.php-cs-fixer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@
1111
'no_superfluous_phpdoc_tags' => [
1212
'allow_mixed' => true,
1313
],
14+
'yoda_style' => [
15+
'equal' => false,
16+
'identical' => false,
17+
'less_and_greater' => false,
18+
],
1419
]);

benchmarks/LexerBench.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public function benchIntrospectionQuery(): void
3131

3232
do {
3333
$token = $lexer->advance();
34-
} while (Token::EOF !== $token->kind);
34+
} while ($token->kind !== Token::EOF);
3535
}
3636
}

benchmarks/Utils/QueryGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(Schema $schema, float $percentOfLeafFields)
3030
{
3131
$this->schema = $schema;
3232

33-
assert(0 < $percentOfLeafFields && $percentOfLeafFields <= 1);
33+
assert($percentOfLeafFields > 0 && $percentOfLeafFields <= 1);
3434

3535
$totalFields = 0;
3636
foreach ($schema->getTypeMap() as $type) {

benchmarks/Utils/SchemaGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function createType(int $nestingLevel, ?string $typeName = null): Obje
7070
}
7171

7272
++$this->typeIndex;
73-
if (null === $typeName) {
73+
if ($typeName === null) {
7474
$typeName = 'Level_' . $nestingLevel . '_Type' . $this->typeIndex;
7575
}
7676

examples/00-hello-world/graphql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
]);
5757

5858
$rawInput = file_get_contents('php://input');
59-
if (false === $rawInput) {
59+
if ($rawInput === false) {
6060
throw new RuntimeException('Failed to get php://input');
6161
}
6262

examples/01-blog/Blog/Data/DataSource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public static function findLatestStory(): ?Story
181181
*/
182182
public static function findStories(int $limit, ?int $afterId = null): array
183183
{
184-
$start = null !== $afterId
184+
$start = $afterId !== null
185185
? (int) array_search($afterId, array_keys(self::$stories), true) + 1
186186
: 0;
187187

examples/01-blog/Blog/Type/CommentType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function resolveAuthor(Comment $comment): ?User
6262

6363
public function resolveParent(Comment $comment): ?Comment
6464
{
65-
if (null !== $comment->parentId) {
65+
if ($comment->parentId !== null) {
6666
return DataSource::findComment($comment->parentId);
6767
}
6868

examples/01-blog/Blog/Type/Scalar/EmailType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ public function parseLiteral(Node $valueNode, ?array $variables = null): string
5454
*/
5555
private function isEmail($value): bool
5656
{
57-
return false !== filter_var($value, FILTER_VALIDATE_EMAIL);
57+
return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
5858
}
5959
}

examples/01-blog/Blog/Type/Scalar/UrlType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ public function parseLiteral(Node $valueNode, ?array $variables = null): string
5555
private function isUrl($value): bool
5656
{
5757
return is_string($value)
58-
&& false !== filter_var($value, FILTER_VALIDATE_URL);
58+
&& filter_var($value, FILTER_VALIDATE_URL) !== false;
5959
}
6060
}

examples/01-blog/graphql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
// Prepare context that will be available in all field resolvers (as 3rd argument):
3131
$appContext = new AppContext();
3232
$currentlyLoggedInUser = DataSource::findUser(1);
33-
assert(null !== $currentlyLoggedInUser);
33+
assert($currentlyLoggedInUser !== null);
3434
$appContext->viewer = $currentlyLoggedInUser;
3535
$appContext->rootUrl = 'http://localhost:8080';
3636
$appContext->request = $_REQUEST;

0 commit comments

Comments
 (0)