Skip to content

Commit b68e96b

Browse files
authored
Normalize types of RootTypeMapperInterface (#520)
* psr/container v2 * Implement replacement for Picotainer * Replace Picotainer with LazyContainer in tests and documentation for version >=6 * Fix tests for phpdocumentor/type-resolver minor update * run cs-fix script * Fix some cs-fixer errors manually * fix return type * abandon psr/container ^1 * Test for LazyContainer * Normalize RootTypeMapperInterface
1 parent fed9ffe commit b68e96b

10 files changed

+14
-19
lines changed

src/Mappers/Root/BaseTypeMapper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function toGraphQLOutputType(Type $type, OutputType|null $subType, Reflec
7878
* @throws CannotMapTypeException
7979
* @throws CannotMapTypeExceptionInterface
8080
*/
81-
public function toGraphQLInputType(Type $type, InputType|GraphQLType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType|GraphQLType
81+
public function toGraphQLInputType(Type $type, InputType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType
8282
{
8383
$mappedType = $this->mapBaseType($type);
8484
if ($mappedType !== null) {

src/Mappers/Root/CompoundTypeMapper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function toGraphQLOutputType(Type $type, OutputType|null $subType, Reflec
8181
return $return;
8282
}
8383

84-
public function toGraphQLInputType(Type $type, InputType|GraphQLType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType|GraphQLType
84+
public function toGraphQLInputType(Type $type, InputType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType
8585
{
8686
if (! $type instanceof Compound) {
8787
return $this->next->toGraphQLInputType($type, $subType, $argumentName, $reflector, $docBlockObj);

src/Mappers/Root/EnumTypeMapper.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ public function toGraphQLOutputType(
6565
*/
6666
public function toGraphQLInputType(
6767
Type $type,
68-
InputType|GraphQLType|null $subType,
68+
InputType|null $subType,
6969
string $argumentName,
7070
ReflectionMethod|ReflectionProperty $reflector,
7171
DocBlock $docBlockObj,
72-
): InputType|GraphQLType
72+
): InputType
7373
{
7474
$result = $this->map($type);
7575
if ($result === null) {

src/Mappers/Root/FinalRootTypeMapper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function toGraphQLOutputType(Type $type, OutputType|null $subType, Reflec
4040
}
4141

4242
/** @throws CannotMapTypeException */
43-
public function toGraphQLInputType(Type $type, InputType|GraphQLType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType|GraphQLType
43+
public function toGraphQLInputType(Type $type, InputType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType
4444
{
4545
throw CannotMapTypeException::createForPhpDocType($type);
4646
}

src/Mappers/Root/IteratorTypeMapper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function toGraphQLOutputType(Type $type, OutputType|null $subType, Reflec
7070
return $result;
7171
}
7272

73-
public function toGraphQLInputType(Type $type, InputType|GraphQLType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType|GraphQLType
73+
public function toGraphQLInputType(Type $type, InputType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType
7474
{
7575
if (! $type instanceof Compound) {
7676
//try {

src/Mappers/Root/MyCLabsEnumTypeMapper.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use GraphQL\Type\Definition\InputType;
99
use GraphQL\Type\Definition\NamedType;
1010
use GraphQL\Type\Definition\OutputType;
11-
use GraphQL\Type\Definition\Type as GraphQLType;
1211
use MyCLabs\Enum\Enum;
1312
use phpDocumentor\Reflection\DocBlock;
1413
use phpDocumentor\Reflection\Type;
@@ -46,7 +45,7 @@ public function toGraphQLOutputType(Type $type, OutputType|null $subType, Reflec
4645
return $result ?? $this->next->toGraphQLOutputType($type, $subType, $reflector, $docBlockObj);
4746
}
4847

49-
public function toGraphQLInputType(Type $type, InputType|GraphQLType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType|GraphQLType
48+
public function toGraphQLInputType(Type $type, InputType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType
5049
{
5150
$result = $this->map($type);
5251
return $result ?? $this->next->toGraphQLInputType($type, $subType, $argumentName, $reflector, $docBlockObj);

src/Mappers/Root/NullableTypeMapperAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function toGraphQLOutputType(Type $type, OutputType|GraphQLType|null $sub
6565
return $graphQlType;
6666
}
6767

68-
public function toGraphQLInputType(Type $type, InputType|GraphQLType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType|GraphQLType
68+
public function toGraphQLInputType(Type $type, InputType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType
6969
{
7070
// Let's check a "null" value in the docblock
7171
$isNullable = $this->isNullable($type);

src/Mappers/Root/RootTypeMapperInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function toGraphQLOutputType(Type $type, OutputType|null $subType, Reflec
3737
*
3838
* @return InputType&GraphQLType
3939
*/
40-
public function toGraphQLInputType(Type $type, InputType|GraphQLType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType|GraphQLType;
40+
public function toGraphQLInputType(Type $type, InputType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType;
4141

4242
/**
4343
* Returns a GraphQL type by name.

tests/Mappers/Root/NullableTypeMapperAdapterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function toGraphQLOutputType(Type $type, ?OutputType $subType, $reflector
5555
return new NonNull(new StringType());
5656
}
5757

58-
public function toGraphQLInputType(Type $type, null|InputType|GraphQLType $subType, string $argumentName, $reflector, DocBlock $docBlockObj): InputType
58+
public function toGraphQLInputType(Type $type, null|InputType $subType, string $argumentName, $reflector, DocBlock $docBlockObj): InputType
5959
{
6060
throw new \RuntimeException('Not implemented');
6161
}

tests/Mappers/Root/VoidRootTypeMapper.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3+
declare(strict_types=1);
34

45
namespace TheCodingMachine\GraphQLite\Mappers\Root;
56

6-
77
use GraphQL\Type\Definition\InputType;
88
use GraphQL\Type\Definition\NamedType;
99
use GraphQL\Type\Definition\OutputType;
@@ -15,9 +15,7 @@
1515

1616
class VoidRootTypeMapper implements RootTypeMapperInterface
1717
{
18-
/**
19-
* @var RootTypeMapperInterface
20-
*/
18+
/** @var RootTypeMapperInterface */
2119
private $next;
2220

2321
public function __construct(RootTypeMapperInterface $next)
@@ -27,22 +25,20 @@ public function __construct(RootTypeMapperInterface $next)
2725

2826
/**
2927
* @param (OutputType&GraphQLType)|null $subType
30-
* @param ReflectionMethod|ReflectionProperty $reflector
3128
*
3229
* @return OutputType&GraphQLType
3330
*/
34-
public function toGraphQLOutputType(Type $type, ?OutputType $subType, $reflector, DocBlock $docBlockObj): OutputType
31+
public function toGraphQLOutputType(Type $type, OutputType|null $subType, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): OutputType
3532
{
3633
return $this->next->toGraphQLOutputType($type, $subType, $reflector, $docBlockObj);
3734
}
3835

3936
/**
4037
* @param (InputType&GraphQLType)|null $subType
41-
* @param ReflectionMethod|ReflectionProperty $reflector
4238
*
4339
* @return InputType&GraphQLType
4440
*/
45-
public function toGraphQLInputType(Type $type, null|InputType|GraphQLType $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType|GraphQLType
41+
public function toGraphQLInputType(Type $type, InputType|null $subType, string $argumentName, ReflectionMethod|ReflectionProperty $reflector, DocBlock $docBlockObj): InputType
4642
{
4743
return $this->next->toGraphQLInputType($type, $subType, $argumentName, $reflector, $docBlockObj);
4844
}

0 commit comments

Comments
 (0)