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 @@ -152,6 +152,15 @@ public function testTypes(): void
152152 ],
153153 'builders ' => [['builder ' => 'MyFieldsBuilder ' , 'builderConfig ' => ['param1 ' => 'val1 ' ]]],
154154 ]);
155+
156+ // Test a type extending another type
157+ $ this ->expect ('Cat ' , 'object ' , [
158+ 'description ' => 'The Cat type ' ,
159+ 'fields ' => [
160+ 'name ' => ['type ' => 'String! ' , 'description ' => 'The name of the animal ' ],
161+ 'lives ' => ['type ' => 'Int! ' ],
162+ ],
163+ ]);
155164 }
156165
157166 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