Skip to content

Commit 827bfa7

Browse files
committed
Server: added missing return $this; statements
1 parent 752668d commit 827bfa7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Server.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,12 @@ public function getPhpErrorFormatter()
311311
* Expects function(\ErrorException $e) : array
312312
*
313313
* @param callable $phpErrorFormatter
314+
* @return $this
314315
*/
315316
public function setPhpErrorFormatter(callable $phpErrorFormatter)
316317
{
317318
$this->phpErrorFormatter = $phpErrorFormatter;
319+
return $this;
318320
}
319321

320322
/**
@@ -329,10 +331,12 @@ public function getExceptionFormatter()
329331
* Expects function(Exception $e) : array
330332
*
331333
* @param callable $exceptionFormatter
334+
* @return $this
332335
*/
333336
public function setExceptionFormatter(callable $exceptionFormatter)
334337
{
335338
$this->exceptionFormatter = $exceptionFormatter;
339+
return $this;
336340
}
337341

338342
/**
@@ -345,10 +349,12 @@ public function getUnexpectedErrorMessage()
345349

346350
/**
347351
* @param string $unexpectedErrorMessage
352+
* @return $this
348353
*/
349354
public function setUnexpectedErrorMessage($unexpectedErrorMessage)
350355
{
351356
$this->unexpectedErrorMessage = $unexpectedErrorMessage;
357+
return $this;
352358
}
353359

354360
/**
@@ -361,10 +367,12 @@ public function getUnexpectedErrorStatus()
361367

362368
/**
363369
* @param int $unexpectedErrorStatus
370+
* @return $this
364371
*/
365372
public function setUnexpectedErrorStatus($unexpectedErrorStatus)
366373
{
367374
$this->unexpectedErrorStatus = $unexpectedErrorStatus;
375+
return $this;
368376
}
369377

370378
/**
@@ -528,8 +536,13 @@ public function handleRequest()
528536
if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
529537
$raw = $this->readInput();
530538
$data = json_decode($raw, true);
539+
540+
Utils::invariant(
541+
is_array($data),
542+
"GraphQL Server expects JSON object with keys 'query' and 'variables', but got " . Utils::getVariableType($data)
543+
);
531544
} else {
532-
$data = $_REQUEST;
545+
$data = $_REQUEST ?: [];
533546
}
534547
$data += ['query' => null, 'variables' => null];
535548
$result = $this->executeQuery($data['query'], (array) $data['variables'])->toArray();

0 commit comments

Comments
 (0)