Server: added missing return $this; statements

This commit is contained in:
Vladimir Razuvaev 2017-02-27 18:19:09 +07:00
parent 752668df8d
commit 827bfa7907

View File

@ -311,10 +311,12 @@ class Server
* Expects function(\ErrorException $e) : array * Expects function(\ErrorException $e) : array
* *
* @param callable $phpErrorFormatter * @param callable $phpErrorFormatter
* @return $this
*/ */
public function setPhpErrorFormatter(callable $phpErrorFormatter) public function setPhpErrorFormatter(callable $phpErrorFormatter)
{ {
$this->phpErrorFormatter = $phpErrorFormatter; $this->phpErrorFormatter = $phpErrorFormatter;
return $this;
} }
/** /**
@ -329,10 +331,12 @@ class Server
* Expects function(Exception $e) : array * Expects function(Exception $e) : array
* *
* @param callable $exceptionFormatter * @param callable $exceptionFormatter
* @return $this
*/ */
public function setExceptionFormatter(callable $exceptionFormatter) public function setExceptionFormatter(callable $exceptionFormatter)
{ {
$this->exceptionFormatter = $exceptionFormatter; $this->exceptionFormatter = $exceptionFormatter;
return $this;
} }
/** /**
@ -345,10 +349,12 @@ class Server
/** /**
* @param string $unexpectedErrorMessage * @param string $unexpectedErrorMessage
* @return $this
*/ */
public function setUnexpectedErrorMessage($unexpectedErrorMessage) public function setUnexpectedErrorMessage($unexpectedErrorMessage)
{ {
$this->unexpectedErrorMessage = $unexpectedErrorMessage; $this->unexpectedErrorMessage = $unexpectedErrorMessage;
return $this;
} }
/** /**
@ -361,10 +367,12 @@ class Server
/** /**
* @param int $unexpectedErrorStatus * @param int $unexpectedErrorStatus
* @return $this
*/ */
public function setUnexpectedErrorStatus($unexpectedErrorStatus) public function setUnexpectedErrorStatus($unexpectedErrorStatus)
{ {
$this->unexpectedErrorStatus = $unexpectedErrorStatus; $this->unexpectedErrorStatus = $unexpectedErrorStatus;
return $this;
} }
/** /**
@ -528,8 +536,13 @@ class Server
if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) { if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
$raw = $this->readInput(); $raw = $this->readInput();
$data = json_decode($raw, true); $data = json_decode($raw, true);
Utils::invariant(
is_array($data),
"GraphQL Server expects JSON object with keys 'query' and 'variables', but got " . Utils::getVariableType($data)
);
} else { } else {
$data = $_REQUEST; $data = $_REQUEST ?: [];
} }
$data += ['query' => null, 'variables' => null]; $data += ['query' => null, 'variables' => null];
$result = $this->executeQuery($data['query'], (array) $data['variables'])->toArray(); $result = $this->executeQuery($data['query'], (array) $data['variables'])->toArray();