5
5
namespace GraphQL \Language ;
6
6
7
7
/**
8
- * List of available directive locations
8
+ * Enumeration of available directive locations.
9
9
*/
10
10
class DirectiveLocation
11
11
{
12
- // Request Definitions
13
12
const QUERY = 'QUERY ' ;
14
13
const MUTATION = 'MUTATION ' ;
15
14
const SUBSCRIPTION = 'SUBSCRIPTION ' ;
@@ -19,7 +18,17 @@ class DirectiveLocation
19
18
const INLINE_FRAGMENT = 'INLINE_FRAGMENT ' ;
20
19
const VARIABLE_DEFINITION = 'VARIABLE_DEFINITION ' ;
21
20
22
- // Type System Definitions
21
+ const EXECUTABLE_LOCATIONS = [
22
+ self ::QUERY => self ::QUERY ,
23
+ self ::MUTATION => self ::MUTATION ,
24
+ self ::SUBSCRIPTION => self ::SUBSCRIPTION ,
25
+ self ::FIELD => self ::FIELD ,
26
+ self ::FRAGMENT_DEFINITION => self ::FRAGMENT_DEFINITION ,
27
+ self ::FRAGMENT_SPREAD => self ::FRAGMENT_SPREAD ,
28
+ self ::INLINE_FRAGMENT => self ::INLINE_FRAGMENT ,
29
+ self ::VARIABLE_DEFINITION => self ::VARIABLE_DEFINITION ,
30
+ ];
31
+
23
32
const SCHEMA = 'SCHEMA ' ;
24
33
const SCALAR = 'SCALAR ' ;
25
34
const OBJECT = 'OBJECT ' ;
@@ -32,16 +41,7 @@ class DirectiveLocation
32
41
const INPUT_OBJECT = 'INPUT_OBJECT ' ;
33
42
const INPUT_FIELD_DEFINITION = 'INPUT_FIELD_DEFINITION ' ;
34
43
35
- /** @var string[] */
36
- private static $ locations = [
37
- self ::QUERY => self ::QUERY ,
38
- self ::MUTATION => self ::MUTATION ,
39
- self ::SUBSCRIPTION => self ::SUBSCRIPTION ,
40
- self ::FIELD => self ::FIELD ,
41
- self ::FRAGMENT_DEFINITION => self ::FRAGMENT_DEFINITION ,
42
- self ::FRAGMENT_SPREAD => self ::FRAGMENT_SPREAD ,
43
- self ::INLINE_FRAGMENT => self ::INLINE_FRAGMENT ,
44
- self ::VARIABLE_DEFINITION => self ::VARIABLE_DEFINITION ,
44
+ const TYPE_SYSTEM_LOCATIONS = [
45
45
self ::SCHEMA => self ::SCHEMA ,
46
46
self ::SCALAR => self ::SCALAR ,
47
47
self ::OBJECT => self ::OBJECT ,
@@ -55,8 +55,10 @@ class DirectiveLocation
55
55
self ::INPUT_FIELD_DEFINITION => self ::INPUT_FIELD_DEFINITION ,
56
56
];
57
57
58
+ const LOCATIONS = self ::EXECUTABLE_LOCATIONS + self ::TYPE_SYSTEM_LOCATIONS ;
59
+
58
60
public static function has (string $ name ): bool
59
61
{
60
- return isset (self ::$ locations [$ name ]);
62
+ return isset (self ::LOCATIONS [$ name ]);
61
63
}
62
64
}
0 commit comments