File tree Expand file tree Collapse file tree 4 files changed +62
-3
lines changed
fixtures/annotations/Type Expand file tree Collapse file tree 4 files changed +62
-3
lines changed Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments