Skip to content

Commit 8a25ee6

Browse files
committed
Add missing test & remove useless methods from GraphClass
1 parent b834798 commit 8a25ee6

File tree

5 files changed

+21
-50
lines changed

5 files changed

+21
-50
lines changed

src/Config/Parser/Annotation/GraphClass.php

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Doctrine\Common\Annotations\AnnotationReader;
99
use Doctrine\Common\Annotations\AnnotationRegistry;
1010
use ReflectionClass;
11-
use ReflectionException;
1211
use ReflectionMethod;
1312
use ReflectionProperty;
1413
use RuntimeException;
@@ -40,43 +39,6 @@ public function __construct(string $className)
4039
} while ($reflection = $reflection->getParentClass());
4140
}
4241

43-
/**
44-
* Get an array of parent class names.
45-
*
46-
* @return string[]
47-
*/
48-
public function getParents(): array
49-
{
50-
$parents = [];
51-
$class = $this;
52-
while ($parent = $class->getParentClass()) {
53-
$parents[] = $parent->getName();
54-
$class = $parent;
55-
}
56-
57-
return $parents;
58-
}
59-
60-
/**
61-
* Get the list of methods name.
62-
*
63-
* @return string[]
64-
*/
65-
public function getMethodsNames(): array
66-
{
67-
return array_map(fn (ReflectionMethod $method) => $method->getName(), $this->getMethods());
68-
}
69-
70-
public function getMethodAnnotations(string $name): array
71-
{
72-
return self::getAnnotationReader()->getMethodAnnotations($this->getMethod($name));
73-
}
74-
75-
public function getPropertyAnnotations(string $name): array
76-
{
77-
return self::getAnnotationReader()->getPropertyAnnotations($this->getProperty($name));
78-
}
79-
8042
/**
8143
* @return ReflectionProperty[]
8244
*/
@@ -85,15 +47,6 @@ public function getPropertiesExtended()
8547
return $this->propertiesExtended;
8648
}
8749

88-
public function getPropertyExtended(string $name): ReflectionProperty
89-
{
90-
if (!isset($this->propertiesExtended[$name])) {
91-
throw new ReflectionException(sprintf('Missing property %s on class or parent class %s', $name, $this->getName()));
92-
}
93-
94-
return $this->propertiesExtended[$name];
95-
}
96-
9750
/**
9851
* @param ReflectionMethod|ReflectionProperty|null $from
9952
*

src/Config/Parser/AnnotationParser.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ private static function graphQLTypeConfigFromAnnotation(GraphClass $graphClass,
304304
if (null !== $typeAnnotation->interfaces) {
305305
$typeConfiguration['interfaces'] = $typeAnnotation->interfaces;
306306
} else {
307-
$typeConfiguration['interfaces'] = array_keys(self::searchClassesMapBy(function ($gqlType, $configuration) use ($graphClass) {
307+
$interfaces = array_keys(self::searchClassesMapBy(function ($gqlType, $configuration) use ($graphClass) {
308308
['class' => $interfaceClassName] = $configuration;
309309

310310
$interfaceMetadata = self::getGraphClass($interfaceClassName);
@@ -314,6 +314,9 @@ private static function graphQLTypeConfigFromAnnotation(GraphClass $graphClass,
314314

315315
return $graphClass->isSubclassOf($interfaceClassName);
316316
}, self::GQL_INTERFACE));
317+
318+
sort($interfaces);
319+
$typeConfiguration['interfaces'] = $interfaces;
317320
}
318321

319322
if ($typeAnnotation->resolveField) {

tests/Config/Parser/AnnotationParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function testUnionAutoguessed(): void
224224
public function testInterfaceAutoguessed(): void
225225
{
226226
$this->expect('Mandalorian', 'object', [
227-
'interfaces' => ['Character'],
227+
'interfaces' => ['Armored', 'Character'],
228228
'fields' => [
229229
'name' => ['type' => 'String!', 'description' => 'The name of the character'],
230230
'friends' => ['type' => '[Character]', 'description' => 'The friends of the character', 'resolve' => "@=resolver('App\\\\MyResolver::getFriends')"],
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Overblog\GraphQLBundle\Tests\Config\Parser\fixtures\annotations\Type;
6+
7+
use Overblog\GraphQLBundle\Annotation as GQL;
8+
9+
/**
10+
* @GQL\TypeInterface(resolveType="@=resolver('character_type', [value])")
11+
* @GQL\Description("The armored interface")
12+
*/
13+
interface Armored
14+
{
15+
}

tests/Config/Parser/fixtures/annotations/Type/Mandalorian.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
/**
1111
* @GQL\Type
1212
*/
13-
class Mandalorian extends Character implements Killable
13+
class Mandalorian extends Character implements Killable, Armored
1414
{
1515
}

0 commit comments

Comments
 (0)