Skip to content

Commit b2c9686

Browse files
committed
composer update and apply php-cs-fixer
1 parent 52854f3 commit b2c9686

File tree

15 files changed

+64
-162
lines changed

15 files changed

+64
-162
lines changed

benchmarks/HugeSchemaBench.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ private function createLazySchema(): Schema
7070
{
7171
return new Schema(
7272
(new SchemaConfig())
73-
->setQuery($this->schemaGenerator->buildQueryType())
74-
->setTypeLoader(fn (string $name): Type => $this->schemaGenerator->loadType($name))
73+
->setQuery($this->schemaGenerator->buildQueryType())
74+
->setTypeLoader(fn (string $name): Type => $this->schemaGenerator->loadType($name))
7575
);
7676
}
7777
}

benchmarks/Utils/SchemaGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function buildSchema(): Schema
3535
{
3636
return new Schema(
3737
(new SchemaConfig())
38-
->setQuery($this->buildQueryType())
38+
->setQuery($this->buildQueryType())
3939
);
4040
}
4141

examples/00-hello-world/graphql.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
// https://webonyx.github.io/graphql-php/schema-definition/#configuration-options
5050
$schema = new Schema(
5151
(new SchemaConfig())
52-
->setQuery($queryType)
53-
->setMutation($mutationType)
52+
->setQuery($queryType)
53+
->setMutation($mutationType)
5454
);
5555

5656
$rawInput = file_get_contents('php://input');

examples/03-standard-server/graphql.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
// https://webonyx.github.io/graphql-php/schema-definition/#configuration-options
4949
$schema = new Schema(
5050
(new SchemaConfig())
51-
->setQuery($queryType)
52-
->setMutation($mutationType)
51+
->setQuery($queryType)
52+
->setMutation($mutationType)
5353
);
5454

5555
$rootValue = ['prefix' => 'You said: '];

src/Executor/ReferenceExecutor.php

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -355,41 +355,29 @@ protected function getOperationRootType(Schema $schema, OperationDefinitionNode
355355
case 'query':
356356
$queryType = $schema->getQueryType();
357357
if ($queryType === null) {
358-
throw new Error(
359-
'Schema does not define the required query root type.',
360-
[$operation]
361-
);
358+
throw new Error('Schema does not define the required query root type.', [$operation]);
362359
}
363360

364361
return $queryType;
365362

366363
case 'mutation':
367364
$mutationType = $schema->getMutationType();
368365
if ($mutationType === null) {
369-
throw new Error(
370-
'Schema is not configured for mutations.',
371-
[$operation]
372-
);
366+
throw new Error('Schema is not configured for mutations.', [$operation]);
373367
}
374368

375369
return $mutationType;
376370

377371
case 'subscription':
378372
$subscriptionType = $schema->getSubscriptionType();
379373
if ($subscriptionType === null) {
380-
throw new Error(
381-
'Schema is not configured for subscriptions.',
382-
[$operation]
383-
);
374+
throw new Error('Schema is not configured for subscriptions.', [$operation]);
384375
}
385376

386377
return $subscriptionType;
387378

388379
default:
389-
throw new Error(
390-
'Can only execute queries, mutations and subscriptions.',
391-
[$operation]
392-
);
380+
throw new Error('Can only execute queries, mutations and subscriptions.', [$operation]);
393381
}
394382
}
395383

@@ -1075,11 +1063,7 @@ protected function completeLeafValue(LeafType $returnType, &$result)
10751063
} catch (\Throwable $error) {
10761064
$safeReturnType = Utils::printSafe($returnType);
10771065
$safeResult = Utils::printSafe($result);
1078-
throw new InvariantViolation(
1079-
"Expected a value of type {$safeReturnType} but received: {$safeResult}. {$error->getMessage()}",
1080-
0,
1081-
$error
1082-
);
1066+
throw new InvariantViolation("Expected a value of type {$safeReturnType} but received: {$safeResult}. {$error->getMessage()}", 0, $error);
10831067
}
10841068
}
10851069

src/Executor/Values.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -238,23 +238,14 @@ public static function getArgumentValuesForMap($def, array $argumentValueMap, ?a
238238
$safeArgType = Utils::printSafe($argType);
239239

240240
if ($isNull) {
241-
throw new Error(
242-
"Argument \"{$name}\" of non-null type \"{$safeArgType}\" must not be null.",
243-
$referenceNode
244-
);
241+
throw new Error("Argument \"{$name}\" of non-null type \"{$safeArgType}\" must not be null.", $referenceNode);
245242
}
246243

247244
if ($argumentValueNode instanceof VariableNode) {
248-
throw new Error(
249-
"Argument \"{$name}\" of required type \"{$safeArgType}\" was provided the variable \"\${$argumentValueNode->name->value}\" which was not provided a runtime value.",
250-
[$argumentValueNode]
251-
);
245+
throw new Error("Argument \"{$name}\" of required type \"{$safeArgType}\" was provided the variable \"\${$argumentValueNode->name->value}\" which was not provided a runtime value.", [$argumentValueNode]);
252246
}
253247

254-
throw new Error(
255-
"Argument \"{$name}\" of required type \"{$safeArgType}\" was not provided.",
256-
$referenceNode
257-
);
248+
throw new Error("Argument \"{$name}\" of required type \"{$safeArgType}\" was not provided.", $referenceNode);
258249
} elseif ($hasValue) {
259250
assert($argumentValueNode instanceof Node);
260251

@@ -275,10 +266,7 @@ public static function getArgumentValuesForMap($def, array $argumentValueMap, ?a
275266
// execution. This is a runtime check to ensure execution does not
276267
// continue with an invalid argument value.
277268
$invalidValue = Printer::doPrint($argumentValueNode);
278-
throw new Error(
279-
"Argument \"{$name}\" has invalid value {$invalidValue}.",
280-
[$argumentValueNode]
281-
);
269+
throw new Error("Argument \"{$name}\" has invalid value {$invalidValue}.", [$argumentValueNode]);
282270
}
283271

284272
$coercedValues[$name] = $coercedValue;

src/Language/Lexer.php

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,7 @@ private function readToken(Token $prev): Token
244244
->readString($line, $col, $prev);
245245
}
246246

247-
throw new SyntaxError(
248-
$this->source,
249-
$position,
250-
$this->unexpectedCharacterMessage($code)
251-
);
247+
throw new SyntaxError($this->source, $position, $this->unexpectedCharacterMessage($code));
252248
}
253249

254250
/** @throws \JsonException */
@@ -329,11 +325,7 @@ private function readNumber(int $line, int $col, Token $prev): Token
329325
[$char, $code] = $this->moveStringCursor(1, 1)->readChar();
330326

331327
if ($code >= 48 && $code <= 57) {
332-
throw new SyntaxError(
333-
$this->source,
334-
$this->position,
335-
'Invalid number, unexpected digit after 0: ' . Utils::printCharCode($code)
336-
);
328+
throw new SyntaxError($this->source, $this->position, 'Invalid number, unexpected digit after 0: ' . Utils::printCharCode($code));
337329
}
338330
} else {
339331
$value .= $this->readDigits();
@@ -398,11 +390,7 @@ private function readDigits(): string
398390
$code = null;
399391
}
400392

401-
throw new SyntaxError(
402-
$this->source,
403-
$this->position,
404-
'Invalid number, expected digit but got: ' . Utils::printCharCode($code)
405-
);
393+
throw new SyntaxError($this->source, $this->position, 'Invalid number, expected digit but got: ' . Utils::printCharCode($code));
406394
}
407395

408396
/**
@@ -477,11 +465,7 @@ private function readString(int $line, int $col, Token $prev): Token
477465
$position = $this->position;
478466
[$hex] = $this->readChars(4);
479467
if (\preg_match('/[0-9a-fA-F]{4}/', $hex) !== 1) {
480-
throw new SyntaxError(
481-
$this->source,
482-
$position - 1,
483-
"Invalid character escape sequence: \\u{$hex}"
484-
);
468+
throw new SyntaxError($this->source, $position - 1, "Invalid character escape sequence: \\u{$hex}");
485469
}
486470

487471
$code = \hexdec($hex);
@@ -492,11 +476,7 @@ private function readString(int $line, int $col, Token $prev): Token
492476
if ($highOrderByte >= 0xD8 && $highOrderByte <= 0xDF) {
493477
[$utf16Continuation] = $this->readChars(6);
494478
if (\preg_match('/^\\\u[0-9a-fA-F]{4}$/', $utf16Continuation) !== 1) {
495-
throw new SyntaxError(
496-
$this->source,
497-
$this->position - 5,
498-
'Invalid UTF-16 trailing surrogate: ' . $utf16Continuation
499-
);
479+
throw new SyntaxError($this->source, $this->position - 5, 'Invalid UTF-16 trailing surrogate: ' . $utf16Continuation);
500480
}
501481

502482
$surrogatePairHex = $hex . \substr($utf16Continuation, 2, 4);
@@ -513,11 +493,7 @@ private function readString(int $line, int $col, Token $prev): Token
513493
continue 2;
514494
default:
515495
$chr = Utils::chr($code);
516-
throw new SyntaxError(
517-
$this->source,
518-
$this->position - 1,
519-
"Invalid character escape sequence: \\{$chr}"
520-
);
496+
throw new SyntaxError($this->source, $this->position - 1, "Invalid character escape sequence: \\{$chr}");
521497
}
522498

523499
$chunk = '';
@@ -528,11 +504,7 @@ private function readString(int $line, int $col, Token $prev): Token
528504
[$char, $code, $bytes] = $this->readChar();
529505
}
530506

531-
throw new SyntaxError(
532-
$this->source,
533-
$this->position,
534-
'Unterminated string.'
535-
);
507+
throw new SyntaxError($this->source, $this->position, 'Unterminated string.');
536508
}
537509

538510
/**
@@ -612,11 +584,7 @@ private function readBlockString(int $line, int $col, Token $prev): Token
612584
[$char, $code, $bytes] = $this->readChar();
613585
}
614586

615-
throw new SyntaxError(
616-
$this->source,
617-
$this->position,
618-
'Unterminated string.'
619-
);
587+
throw new SyntaxError($this->source, $this->position, 'Unterminated string.');
620588
}
621589

622590
/**

src/Language/Parser.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,7 @@ private function expect(string $kind): Token
379379
return $token;
380380
}
381381

382-
throw new SyntaxError(
383-
$this->lexer->source,
384-
$token->start,
385-
"Expected {$kind}, found {$token->getDescription()}"
386-
);
382+
throw new SyntaxError($this->lexer->source, $token->start, "Expected {$kind}, found {$token->getDescription()}");
387383
}
388384

389385
/**
@@ -397,11 +393,7 @@ private function expectKeyword(string $value): void
397393
{
398394
$token = $this->lexer->token;
399395
if ($token->kind !== Token::NAME || $token->value !== $value) {
400-
throw new SyntaxError(
401-
$this->lexer->source,
402-
$token->start,
403-
"Expected \"{$value}\", found {$token->getDescription()}"
404-
);
396+
throw new SyntaxError($this->lexer->source, $token->start, "Expected \"{$value}\", found {$token->getDescription()}");
405397
}
406398

407399
$this->lexer->advance();

src/Type/Definition/EnumType.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,7 @@ public function parseLiteral(Node $valueNode, ?array $variables = null)
197197
{
198198
if (! $valueNode instanceof EnumValueNode) {
199199
$valueStr = Printer::doPrint($valueNode);
200-
throw new Error(
201-
"Enum \"{$this->name}\" cannot represent non-enum value: {$valueStr}.{$this->didYouMean($valueStr)}",
202-
$valueNode
203-
);
200+
throw new Error("Enum \"{$this->name}\" cannot represent non-enum value: {$valueStr}.{$this->didYouMean($valueStr)}", $valueNode);
204201
}
205202

206203
$name = $valueNode->value;

src/Utils/ASTDefinitionBuilder.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,7 @@ private function internalBuildType(string $typeName, ?Node $typeNode = null): Ty
275275
);
276276
} catch (\Throwable $e) {
277277
$class = static::class;
278-
throw new Error(
279-
"Type config decorator passed to {$class} threw an error when building {$typeName} type: {$e->getMessage()}",
280-
null,
281-
null,
282-
[],
283-
null,
284-
$e
285-
);
278+
throw new Error("Type config decorator passed to {$class} threw an error when building {$typeName} type: {$e->getMessage()}", null, null, [], null, $e);
286279
}
287280

288281
// @phpstan-ignore-next-line should not happen, but function types are not enforced by PHP

src/Utils/BuildClientSchema.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ public function buildSchema(): Schema
151151

152152
return new Schema(
153153
(new SchemaConfig())
154-
->setQuery($queryType)
155-
->setMutation($mutationType)
156-
->setSubscription($subscriptionType)
157-
->setTypes($this->typeMap)
158-
->setDirectives($directives)
159-
->setAssumeValid($this->options['assumeValid'] ?? false)
154+
->setQuery($queryType)
155+
->setMutation($mutationType)
156+
->setSubscription($subscriptionType)
157+
->setTypes($this->typeMap)
158+
->setDirectives($directives)
159+
->setAssumeValid($this->options['assumeValid'] ?? false)
160160
);
161161
}
162162

src/Utils/BuildSchema.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -245,24 +245,24 @@ static function (string $typeName): Type {
245245
return new Schema(
246246
(new SchemaConfig())
247247
// @phpstan-ignore-next-line
248-
->setQuery(isset($operationTypes['query'])
249-
? $definitionBuilder->maybeBuildType($operationTypes['query'])
250-
: null)
248+
->setQuery(isset($operationTypes['query'])
249+
? $definitionBuilder->maybeBuildType($operationTypes['query'])
250+
: null)
251251
// @phpstan-ignore-next-line
252-
->setMutation(isset($operationTypes['mutation'])
253-
? $definitionBuilder->maybeBuildType($operationTypes['mutation'])
254-
: null)
252+
->setMutation(isset($operationTypes['mutation'])
253+
? $definitionBuilder->maybeBuildType($operationTypes['mutation'])
254+
: null)
255255
// @phpstan-ignore-next-line
256-
->setSubscription(isset($operationTypes['subscription'])
257-
? $definitionBuilder->maybeBuildType($operationTypes['subscription'])
258-
: null)
259-
->setTypeLoader(static fn (string $name): ?Type => $definitionBuilder->maybeBuildType($name))
260-
->setDirectives($directives)
261-
->setAstNode($schemaDef)
262-
->setTypes(fn (): array => \array_map(
263-
static fn (TypeDefinitionNode $def): Type => $definitionBuilder->buildType($def->getName()->value),
264-
$typeDefinitionsMap,
265-
))
256+
->setSubscription(isset($operationTypes['subscription'])
257+
? $definitionBuilder->maybeBuildType($operationTypes['subscription'])
258+
: null)
259+
->setTypeLoader(static fn (string $name): ?Type => $definitionBuilder->maybeBuildType($name))
260+
->setDirectives($directives)
261+
->setAstNode($schemaDef)
262+
->setTypes(fn (): array => \array_map(
263+
static fn (TypeDefinitionNode $def): Type => $definitionBuilder->buildType($def->getName()->value),
264+
$typeDefinitionsMap,
265+
))
266266
);
267267
}
268268

src/Validator/Rules/QueryComplexity.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,7 @@ protected function directiveExcludesField(FieldNode $node): bool
179179
$this->getRawVariableValues()
180180
);
181181
if ($errors !== null && $errors !== []) {
182-
throw new Error(\implode(
183-
"\n\n",
184-
\array_map(
185-
static fn (Error $error): string => $error->getMessage(),
186-
$errors
187-
)
188-
));
182+
throw new Error(\implode("\n\n", \array_map(static fn (Error $error): string => $error->getMessage(), $errors)));
189183
}
190184

191185
if ($directiveNode->name->value === Directive::INCLUDE_NAME) {
@@ -248,13 +242,7 @@ protected function buildFieldArguments(FieldNode $node): array
248242
);
249243

250244
if (is_array($errors) && $errors !== []) {
251-
throw new Error(\implode(
252-
"\n\n",
253-
\array_map(
254-
static fn ($error) => $error->getMessage(),
255-
$errors
256-
)
257-
));
245+
throw new Error(\implode("\n\n", \array_map(static fn ($error) => $error->getMessage(), $errors)));
258246
}
259247

260248
$args = Values::getArgumentValues($fieldDef, $node, $variableValues);

0 commit comments

Comments
 (0)