Skip to content

Commit 6859a9e

Browse files
committed
Stricter types
1 parent 00c3e6d commit 6859a9e

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/UploadType.php

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use GraphQL\Error\Error;
88
use GraphQL\Error\InvariantViolation;
9+
use GraphQL\Language\AST\Node;
910
use GraphQL\Type\Definition\ScalarType;
1011
use GraphQL\Utils\Utils;
1112
use Psr\Http\Message\UploadedFileInterface;
@@ -27,24 +28,16 @@ class UploadType extends ScalarType
2728

2829
/**
2930
* Serializes an internal value to include in a response.
30-
*
31-
* @param mixed $value
32-
*
33-
* @return mixed
3431
*/
35-
public function serialize($value)
32+
public function serialize(mixed $value): never
3633
{
3734
throw new InvariantViolation('`Upload` cannot be serialized');
3835
}
3936

4037
/**
4138
* Parses an externally provided value (query variable) to use as an input.
42-
*
43-
* @param mixed $value
44-
*
45-
* @return UploadedFileInterface
4639
*/
47-
public function parseValue($value)
40+
public function parseValue(mixed $value): UploadedFileInterface
4841
{
4942
if (!$value instanceof UploadedFileInterface) {
5043
throw new UnexpectedValueException('Could not get uploaded file, be sure to conform to GraphQL multipart request specification. Instead got: ' . Utils::printSafe($value));
@@ -55,12 +48,8 @@ public function parseValue($value)
5548

5649
/**
5750
* Parses an externally provided literal value (hardcoded in GraphQL query) to use as an input.
58-
*
59-
* @param \GraphQL\Language\AST\Node $valueNode
60-
*
61-
* @return mixed
6251
*/
63-
public function parseLiteral($valueNode, ?array $variables = null)
52+
public function parseLiteral(Node $valueNode, ?array $variables = null): mixed
6453
{
6554
throw new Error('`Upload` cannot be hardcoded in query, be sure to conform to GraphQL multipart request specification. Instead got: ' . $valueNode->kind, $valueNode);
6655
}

0 commit comments

Comments
 (0)