From 644f97634b73d240e05144faaef1cfd9af958b0d Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Mon, 22 Oct 2018 22:40:02 +0200 Subject: [PATCH 1/2] Little fixes --- phpcs.xml.dist | 4 +++- src/Executor/Promise/Adapter/SyncPromise.php | 8 ++++---- src/Type/Definition/EnumType.php | 2 +- src/Utils/TypeInfo.php | 1 + src/Validator/Rules/OverlappingFieldsCanBeMerged.php | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index aba1cb2..803dd12 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -13,10 +13,12 @@ tests - + + + diff --git a/src/Executor/Promise/Adapter/SyncPromise.php b/src/Executor/Promise/Adapter/SyncPromise.php index 4d1f96e..91e139c 100644 --- a/src/Executor/Promise/Adapter/SyncPromise.php +++ b/src/Executor/Promise/Adapter/SyncPromise.php @@ -123,7 +123,7 @@ class SyncPromise if ($this->state === self::FULFILLED) { try { - $promise->resolve($onFulfilled ? $onFulfilled($this->result) : $this->result); + $promise->resolve($onFulfilled === null ? $this->result : $onFulfilled($this->result)); } catch (Exception $e) { $promise->reject($e); } catch (Throwable $e) { @@ -131,10 +131,10 @@ class SyncPromise } } elseif ($this->state === self::REJECTED) { try { - if ($onRejected) { - $promise->resolve($onRejected($this->result)); - } else { + if ($onRejected === null) { $promise->reject($this->result); + } else { + $promise->resolve($onRejected($this->result)); } } catch (Exception $e) { $promise->reject($e); diff --git a/src/Type/Definition/EnumType.php b/src/Type/Definition/EnumType.php index aa5c8b4..2b42590 100644 --- a/src/Type/Definition/EnumType.php +++ b/src/Type/Definition/EnumType.php @@ -188,7 +188,7 @@ class EnumType extends Type implements InputType, OutputType, LeafType, NamedTyp $lookup = $this->getNameLookup(); if (isset($lookup[$valueNode->value])) { $enumValue = $lookup[$valueNode->value]; - if ($enumValue) { + if ($enumValue !== null) { return $enumValue->value; } } diff --git a/src/Utils/TypeInfo.php b/src/Utils/TypeInfo.php index 722195d..430e7ad 100644 --- a/src/Utils/TypeInfo.php +++ b/src/Utils/TypeInfo.php @@ -22,6 +22,7 @@ use GraphQL\Type\Definition\InputType; use GraphQL\Type\Definition\InterfaceType; use GraphQL\Type\Definition\ListOfType; use GraphQL\Type\Definition\ObjectType; +use GraphQL\Type\Definition\OutputType; use GraphQL\Type\Definition\Type; use GraphQL\Type\Definition\UnionType; use GraphQL\Type\Definition\WrappingType; diff --git a/src/Validator/Rules/OverlappingFieldsCanBeMerged.php b/src/Validator/Rules/OverlappingFieldsCanBeMerged.php index d872245..8dfa7f1 100644 --- a/src/Validator/Rules/OverlappingFieldsCanBeMerged.php +++ b/src/Validator/Rules/OverlappingFieldsCanBeMerged.php @@ -366,8 +366,8 @@ class OverlappingFieldsCanBeMerged extends ValidationRule ); // The return type for each field. - $type1 = $def1 ? $def1->getType() : null; - $type2 = $def2 ? $def2->getType() : null; + $type1 = $def1 === null ? null : $def1->getType(); + $type2 = $def2 === null ? null : $def2->getType(); if (! $areMutuallyExclusive) { // Two aliases must refer to the same field. From 0d954b6ecc45a529fcdd893659fd3aa495c4e5e4 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Mon, 22 Oct 2018 22:40:19 +0200 Subject: [PATCH 2/2] Constrain PHPStan versions --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index c1f4afe..27bad9f 100644 --- a/composer.json +++ b/composer.json @@ -16,9 +16,9 @@ "require-dev": { "doctrine/coding-standard": "^5.0", "phpbench/phpbench": "^0.14.0", - "phpstan/phpstan": "^0.10.3", - "phpstan/phpstan-phpunit": "^0.10.0", - "phpstan/phpstan-strict-rules": "^0.10.1", + "phpstan/phpstan": "0.10.5", + "phpstan/phpstan-phpunit": "0.10.0", + "phpstan/phpstan-strict-rules": "0.10.1", "phpunit/phpunit": "^7.2", "psr/http-message": "^1.0", "react/promise": "2.*"