Skip to content

Commit 234cb87

Browse files
committed
stanning
1 parent 98f7ccc commit 234cb87

File tree

5 files changed

+20
-25
lines changed

5 files changed

+20
-25
lines changed

src/Type/Definition/ListOfType.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,24 @@
99
class ListOfType extends Type implements WrappingType, OutputType, NullableType, InputType
1010
{
1111
/** @var ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType */
12-
private $_ofType;
12+
private $ofType;
1313

1414
/**
1515
* @param callable|Type $type
1616
*/
1717
public function __construct($type)
1818
{
19-
$this->_ofType = is_callable($type) ? $type : Type::assertType($type);
19+
$this->ofType = is_callable($type) ? $type : Type::assertType($type);
2020
}
2121

2222
public function toString() : string
2323
{
24-
return '[' . $this->ofType->toString() . ']';
24+
return '[' . $this->getOfType()->toString() . ']';
2525
}
2626

27-
public function __get($name)
27+
public function getOfType()
2828
{
29-
switch ($name) {
30-
case 'ofType':
31-
return Type::resolveLazyType($this->_ofType);
32-
}
29+
return Type::resolveLazyType($this->ofType);
3330
}
3431

3532
/**
@@ -39,7 +36,7 @@ public function __get($name)
3936
*/
4037
public function getWrappedType($recurse = false)
4138
{
42-
$type = $this->ofType;
39+
$type = $this->getOfType();
4340

4441
return $recurse && $type instanceof WrappingType
4542
? $type->getWrappedType($recurse)

src/Type/Definition/NonNull.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,14 @@
1010
class NonNull extends Type implements WrappingType, OutputType, InputType
1111
{
1212
/** @var NullableType */
13-
private $_ofType;
13+
private $ofType;
1414

1515
/**
1616
* @param NullableType $type
1717
*/
1818
public function __construct($type)
1919
{
20-
$this->_ofType = is_callable($type) ? $type : self::assertNullableType($type);
21-
}
22-
23-
public function __get($name)
24-
{
25-
switch ($name) {
26-
case 'ofType':
27-
return Type::resolveLazyType($this->_ofType);
28-
}
20+
$this->ofType = is_callable($type) ? $type : self::assertNullableType($type);
2921
}
3022

3123
/**
@@ -66,14 +58,19 @@ public function toString()
6658
return $this->getWrappedType()->toString() . '!';
6759
}
6860

61+
public function getOfType()
62+
{
63+
return Type::resolveLazyType($this->ofType);
64+
}
65+
6966
/**
7067
* @param bool $recurse
7168
*
7269
* @return Type
7370
*/
7471
public function getWrappedType($recurse = false)
7572
{
76-
$type = $this->ofType;
73+
$type = $this->getOfType();
7774

7875
return $recurse && $type instanceof WrappingType
7976
? $type->getWrappedType($recurse)

src/Type/Definition/UnionType.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use GraphQL\Language\AST\UnionTypeDefinitionNode;
99
use GraphQL\Language\AST\UnionTypeExtensionNode;
1010
use GraphQL\Utils\Utils;
11+
use function array_map;
1112
use function call_user_func;
1213
use function is_array;
1314
use function is_callable;
@@ -87,9 +88,9 @@ public function getTypes()
8788
);
8889
}
8990

90-
$this->types = array_map(function($type) {
91-
return Type::resolveLazyType($type);
92-
},$types);
91+
$this->types = array_map(static function ($type) {
92+
return Type::resolveLazyType($type);
93+
}, $types);
9394
}
9495

9596
return $this->types;

src/Type/Schema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ private function getPossibleTypeMap()
424424
}
425425
} elseif ($type instanceof UnionType) {
426426
foreach ($type->getTypes() as $innerType) {
427-
$this->possibleTypeMap[$type->name][$innerType->name] = $innerType;
427+
$this->possibleTypeMap[$type->name][$innerType->name] = $innerType;
428428
}
429429
}
430430
}

src/Utils/SchemaExtender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ protected static function extendImplementedInterfaces(ObjectType $type) : array
296296
protected static function extendType($typeDef)
297297
{
298298
if ($typeDef instanceof ListOfType) {
299-
return Type::listOf(static::extendType($typeDef->ofType));
299+
return Type::listOf(static::extendType($typeDef->getOfType()));
300300
}
301301

302302
if ($typeDef instanceof NonNull) {

0 commit comments

Comments
 (0)