mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-21 20:36:05 +03:00
commit
0a71f9fba9
@ -96,7 +96,7 @@ final class Warning
|
||||
|
||||
public static function warnOnce(string $errorMessage, int $warningId, ?int $messageLevel = null) : void
|
||||
{
|
||||
if (self::$warningHandler) {
|
||||
if (self::$warningHandler !== null) {
|
||||
$fn = self::$warningHandler;
|
||||
$fn($errorMessage, $warningId);
|
||||
} elseif ((self::$enableWarnings & $warningId) > 0 && ! isset(self::$warned[$warningId])) {
|
||||
@ -107,7 +107,7 @@ final class Warning
|
||||
|
||||
public static function warn(string $errorMessage, int $warningId, ?int $messageLevel = null) : void
|
||||
{
|
||||
if (self::$warningHandler) {
|
||||
if (self::$warningHandler !== null) {
|
||||
$fn = self::$warningHandler;
|
||||
$fn($errorMessage, $warningId);
|
||||
} elseif ((self::$enableWarnings & $warningId) > 0) {
|
||||
|
@ -38,16 +38,16 @@ class SyncPromise
|
||||
*/
|
||||
private $waiting = [];
|
||||
|
||||
public static function runQueue()
|
||||
public static function runQueue() : void
|
||||
{
|
||||
$q = self::$queue;
|
||||
while ($q && ! $q->isEmpty()) {
|
||||
while ($q !== null && ! $q->isEmpty()) {
|
||||
$task = $q->dequeue();
|
||||
$task();
|
||||
}
|
||||
}
|
||||
|
||||
public function resolve($value)
|
||||
public function resolve($value) : self
|
||||
{
|
||||
switch ($this->state) {
|
||||
case self::PENDING:
|
||||
@ -83,7 +83,7 @@ class SyncPromise
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function reject($reason)
|
||||
public function reject($reason) : self
|
||||
{
|
||||
if (! $reason instanceof Exception && ! $reason instanceof Throwable) {
|
||||
throw new Exception('SyncPromise::reject() has to be called with an instance of \Throwable');
|
||||
@ -107,7 +107,7 @@ class SyncPromise
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function enqueueWaitingPromises()
|
||||
private function enqueueWaitingPromises() : void
|
||||
{
|
||||
Utils::invariant(
|
||||
$this->state !== self::PENDING,
|
||||
@ -116,7 +116,7 @@ class SyncPromise
|
||||
|
||||
foreach ($this->waiting as $descriptor) {
|
||||
self::getQueue()->enqueue(function () use ($descriptor) {
|
||||
/** @var $promise self */
|
||||
/** @var self $promise */
|
||||
[$promise, $onFulfilled, $onRejected] = $descriptor;
|
||||
|
||||
if ($this->state === self::FULFILLED) {
|
||||
@ -145,17 +145,17 @@ class SyncPromise
|
||||
$this->waiting = [];
|
||||
}
|
||||
|
||||
public static function getQueue()
|
||||
public static function getQueue() : SplQueue
|
||||
{
|
||||
return self::$queue ?: self::$queue = new SplQueue();
|
||||
}
|
||||
|
||||
public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
|
||||
{
|
||||
if ($this->state === self::REJECTED && ! $onRejected) {
|
||||
if ($this->state === self::REJECTED && $onRejected === null) {
|
||||
return $this;
|
||||
}
|
||||
if ($this->state === self::FULFILLED && ! $onFulfilled) {
|
||||
if ($this->state === self::FULFILLED && $onFulfilled === null) {
|
||||
return $this;
|
||||
}
|
||||
$tmp = new self();
|
||||
|
@ -92,7 +92,7 @@ class Values
|
||||
),
|
||||
[$varDefNode]
|
||||
);
|
||||
} elseif ($varDefNode->defaultValue) {
|
||||
} elseif ($varDefNode->defaultValue !== null) {
|
||||
$coercedValues[$varName] = AST::valueFromAST($varDefNode->defaultValue, $varType);
|
||||
}
|
||||
}
|
||||
@ -196,7 +196,7 @@ class Values
|
||||
$argType = $argumentDefinition->getType();
|
||||
$argumentValueNode = $argumentValueMap[$name] ?? null;
|
||||
|
||||
if (! $argumentValueNode) {
|
||||
if ($argumentValueNode === null) {
|
||||
if ($argumentDefinition->defaultValueExists()) {
|
||||
$coercedValues[$name] = $argumentDefinition->defaultValue;
|
||||
} elseif ($argType instanceof NonNull) {
|
||||
@ -209,7 +209,7 @@ class Values
|
||||
} elseif ($argumentValueNode instanceof VariableNode) {
|
||||
$variableName = $argumentValueNode->name->value;
|
||||
|
||||
if ($variableValues && array_key_exists($variableName, $variableValues)) {
|
||||
if ($variableValues !== null && array_key_exists($variableName, $variableValues)) {
|
||||
// Note: this does not check that this variable value is correct.
|
||||
// This assumes that this query has been validated and the variable
|
||||
// usage here is of the correct type.
|
||||
|
@ -199,7 +199,7 @@ class Collector
|
||||
if ($selection instanceof FieldNode) {
|
||||
/** @var FieldNode $selection */
|
||||
|
||||
$resultName = $selection->alias ? $selection->alias->value : $selection->name->value;
|
||||
$resultName = $selection->alias === null ? $selection->name->value : $selection->alias->value;
|
||||
|
||||
if (! isset($this->fields[$resultName])) {
|
||||
$this->fields[$resultName] = [];
|
||||
|
@ -498,7 +498,7 @@ class CoroutineExecutor implements Runtime, ExecutorImplementation
|
||||
|
||||
if ($type !== $this->schema->getType($type->name)) {
|
||||
$hint = '';
|
||||
if ($this->schema->getConfig()->typeLoader) {
|
||||
if ($this->schema->getConfig()->typeLoader !== null) {
|
||||
$hint = sprintf(
|
||||
'Make sure that type loader returns the same instance as defined in %s.%s',
|
||||
$ctx->type,
|
||||
@ -646,7 +646,7 @@ class CoroutineExecutor implements Runtime, ExecutorImplementation
|
||||
} else {
|
||||
if ($type !== $this->schema->getType($type->name)) {
|
||||
$hint = '';
|
||||
if ($this->schema->getConfig()->typeLoader) {
|
||||
if ($this->schema->getConfig()->typeLoader !== null) {
|
||||
$hint = sprintf(
|
||||
'Make sure that type loader returns the same instance as defined in %s.%s',
|
||||
$ctx->type,
|
||||
@ -904,7 +904,7 @@ class CoroutineExecutor implements Runtime, ExecutorImplementation
|
||||
return $this->schema->getType($value['__typename']);
|
||||
}
|
||||
|
||||
if ($abstractType instanceof InterfaceType && $this->schema->getConfig()->typeLoader) {
|
||||
if ($abstractType instanceof InterfaceType && $this->schema->getConfig()->typeLoader !== null) {
|
||||
Warning::warnOnce(
|
||||
sprintf(
|
||||
'GraphQL Interface Type `%s` returned `null` from its `resolveType` function ' .
|
||||
|
@ -69,7 +69,7 @@ class Location
|
||||
$this->endToken = $endToken;
|
||||
$this->source = $source;
|
||||
|
||||
if (! $startToken || ! $endToken) {
|
||||
if ($startToken === null || $endToken === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ abstract class Node
|
||||
|
||||
$tmp = (array) $this;
|
||||
|
||||
if ($this->loc) {
|
||||
if ($this->loc !== null) {
|
||||
$tmp['loc'] = [
|
||||
'start' => $this->loc->start,
|
||||
'end' => $this->loc->end,
|
||||
@ -125,7 +125,7 @@ abstract class Node
|
||||
'kind' => $node->kind,
|
||||
];
|
||||
|
||||
if ($node->loc) {
|
||||
if ($node->loc !== null) {
|
||||
$result['loc'] = [
|
||||
'start' => $node->loc->start,
|
||||
'end' => $node->loc->end,
|
||||
|
@ -314,11 +314,11 @@ class Lexer
|
||||
$start = $this->position;
|
||||
[$char, $code] = $this->readChar();
|
||||
|
||||
while ($code && (
|
||||
while ($code !== null && (
|
||||
$code === 95 || // _
|
||||
$code >= 48 && $code <= 57 || // 0-9
|
||||
$code >= 65 && $code <= 90 || // A-Z
|
||||
$code >= 97 && $code <= 122 // a-z
|
||||
($code >= 48 && $code <= 57) || // 0-9
|
||||
($code >= 65 && $code <= 90) || // A-Z
|
||||
($code >= 97 && $code <= 122) // a-z
|
||||
)) {
|
||||
$value .= $char;
|
||||
[$char, $code] = $this->moveStringCursor(1, 1)->readChar();
|
||||
@ -695,7 +695,7 @@ class Lexer
|
||||
do {
|
||||
[$char, $code, $bytes] = $this->moveStringCursor(1, $bytes)->readChar();
|
||||
$value .= $char;
|
||||
} while ($code &&
|
||||
} while ($code !== null &&
|
||||
// SourceCharacter but not LineTerminator
|
||||
($code > 0x001F || $code === 0x0009)
|
||||
);
|
||||
|
@ -1655,9 +1655,7 @@ class Parser
|
||||
$name = $this->parseName();
|
||||
$directives = $this->parseDirectives(true);
|
||||
$types = $this->parseUnionMemberTypes();
|
||||
if (count($directives) === 0 &&
|
||||
! $types
|
||||
) {
|
||||
if (count($directives) === 0 && count($types) === 0) {
|
||||
throw $this->unexpected();
|
||||
}
|
||||
|
||||
|
@ -11,28 +11,28 @@ namespace GraphQL\Language;
|
||||
class Token
|
||||
{
|
||||
// Each kind of token.
|
||||
const SOF = '<SOF>';
|
||||
const EOF = '<EOF>';
|
||||
const BANG = '!';
|
||||
const DOLLAR = '$';
|
||||
const AMP = '&';
|
||||
const PAREN_L = '(';
|
||||
const PAREN_R = ')';
|
||||
const SPREAD = '...';
|
||||
const COLON = ':';
|
||||
const EQUALS = '=';
|
||||
const AT = '@';
|
||||
const BRACKET_L = '[';
|
||||
const BRACKET_R = ']';
|
||||
const BRACE_L = '{';
|
||||
const PIPE = '|';
|
||||
const BRACE_R = '}';
|
||||
const NAME = 'Name';
|
||||
const INT = 'Int';
|
||||
const FLOAT = 'Float';
|
||||
const STRING = 'String';
|
||||
const BLOCK_STRING = 'BlockString';
|
||||
const COMMENT = 'Comment';
|
||||
public const SOF = '<SOF>';
|
||||
public const EOF = '<EOF>';
|
||||
public const BANG = '!';
|
||||
public const DOLLAR = '$';
|
||||
public const AMP = '&';
|
||||
public const PAREN_L = '(';
|
||||
public const PAREN_R = ')';
|
||||
public const SPREAD = '...';
|
||||
public const COLON = ':';
|
||||
public const EQUALS = '=';
|
||||
public const AT = '@';
|
||||
public const BRACKET_L = '[';
|
||||
public const BRACKET_R = ']';
|
||||
public const BRACE_L = '{';
|
||||
public const PIPE = '|';
|
||||
public const BRACE_R = '}';
|
||||
public const NAME = 'Name';
|
||||
public const INT = 'Int';
|
||||
public const FLOAT = 'Float';
|
||||
public const STRING = 'String';
|
||||
public const BLOCK_STRING = 'BlockString';
|
||||
public const COMMENT = 'Comment';
|
||||
|
||||
/**
|
||||
* The kind of Token (see one of constants above).
|
||||
@ -104,18 +104,15 @@ class Token
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
public function getDescription() : string
|
||||
{
|
||||
return $this->kind . ($this->value ? ' "' . $this->value . '"' : '');
|
||||
return $this->kind . ($this->value === null ? '' : ' "' . $this->value . '"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return (string|int|null)[]
|
||||
*/
|
||||
public function toArray()
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'kind' => $this->kind,
|
||||
|
@ -9,6 +9,7 @@ use function is_string;
|
||||
use function json_decode;
|
||||
use function json_last_error;
|
||||
use const CASE_LOWER;
|
||||
use const JSON_ERROR_NONE;
|
||||
|
||||
/**
|
||||
* Structure representing parsed HTTP parameters for GraphQL operation
|
||||
@ -93,7 +94,7 @@ class OperationParams
|
||||
}
|
||||
|
||||
$tmp = json_decode($params[$param], true);
|
||||
if (json_last_error()) {
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ use GraphQL\Language\DirectiveLocation;
|
||||
use GraphQL\Utils\Utils;
|
||||
use function array_key_exists;
|
||||
use function array_keys;
|
||||
use function count;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
|
||||
@ -16,11 +17,11 @@ class Directive
|
||||
{
|
||||
public const DEFAULT_DEPRECATION_REASON = 'No longer supported';
|
||||
|
||||
const INCLUDE_NAME = 'include';
|
||||
const IF_ARGUMENT_NAME = 'if';
|
||||
const SKIP_NAME = 'skip';
|
||||
const DEPRECATED_NAME = 'deprecated';
|
||||
const REASON_ARGUMENT_NAME = 'reason';
|
||||
public const INCLUDE_NAME = 'include';
|
||||
public const IF_ARGUMENT_NAME = 'if';
|
||||
public const SKIP_NAME = 'skip';
|
||||
public const DEPRECATED_NAME = 'deprecated';
|
||||
public const REASON_ARGUMENT_NAME = 'reason';
|
||||
|
||||
/** @var Directive[] */
|
||||
public static $internalDirectives;
|
||||
@ -84,9 +85,9 @@ class Directive
|
||||
/**
|
||||
* @return Directive[]
|
||||
*/
|
||||
public static function getInternalDirectives()
|
||||
public static function getInternalDirectives() : array
|
||||
{
|
||||
if (! self::$internalDirectives) {
|
||||
if (count(self::$internalDirectives) === 0) {
|
||||
self::$internalDirectives = [
|
||||
'include' => new self([
|
||||
'name' => self::INCLUDE_NAME,
|
||||
|
@ -168,7 +168,7 @@ class ObjectType extends Type implements OutputType, CompositeType, NullableType
|
||||
|
||||
private function getInterfaceMap()
|
||||
{
|
||||
if (! $this->interfaceMap) {
|
||||
if ($this->interfaceMap === null) {
|
||||
$this->interfaceMap = [];
|
||||
foreach ($this->getInterfaces() as $interface) {
|
||||
$this->interfaceMap[$interface->name] = $interface;
|
||||
|
@ -42,7 +42,7 @@ class SchemaConfig
|
||||
/** @var Directive[] */
|
||||
public $directives;
|
||||
|
||||
/** @var callable */
|
||||
/** @var callable|null */
|
||||
public $typeLoader;
|
||||
|
||||
/** @var SchemaDefinitionNode */
|
||||
|
Loading…
Reference in New Issue
Block a user