3535
3636namespace Glpi \Api \HL ;
3737
38+ use Closure ;
3839use Glpi \Api \HL \Doc as Doc ;
3940use Glpi \Debug \Profiler ;
41+ use GraphQL \Type \Definition \ListOfType ;
4042use GraphQL \Type \Definition \ObjectType ;
43+ use GraphQL \Type \Definition \ScalarType ;
4144use GraphQL \Type \Definition \Type ;
4245use Throwable ;
4346
@@ -57,6 +60,9 @@ private function normalizeTypeName(string $type_name): string
5760 return str_replace ([' ' , '- ' ], ['' , '_ ' ], $ type_name );
5861 }
5962
63+ /**
64+ * @return string
65+ */
6066 public function getSchema ()
6167 {
6268 Profiler::getInstance ()->start ('GraphQLGenerator::loadTypes ' , Profiler::CATEGORY_HLAPI );
@@ -87,7 +93,7 @@ public function getSchema()
8793 return $ schema_str ;
8894 }
8995
90- private function writeType ($ type_name , ObjectType |callable $ type ): string
96+ private function writeType (string $ type_name , ObjectType |callable $ type ): string
9197 {
9298 $ type_name = $ this ->normalizeTypeName ($ type_name );
9399 $ type_str = "type $ type_name { \n" ;
@@ -118,7 +124,7 @@ private function writeType($type_name, ObjectType|callable $type): string
118124 return $ type_str ;
119125 }
120126
121- private function loadTypes ()
127+ private function loadTypes (): void
122128 {
123129 $ component_schemas = OpenAPIGenerator::getComponentSchemas ($ this ->api_version );
124130 foreach ($ component_schemas as $ schema_name => $ schema ) {
@@ -173,6 +179,13 @@ private function convertRESTSchemaToGraphQLSchema(string $schema_name, array $sc
173179 ]);
174180 }
175181
182+ /**
183+ * @param array $property
184+ * @param string|null $name
185+ * @param string $prefix
186+ *
187+ * @return Closure|ListOfType|ObjectType|ScalarType|void
188+ */
176189 private function convertRESTPropertyToGraphQLType (array $ property , ?string $ name = null , string $ prefix = '' )
177190 {
178191 $ type = $ property ['type ' ] ?? 'string ' ;
0 commit comments