11<?php
22
3-
43namespace TheCodingMachine \GraphQLite \Bundle \Tests \Fixtures \Entities ;
54
6-
75use stdClass ;
86use TheCodingMachine \GraphQLite \Annotations \Field ;
97use TheCodingMachine \GraphQLite \Annotations \Type ;
108use TheCodingMachine \GraphQLite \Bundle \Tests \Fixtures \Controller \TestGraphqlController ;
119use TheCodingMachine \GraphQLite \Annotations \Autowire ;
1210
13- /**
14- * @Type()
15- */
11+ #[Type]
1612class Contact
1713{
1814 /**
@@ -25,51 +21,45 @@ public function __construct(string $name)
2521 $ this ->name = $ name ;
2622 }
2723
28- /**
29- * @Field(name="name")
30- */
24+ #[Field(name: 'name ' )]
3125 public function getName (): string
3226 {
3327 return $ this ->name ;
3428 }
3529
36- /**
37- * @Field()
38- * @ Autowire(for="$testService")
39- * @Autowire(for="$someService", identifier="someService")
40- * @ Autowire(for="$someAlias", identifier="someAlias")
41- * @return string
42- */
43- public function injectService ( TestGraphqlController $ testService = null , stdClass $ someService = null , stdClass $ someAlias = null ): string
44- {
30+ #[Field]
31+ public function injectService (
32+ #[ Autowire]
33+ TestGraphqlController $ testService = null ,
34+ #[ Autowire(identifier: ' someService ' )]
35+ stdClass $ someService = null ,
36+ #[Autowire(identifier: ' someAlias ' )]
37+ stdClass $ someAlias = null ,
38+ ): string {
4539 if (!$ testService instanceof TestGraphqlController || $ someService === null || $ someAlias === null ) {
4640 return 'KO ' ;
4741 }
4842 return 'OK ' ;
4943 }
5044
51- /**
52- * @Field(prefetchMethod="prefetchData")
53- */
45+ #[Field(prefetchMethod: 'prefetchData ' )]
5446 public function injectServicePrefetch ($ prefetchData ): string
5547 {
5648 return $ prefetchData ;
5749 }
5850
59- /**
60- * @Autowire(for="$someOtherService", identifier="someOtherService")
61- */
62- public function prefetchData ( iterable $ iterable , stdClass $ someOtherService = null )
63- {
51+ public function prefetchData (
52+ iterable $ iterable ,
53+ #[Autowire(identifier: ' someOtherService ' )]
54+ stdClass $ someOtherService = null ,
55+ ) {
6456 if ($ someOtherService === null ) {
6557 return 'KO ' ;
6658 }
6759 return 'OK ' ;
6860 }
6961
70- /**
71- * @Field()
72- */
62+ #[Field]
7363 public function getManager (): ?Contact
7464 {
7565 return null ;
0 commit comments