Skip to content

Commit

Permalink
Fix compatibility of methods with native return type in PHP 8.1 (#1011)
Browse files Browse the repository at this point in the history
(cherry picked from commit 51ad17c)
  • Loading branch information
SilinMykola authored and spawnia committed Nov 15, 2021
1 parent d191b0c commit 527bdee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Error/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use GraphQL\Language\SourceLocation;
use GraphQL\Utils\Utils;
use JsonSerializable;
use ReturnTypeWillChange;
use Throwable;
use Traversable;
use function array_filter;
Expand Down Expand Up @@ -367,6 +368,7 @@ static function (SourceLocation $loc) : array {
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toSerializableArray();
Expand Down
2 changes: 2 additions & 0 deletions src/Language/SourceLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace GraphQL\Language;

use JsonSerializable;
use ReturnTypeWillChange;

class SourceLocation implements JsonSerializable
{
Expand Down Expand Up @@ -46,6 +47,7 @@ public function toSerializableArray()
/**
* @return int[]
*/
#[ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toSerializableArray();
Expand Down
5 changes: 4 additions & 1 deletion src/Type/Definition/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use GraphQL\Utils\Utils;
use JsonSerializable;
use ReflectionClass;
use ReturnTypeWillChange;

use function array_keys;
use function array_merge;
use function assert;
Expand Down Expand Up @@ -308,7 +310,8 @@ public function assertValid()
/**
* @return string
*/
public function jsonSerialize()
#[ReturnTypeWillChange]
public function jsonSerialize(): string
{
return $this->toString();
}
Expand Down

0 comments on commit 527bdee

Please sign in to comment.