@@ -18,11 +18,11 @@ |
||
18 | 18 | public function getVisitor(ValidationContext $context) |
19 | 19 | { |
20 | 20 | return [ |
21 | - NodeKind::VARIABLE_DEFINITION => static function (VariableDefinitionNode $node) use ($context) { |
|
21 | + NodeKind::VARIABLE_DEFINITION => static function(VariableDefinitionNode $node) use ($context) { |
|
22 | 22 | $type = TypeInfo::typeFromAST($context->getSchema(), $node->type); |
23 | 23 | |
24 | 24 | // If the variable type is not an input type, return an error. |
25 | - if (! $type || Type::isInputType($type)) { |
|
25 | + if (!$type || Type::isInputType($type)) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | 28 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $this->knownOperationNames = []; |
23 | 23 | |
24 | 24 | return [ |
25 | - NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) use ($context) { |
|
25 | + NodeKind::OPERATION_DEFINITION => function(OperationDefinitionNode $node) use ($context) { |
|
26 | 26 | $operationName = $node->name; |
27 | 27 | |
28 | 28 | if ($operationName) { |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | return Visitor::skipNode(); |
40 | 40 | }, |
41 | - NodeKind::FRAGMENT_DEFINITION => static function () { |
|
41 | + NodeKind::FRAGMENT_DEFINITION => static function() { |
|
42 | 42 | return Visitor::skipNode(); |
43 | 43 | }, |
44 | 44 | ]; |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | public function getVisitor(ValidationContext $context) |
17 | 17 | { |
18 | 18 | return [ |
19 | - NodeKind::FIELD => static function (FieldNode $node) use ($context) { |
|
19 | + NodeKind::FIELD => static function(FieldNode $node) use ($context) { |
|
20 | 20 | $type = $context->getType(); |
21 | - if (! $type) { |
|
21 | + if (!$type) { |
|
22 | 22 | return; |
23 | 23 | } |
24 | 24 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | [$node->selectionSet] |
30 | 30 | )); |
31 | 31 | } |
32 | - } elseif (! $node->selectionSet) { |
|
32 | + } elseif (!$node->selectionSet) { |
|
33 | 33 | $context->reportError(new Error( |
34 | 34 | self::requiredSubselectionMessage($node->name->value, $type), |
35 | 35 | [$node] |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $queryComplexity->setRawVariableValues($variableValues); |
139 | 139 | } else { |
140 | 140 | foreach ($validationRules as $rule) { |
141 | - if (! ($rule instanceof QueryComplexity)) { |
|
141 | + if (!($rule instanceof QueryComplexity)) { |
|
142 | 142 | continue; |
143 | 143 | } |
144 | 144 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | $validationErrors = DocumentValidator::validate($schema, $documentNode, $validationRules); |
150 | 150 | |
151 | - if (! empty($validationErrors)) { |
|
151 | + if (!empty($validationErrors)) { |
|
152 | 152 | return $promiseAdapter->createFulfilled( |
153 | 153 | new ExecutionResult(null, $validationErrors) |
154 | 154 | ); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | if ($promiseAdapter instanceof SyncPromiseAdapter) { |
209 | 209 | $result = $promiseAdapter->wait($result)->toArray(); |
210 | 210 | } else { |
211 | - $result = $result->then(static function (ExecutionResult $r) { |
|
211 | + $result = $result->then(static function(ExecutionResult $r) { |
|
212 | 212 | return $r->toArray(); |
213 | 213 | }); |
214 | 214 | } |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | public static function assign($obj, array $vars, array $requiredKeys = []) |
85 | 85 | { |
86 | 86 | foreach ($requiredKeys as $key) { |
87 | - if (! isset($vars[$key])) { |
|
87 | + if (!isset($vars[$key])) { |
|
88 | 88 | throw new InvalidArgumentException(sprintf('Key %s is expected to be set and not to be null', $key)); |
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | 92 | foreach ($vars as $key => $value) { |
93 | - if (! property_exists($obj, $key)) { |
|
93 | + if (!property_exists($obj, $key)) { |
|
94 | 94 | $cls = get_class($obj); |
95 | 95 | Warning::warn( |
96 | 96 | sprintf("Trying to set non-existing property '%s' on class '%s'", $key, $cls), |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | $result = []; |
142 | 142 | $assoc = false; |
143 | 143 | foreach ($traversable as $key => $value) { |
144 | - if (! $assoc && ! is_int($key)) { |
|
144 | + if (!$assoc && !is_int($key)) { |
|
145 | 145 | $assoc = true; |
146 | 146 | } |
147 | - if (! $predicate($value, $key)) { |
|
147 | + if (!$predicate($value, $key)) { |
|
148 | 148 | continue; |
149 | 149 | } |
150 | 150 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $map = []; |
217 | 217 | foreach ($traversable as $key => $value) { |
218 | 218 | $newKey = $keyFn($value, $key); |
219 | - if (! is_scalar($newKey)) { |
|
219 | + if (!is_scalar($newKey)) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | public static function every($traversable, callable $predicate) |
296 | 296 | { |
297 | 297 | foreach ($traversable as $key => $value) { |
298 | - if (! $predicate($value, $key)) { |
|
298 | + if (!$predicate($value, $key)) { |
|
299 | 299 | return false; |
300 | 300 | } |
301 | 301 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public static function invariant($test, $message = '') |
311 | 311 | { |
312 | - if (! $test) { |
|
312 | + if (!$test) { |
|
313 | 313 | if (func_num_args() > 2) { |
314 | 314 | $args = func_get_args(); |
315 | 315 | array_shift($args); |
@@ -446,10 +446,10 @@ discard block |
||
446 | 446 | */ |
447 | 447 | public static function ord($char, $encoding = 'UTF-8') |
448 | 448 | { |
449 | - if (! $char && $char !== '0') { |
|
449 | + if (!$char && $char !== '0') { |
|
450 | 450 | return 0; |
451 | 451 | } |
452 | - if (! isset($char[1])) { |
|
452 | + if (!isset($char[1])) { |
|
453 | 453 | return ord($char); |
454 | 454 | } |
455 | 455 | if ($encoding !== 'UCS-4BE') { |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | ); |
528 | 528 | } |
529 | 529 | |
530 | - if (! preg_match('/^[_a-zA-Z][_a-zA-Z0-9]*$/', $name)) { |
|
530 | + if (!preg_match('/^[_a-zA-Z][_a-zA-Z0-9]*$/', $name)) { |
|
531 | 531 | return new Error( |
532 | 532 | sprintf('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "%s" does not.', $name), |
533 | 533 | $node |
@@ -547,9 +547,9 @@ discard block |
||
547 | 547 | */ |
548 | 548 | public static function withErrorHandling(callable $fn, array &$errors) |
549 | 549 | { |
550 | - return static function () use ($fn, &$errors) { |
|
550 | + return static function() use ($fn, &$errors) { |
|
551 | 551 | // Catch custom errors (to report them in query results) |
552 | - set_error_handler(static function ($severity, $message, $file, $line) use (&$errors) { |
|
552 | + set_error_handler(static function($severity, $message, $file, $line) use (&$errors) { |
|
553 | 553 | $errors[] = new ErrorException($message, 0, $severity, $file, $line); |
554 | 554 | }); |
555 | 555 | |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | public static function quotedOrList(array $items) |
570 | 570 | { |
571 | 571 | $items = array_map( |
572 | - static function ($item) { |
|
572 | + static function($item) { |
|
573 | 573 | return sprintf('"%s"', $item); |
574 | 574 | }, |
575 | 575 | $items |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | |
599 | 599 | return array_reduce( |
600 | 600 | range(1, $selectedLength - 1), |
601 | - static function ($list, $index) use ($selected, $selectedLength) { |
|
601 | + static function($list, $index) use ($selected, $selectedLength) { |
|
602 | 602 | return $list . |
603 | 603 | ($selectedLength > 2 ? ', ' : ' ') . |
604 | 604 | ($index === $selectedLength - 1 ? 'or ' : '') . |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $suggestions = Utils::suggestionList( |
99 | 99 | Utils::printSafe($value), |
100 | 100 | array_map( |
101 | - static function ($enumValue) { |
|
101 | + static function($enumValue) { |
|
102 | 102 | return $enumValue->name; |
103 | 103 | }, |
104 | 104 | $type->getValues() |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | if ($type instanceof InputObjectType) { |
150 | - if (! is_object($value) && ! is_array($value) && ! $value instanceof Traversable) { |
|
150 | + if (!is_object($value) && !is_array($value) && !$value instanceof Traversable) { |
|
151 | 151 | return self::ofErrors([ |
152 | 152 | self::coercionError( |
153 | 153 | sprintf('Expected type %s to be an object', $type->name), |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | $pathStr = ''; |
271 | 271 | $currentPath = $path; |
272 | 272 | while ($currentPath) { |
273 | - $pathStr = |
|
273 | + $pathStr = |
|
274 | 274 | (is_string($currentPath['key']) |
275 | 275 | ? '.' . $currentPath['key'] |
276 | 276 | : '[' . $currentPath['key'] . ']') . $pathStr; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | // Compute list of blame nodes. |
107 | 107 | if ($nodes instanceof Traversable) { |
108 | 108 | $nodes = iterator_to_array($nodes); |
109 | - } elseif ($nodes && ! is_array($nodes)) { |
|
109 | + } elseif ($nodes && !is_array($nodes)) { |
|
110 | 110 | $nodes = [$nodes]; |
111 | 111 | } |
112 | 112 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | public function getSource() |
213 | 213 | { |
214 | 214 | if ($this->source === null) { |
215 | - if (! empty($this->nodes[0]) && ! empty($this->nodes[0]->loc)) { |
|
215 | + if (!empty($this->nodes[0]) && !empty($this->nodes[0]->loc)) { |
|
216 | 216 | $this->source = $this->nodes[0]->loc->source; |
217 | 217 | } |
218 | 218 | } |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function getPositions() |
227 | 227 | { |
228 | - if ($this->positions === null && ! empty($this->nodes)) { |
|
228 | + if ($this->positions === null && !empty($this->nodes)) { |
|
229 | 229 | $positions = array_map( |
230 | - static function ($node) { |
|
230 | + static function($node) { |
|
231 | 231 | return isset($node->loc) ? $node->loc->start : null; |
232 | 232 | }, |
233 | 233 | $this->nodes |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | $positions = array_filter( |
237 | 237 | $positions, |
238 | - static function ($p) { |
|
238 | + static function($p) { |
|
239 | 239 | return $p !== null; |
240 | 240 | } |
241 | 241 | ); |
@@ -270,15 +270,15 @@ discard block |
||
270 | 270 | |
271 | 271 | if ($positions && $source) { |
272 | 272 | $this->locations = array_map( |
273 | - static function ($pos) use ($source) { |
|
273 | + static function($pos) use ($source) { |
|
274 | 274 | return $source->getLocation($pos); |
275 | 275 | }, |
276 | 276 | $positions |
277 | 277 | ); |
278 | 278 | } elseif ($nodes) { |
279 | - $locations = array_filter( |
|
279 | + $locations = array_filter( |
|
280 | 280 | array_map( |
281 | - static function ($node) { |
|
281 | + static function($node) { |
|
282 | 282 | if ($node->loc && $node->loc->source) { |
283 | 283 | return $node->loc->source->getLocation($node->loc->start); |
284 | 284 | } |
@@ -339,18 +339,18 @@ discard block |
||
339 | 339 | |
340 | 340 | $locations = Utils::map( |
341 | 341 | $this->getLocations(), |
342 | - static function (SourceLocation $loc) { |
|
342 | + static function(SourceLocation $loc) { |
|
343 | 343 | return $loc->toSerializableArray(); |
344 | 344 | } |
345 | 345 | ); |
346 | 346 | |
347 | - if (! empty($locations)) { |
|
347 | + if (!empty($locations)) { |
|
348 | 348 | $arr['locations'] = $locations; |
349 | 349 | } |
350 | - if (! empty($this->path)) { |
|
350 | + if (!empty($this->path)) { |
|
351 | 351 | $arr['path'] = $this->path; |
352 | 352 | } |
353 | - if (! empty($this->extensions)) { |
|
353 | + if (!empty($this->extensions)) { |
|
354 | 354 | $arr['extensions'] = $this->extensions; |
355 | 355 | } |
356 | 356 |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if ($error->nodes) { |
71 | 71 | /** @var Node $node */ |
72 | 72 | foreach ($error->nodes as $node) { |
73 | - if (! $node->loc) { |
|
73 | + if (!$node->loc) { |
|
74 | 74 | continue; |
75 | 75 | } |
76 | 76 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | - return ! $printedLocations |
|
93 | + return !$printedLocations |
|
94 | 94 | ? $error->getMessage() |
95 | 95 | : implode("\n\n", array_merge([$error->getMessage()], $printedLocations)) . "\n"; |
96 | 96 | } |
@@ -203,17 +203,17 @@ discard block |
||
203 | 203 | if ($e instanceof Error) { |
204 | 204 | $locations = Utils::map( |
205 | 205 | $e->getLocations(), |
206 | - static function (SourceLocation $loc) { |
|
206 | + static function(SourceLocation $loc) { |
|
207 | 207 | return $loc->toSerializableArray(); |
208 | 208 | } |
209 | 209 | ); |
210 | - if (! empty($locations)) { |
|
210 | + if (!empty($locations)) { |
|
211 | 211 | $formattedError['locations'] = $locations; |
212 | 212 | } |
213 | - if (! empty($e->path)) { |
|
213 | + if (!empty($e->path)) { |
|
214 | 214 | $formattedError['path'] = $e->path; |
215 | 215 | } |
216 | - if (! empty($e->getExtensions())) { |
|
216 | + if (!empty($e->getExtensions())) { |
|
217 | 217 | $formattedError['extensions'] = $e->getExtensions() + $formattedError['extensions']; |
218 | 218 | } |
219 | 219 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public static function addDebugEntries(array $formattedError, $e, $debug) |
241 | 241 | { |
242 | - if (! $debug) { |
|
242 | + if (!$debug) { |
|
243 | 243 | return $formattedError; |
244 | 244 | } |
245 | 245 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $debug = (int) $debug; |
253 | 253 | |
254 | 254 | if ($debug & Debug::RETHROW_INTERNAL_EXCEPTIONS) { |
255 | - if (! $e instanceof Error) { |
|
255 | + if (!$e instanceof Error) { |
|
256 | 256 | throw $e; |
257 | 257 | } |
258 | 258 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - $isUnsafe = ! $e instanceof ClientAware || ! $e->isClientSafe(); |
|
264 | + $isUnsafe = !$e instanceof ClientAware || !$e->isClientSafe(); |
|
265 | 265 | |
266 | 266 | if (($debug & Debug::RETHROW_UNSAFE_EXCEPTIONS) && $isUnsafe) { |
267 | 267 | if ($e->getPrevious()) { |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | ]; |
283 | 283 | } |
284 | 284 | |
285 | - $isTrivial = $e instanceof Error && ! $e->getPrevious(); |
|
285 | + $isTrivial = $e instanceof Error && !$e->getPrevious(); |
|
286 | 286 | |
287 | - if (! $isTrivial) { |
|
287 | + if (!$isTrivial) { |
|
288 | 288 | $debugging = $e->getPrevious() ?: $e; |
289 | 289 | $formattedError['trace'] = static::toSafeTrace($debugging); |
290 | 290 | } |
@@ -303,11 +303,11 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public static function prepareFormatter(?callable $formatter = null, $debug) |
305 | 305 | { |
306 | - $formatter = $formatter ?: static function ($e) { |
|
306 | + $formatter = $formatter ?: static function($e) { |
|
307 | 307 | return FormattedError::createFromException($e); |
308 | 308 | }; |
309 | 309 | if ($debug) { |
310 | - $formatter = static function ($e) use ($formatter, $debug) { |
|
310 | + $formatter = static function($e) use ($formatter, $debug) { |
|
311 | 311 | return FormattedError::addDebugEntries($formatter($e), $e, $debug); |
312 | 312 | }; |
313 | 313 | } |
@@ -332,18 +332,18 @@ discard block |
||
332 | 332 | // Remove invariant entries as they don't provide much value: |
333 | 333 | ($trace[0]['class'] . '::' . $trace[0]['function'] === 'GraphQL\Utils\Utils::invariant')) { |
334 | 334 | array_shift($trace); |
335 | - } elseif (! isset($trace[0]['file'])) { |
|
335 | + } elseif (!isset($trace[0]['file'])) { |
|
336 | 336 | // Remove root call as it's likely error handler trace: |
337 | 337 | array_shift($trace); |
338 | 338 | } |
339 | 339 | |
340 | 340 | return array_map( |
341 | - static function ($err) { |
|
341 | + static function($err) { |
|
342 | 342 | $safeErr = array_intersect_key($err, ['file' => true, 'line' => true]); |
343 | 343 | |
344 | 344 | if (isset($err['function'])) { |
345 | 345 | $func = $err['function']; |
346 | - $args = ! empty($err['args']) ? array_map([self::class, 'printVar'], $err['args']) : []; |
|
346 | + $args = !empty($err['args']) ? array_map([self::class, 'printVar'], $err['args']) : []; |
|
347 | 347 | $funcStr = $func . '(' . implode(', ', $args) . ')'; |
348 | 348 | |
349 | 349 | if (isset($err['class'])) { |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | { |
413 | 413 | $formatted = ['message' => $error]; |
414 | 414 | |
415 | - if (! empty($locations)) { |
|
415 | + if (!empty($locations)) { |
|
416 | 416 | $formatted['locations'] = array_map( |
417 | - static function ($loc) { |
|
417 | + static function($loc) { |
|
418 | 418 | return $loc->toArray(); |
419 | 419 | }, |
420 | 420 | $locations |
@@ -187,7 +187,7 @@ |
||
187 | 187 | $fields = []; |
188 | 188 | foreach ($selectionSet->selections as $selectionNode) { |
189 | 189 | if ($selectionNode instanceof FieldNode) { |
190 | - $fields[$selectionNode->name->value] = $descend > 0 && ! empty($selectionNode->selectionSet) |
|
190 | + $fields[$selectionNode->name->value] = $descend > 0 && !empty($selectionNode->selectionSet) |
|
191 | 191 | ? $this->foldSelectionSet($selectionNode->selectionSet, $descend - 1) |
192 | 192 | : true; |
193 | 193 | } elseif ($selectionNode instanceof FragmentSpreadNode) { |