1
1
<?php
2
2
3
+ declare (strict_types=1 );
4
+
3
5
namespace Overblog \GraphQLBundle \Config \Parser ;
4
6
5
7
use GraphQL \Language \AST \DefinitionNode ;
@@ -20,7 +22,7 @@ class GraphQLParser implements ParserInterface
20
22
/** @var self */
21
23
private static $ parser ;
22
24
23
- const DEFINITION_TYPE_MAPPING = [
25
+ public const DEFINITION_TYPE_MAPPING = [
24
26
NodeKind::OBJECT_TYPE_DEFINITION => 'object ' ,
25
27
NodeKind::INTERFACE_TYPE_DEFINITION => 'interface ' ,
26
28
NodeKind::ENUM_TYPE_DEFINITION => 'enum ' ,
@@ -32,7 +34,7 @@ class GraphQLParser implements ParserInterface
32
34
/**
33
35
* {@inheritdoc}
34
36
*/
35
- public static function parse (\SplFileInfo $ file , ContainerBuilder $ container )
37
+ public static function parse (\SplFileInfo $ file , ContainerBuilder $ container ): array
36
38
{
37
39
$ container ->addResource (new FileResource ($ file ->getRealPath ()));
38
40
$ content = \trim (\file_get_contents ($ file ->getPathname ()));
@@ -63,7 +65,7 @@ public static function parse(\SplFileInfo $file, ContainerBuilder $container)
63
65
return $ typesConfig ;
64
66
}
65
67
66
- public static function mustOverrideConfig ()
68
+ public static function mustOverrideConfig (): void
67
69
{
68
70
throw new \RuntimeException ('Config entry must be override with ResolverMap to be used. ' );
69
71
}
@@ -112,7 +114,7 @@ protected function typeDefinitionToConfig(DefinitionNode $typeDef)
112
114
self ::throwUnsupportedDefinitionNode ($ typeDef );
113
115
}
114
116
115
- private static function throwUnsupportedDefinitionNode (DefinitionNode $ typeDef )
117
+ private static function throwUnsupportedDefinitionNode (DefinitionNode $ typeDef ): void
116
118
{
117
119
$ path = \explode ('\\' , \get_class ($ typeDef ));
118
120
throw new InvalidArgumentException (
@@ -127,7 +129,7 @@ private static function throwUnsupportedDefinitionNode(DefinitionNode $typeDef)
127
129
* @param DefinitionNode $typeDef
128
130
* @param array $config
129
131
*/
130
- private function addTypeFields (DefinitionNode $ typeDef , array &$ config )
132
+ private function addTypeFields (DefinitionNode $ typeDef , array &$ config ): void
131
133
{
132
134
if (!empty ($ typeDef ->fields )) {
133
135
$ fields = [];
@@ -148,7 +150,7 @@ private function addTypeFields(DefinitionNode $typeDef, array &$config)
148
150
* @param Node $fieldDef
149
151
* @param array $fieldConf
150
152
*/
151
- private function addFieldArguments (Node $ fieldDef , array &$ fieldConf )
153
+ private function addFieldArguments (Node $ fieldDef , array &$ fieldConf ): void
152
154
{
153
155
if (!empty ($ fieldDef ->arguments )) {
154
156
$ arguments = [];
@@ -167,7 +169,7 @@ private function addFieldArguments(Node $fieldDef, array &$fieldConf)
167
169
* @param DefinitionNode $typeDef
168
170
* @param array $config
169
171
*/
170
- private function addInterfaces (DefinitionNode $ typeDef , array &$ config )
172
+ private function addInterfaces (DefinitionNode $ typeDef , array &$ config ): void
171
173
{
172
174
if (!empty ($ typeDef ->interfaces )) {
173
175
$ interfaces = [];
@@ -182,7 +184,7 @@ private function addInterfaces(DefinitionNode $typeDef, array &$config)
182
184
* @param DefinitionNode $typeDef
183
185
* @param array $config
184
186
*/
185
- private function addTypes (DefinitionNode $ typeDef , array &$ config )
187
+ private function addTypes (DefinitionNode $ typeDef , array &$ config ): void
186
188
{
187
189
if (!empty ($ typeDef ->types )) {
188
190
$ types = [];
@@ -197,7 +199,7 @@ private function addTypes(DefinitionNode $typeDef, array &$config)
197
199
* @param DefinitionNode $typeDef
198
200
* @param array $config
199
201
*/
200
- private function addValues (DefinitionNode $ typeDef , array &$ config )
202
+ private function addValues (DefinitionNode $ typeDef , array &$ config ): void
201
203
{
202
204
if (!empty ($ typeDef ->values )) {
203
205
$ values = [];
@@ -213,7 +215,7 @@ private function addValues(DefinitionNode $typeDef, array &$config)
213
215
* @param Node $definition
214
216
* @param array $config
215
217
*/
216
- private function addType (Node $ definition , array &$ config )
218
+ private function addType (Node $ definition , array &$ config ): void
217
219
{
218
220
if (!empty ($ definition ->type )) {
219
221
$ config ['type ' ] = $ this ->astTypeNodeToString ($ definition ->type );
@@ -224,7 +226,7 @@ private function addType(Node $definition, array &$config)
224
226
* @param Node $definition
225
227
* @param array $config
226
228
*/
227
- private function addDescription (Node $ definition , array &$ config )
229
+ private function addDescription (Node $ definition , array &$ config ): void
228
230
{
229
231
if (
230
232
!empty ($ definition ->description )
@@ -238,7 +240,7 @@ private function addDescription(Node $definition, array &$config)
238
240
* @param Node $definition
239
241
* @param array $config
240
242
*/
241
- private function addDefaultValue (Node $ definition , array &$ config )
243
+ private function addDefaultValue (Node $ definition , array &$ config ): void
242
244
{
243
245
if (!empty ($ definition ->defaultValue )) {
244
246
$ config ['defaultValue ' ] = $ this ->astValueNodeToConfig ($ definition ->defaultValue );
0 commit comments