1 | <?php |
||
24 | class Backend |
||
25 | { |
||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private const ERR_UNSUPPORTED_RULE = '%s is not supported by this compiler'; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private const ERR_UNRECOGNIZED_RULE = 'The language rule <%s> is not supported or implemented by this compiler'; |
||
35 | |||
36 | /** |
||
37 | * @var string[] |
||
38 | */ |
||
39 | private const BUILDERS = [ |
||
40 | // Root definitions |
||
41 | 'SchemaDefinition' => Definition\SchemaBuilder::class, |
||
42 | 'ObjectDefinition' => Definition\ObjectBuilder::class, |
||
43 | 'EnumDefinition' => Definition\EnumBuilder::class, |
||
44 | 'ScalarDefinition' => Definition\ScalarBuilder::class, |
||
45 | 'InputDefinition' => Definition\InputBuilder::class, |
||
46 | 'DirectiveDefinition' => Definition\DirectiveBuilder::class, |
||
47 | 'InterfaceDefinition' => Definition\InterfaceBuilder::class, |
||
48 | 'UnionDefinition' => Definition\UnionBuilder::class, |
||
49 | // Invocations |
||
50 | 'Directive' => Invocation\DirectiveBuilder::class, |
||
51 | ]; |
||
52 | |||
53 | /** |
||
54 | * @var string[] |
||
55 | */ |
||
56 | private const UNSUPPORTED_BUILDERS = [ |
||
57 | 'QueryOperation' => 'Query expression', |
||
58 | 'MutationOperation' => 'Mutation expression', |
||
59 | 'SubscriptionOperation' => 'Subscription expression', |
||
60 | 'FragmentDefinition' => 'Fragment definition', |
||
61 | ]; |
||
62 | |||
63 | /** |
||
64 | * @var Process |
||
65 | */ |
||
66 | private $process; |
||
67 | |||
68 | /** |
||
69 | * Backend constructor. |
||
70 | * @param Process $process |
||
71 | */ |
||
72 | public function __construct(Process $process) |
||
76 | |||
77 | /** |
||
78 | * @param \Closure $deferred |
||
79 | */ |
||
80 | public function async(\Closure $deferred): void |
||
84 | |||
85 | /** |
||
86 | * @param Document $document |
||
87 | * @return Context |
||
88 | */ |
||
89 | public function context(Document $document): Context |
||
93 | |||
94 | /** |
||
95 | * @param Context $context |
||
96 | * @param RuleInterface $ast |
||
97 | * @return Document |
||
98 | * @throws TypeException |
||
99 | */ |
||
100 | public function each(Context $context, RuleInterface $ast): Document |
||
113 | |||
114 | /** |
||
115 | * @param Context $context |
||
116 | * @param RuleInterface $ast |
||
117 | * @return DefinitionInterface |
||
118 | * @throws TypeException |
||
119 | */ |
||
120 | public function exec(Context $context, RuleInterface $ast): DefinitionInterface |
||
138 | |||
139 | /** |
||
140 | * @param BuilderInterface $builder |
||
141 | * @return DefinitionInterface |
||
142 | */ |
||
143 | private function execBuilder(BuilderInterface $builder): DefinitionInterface |
||
147 | } |
||
148 |