Skip to content

Commit c332fa0

Browse files
committed
Merge branch '0.12' into 0.13
2 parents 59cac21 + 1b5fbeb commit c332fa0

File tree

4 files changed

+62
-3
lines changed

4 files changed

+62
-3
lines changed

src/Config/Parser/AnnotationParser.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,15 @@ private static function extractClassAnnotations(string $className): array
259259
$classAnnotations = $annotationReader->getClassAnnotations($reflectionEntity);
260260

261261
$properties = [];
262-
foreach ($reflectionEntity->getProperties() as $property) {
263-
$properties[$property->getName()] = ['property' => $property, 'annotations' => $annotationReader->getPropertyAnnotations($property)];
264-
}
262+
$reflectionClass = new \ReflectionClass($className);
263+
do {
264+
foreach ($reflectionClass->getProperties() as $property) {
265+
if (isset($properties[$property->getName()])) {
266+
continue;
267+
}
268+
$properties[$property->getName()] = ['property' => $property, 'annotations' => $annotationReader->getPropertyAnnotations($property)];
269+
}
270+
} while ($reflectionClass = $reflectionClass->getParentClass());
265271

266272
$methods = [];
267273
foreach ($reflectionEntity->getMethods() as $method) {

tests/Config/Parser/AnnotationParserTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@ public function testTypes(): void
154154
],
155155
'builders' => [['builder' => 'MyFieldsBuilder', 'builderConfig' => ['param1' => 'val1']]],
156156
]);
157+
158+
// Test a type extending another type
159+
$this->expect('Cat', 'object', [
160+
'description' => 'The Cat type',
161+
'fields' => [
162+
'name' => ['type' => 'String!', 'description' => 'The name of the animal'],
163+
'lives' => ['type' => 'Int!'],
164+
],
165+
]);
157166
}
158167

159168
public function testInput(): void
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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\Type()
11+
* @GQL\Description("The character interface")
12+
*/
13+
abstract class Animal
14+
{
15+
/**
16+
* @GQL\Field(type="String!")
17+
* @GQL\Description("The name of the animal")
18+
*/
19+
private $name;
20+
21+
/**
22+
* @GQL\Field(type="String!")
23+
*/
24+
private $lives;
25+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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\Type()
11+
* @GQL\Description("The Cat type")
12+
*/
13+
class Cat extends Animal
14+
{
15+
/**
16+
* @GQL\Field(type="Int!")
17+
*/
18+
protected $lives;
19+
}

0 commit comments

Comments
 (0)