We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
16 | class Configuration implements ConfigurationInterface |
||
17 | { |
||
18 | const NAME = 'overblog_graphql'; |
||
19 | |||
20 | /** bool */ |
||
21 | private $debug; |
||
22 | |||
23 | /** null|string */ |
||
24 | private $cacheDir; |
||
25 | |||
26 | /** |
||
27 | * Constructor. |
||
28 | * |
||
29 | * @param bool $debug Whether to use the debug mode |
||
30 | * @param null|string $cacheDir |
||
31 | */ |
||
32 | 33 | public function __construct($debug, $cacheDir = null) |
|
37 | |||
38 | 33 | public function getConfigTreeBuilder() |
|
39 | { |
||
40 | 33 | $treeBuilder = new TreeBuilder(self::NAME); |
|
|
|||
41 | |||
42 | 33 | $rootNode = self::getRootNodeWithoutDeprecation($treeBuilder, self::NAME); |
|
43 | |||
44 | $rootNode |
||
45 | 33 | ->children() |
|
46 | 33 | ->append($this->batchingMethodSection()) |
|
47 | 33 | ->append($this->definitionsSection()) |
|
48 | 33 | ->append($this->errorsHandlerSection()) |
|
49 | 33 | ->append($this->servicesSection()) |
|
50 | 33 | ->append($this->securitySection()) |
|
51 | 33 | ->end(); |
|
52 | |||
53 | 33 | return $treeBuilder; |
|
54 | } |
||
55 | |||
56 | 33 | private function batchingMethodSection() |
|
57 | { |
||
58 | 33 | $builder = new TreeBuilder('batching_method', 'enum'); |
|
59 | /** @var EnumNodeDefinition $node */ |
||
60 | 33 | $node = self::getRootNodeWithoutDeprecation($builder, 'batching_method', 'enum'); |
|
61 | |||
62 | $node |
||
63 | 33 | ->values(['relay', 'apollo']) |
|
64 | 33 | ->defaultValue('relay') |
|
65 | 33 | ->end(); |
|
66 | |||
67 | 33 | return $node; |
|
68 | } |
||
69 | |||
70 | 33 | private function errorsHandlerSection() |
|
71 | { |
||
72 | 33 | $builder = new TreeBuilder('errors_handler'); |
|
73 | /** @var ArrayNodeDefinition $node */ |
||
74 | 33 | $node = self::getRootNodeWithoutDeprecation($builder, 'errors_handler'); |
|
75 | $node |
||
76 | 33 | ->treatFalseLike(['enabled' => false]) |
|
77 | 33 | ->treatTrueLike(['enabled' => true]) |
|
78 | 33 | ->treatNullLike(['enabled' => true]) |
|
79 | 33 | ->addDefaultsIfNotSet() |
|
80 | 33 | ->children() |
|
81 | 33 | ->booleanNode('enabled')->defaultTrue()->end() |
|
82 | 33 | ->scalarNode('internal_error_message')->defaultValue(ErrorHandler::DEFAULT_ERROR_MESSAGE)->end() |
|
83 | 33 | ->booleanNode('rethrow_internal_exceptions')->defaultFalse()->end() |
|
84 | 33 | ->booleanNode('debug')->defaultValue($this->debug)->end() |
|
85 | 33 | ->booleanNode('log')->defaultTrue()->end() |
|
86 | 33 | ->scalarNode('logger_service')->defaultValue(ErrorLoggerListener::DEFAULT_LOGGER_SERVICE)->end() |
|
87 | 33 | ->booleanNode('map_exceptions_to_parent')->defaultFalse()->end() |
|
88 | 33 | ->arrayNode('exceptions') |
|
89 | 33 | ->addDefaultsIfNotSet() |
|
90 | 33 | ->children() |
|
91 | 33 | ->arrayNode('warnings') |
|
92 | 33 | ->treatNullLike([]) |
|
93 | 33 | ->prototype('scalar')->end() |
|
94 | 33 | ->end() |
|
95 | 33 | ->arrayNode('errors') |
|
96 | 33 | ->treatNullLike([]) |
|
97 | 33 | ->prototype('scalar')->end() |
|
98 | 33 | ->end() |
|
99 | 33 | ->end() |
|
100 | 33 | ->end(); |
|
101 | |||
102 | 33 | return $node; |
|
103 | } |
||
104 | |||
105 | 33 | private function definitionsSection() |
|
106 | { |
||
107 | 33 | $builder = new TreeBuilder('definitions'); |
|
108 | /** @var ArrayNodeDefinition $node */ |
||
109 | 33 | $node = \method_exists($builder, 'getRootNode') ? $builder->getRootNode() : $builder->root('definitions'); |
|
110 | $node |
||
111 | 33 | ->addDefaultsIfNotSet() |
|
112 | 33 | ->children() |
|
113 | 33 | ->variableNode('default_resolver')->defaultValue([Resolver::class, 'defaultResolveFn'])->end() |
|
114 | 33 | ->scalarNode('class_namespace')->defaultValue('Overblog\\GraphQLBundle\\__DEFINITIONS__')->end() |
|
115 | 33 | ->scalarNode('cache_dir')->defaultNull()->end() |
|
116 | 33 | ->booleanNode('use_classloader_listener')->defaultTrue()->end() |
|
117 | 33 | ->booleanNode('auto_compile')->defaultTrue()->end() |
|
118 | 33 | ->booleanNode('show_debug_info')->info('Show some performance stats in extensions')->defaultFalse()->end() |
|
119 | 33 | ->booleanNode('config_validation')->defaultValue($this->debug)->end() |
|
120 | 33 | ->append($this->definitionsSchemaSection()) |
|
121 | 33 | ->append($this->definitionsAutoMappingSection()) |
|
122 | 33 | ->append($this->definitionsMappingsSection()) |
|
123 | 33 | ->arrayNode('builders') |
|
124 | 33 | ->children() |
|
125 | 33 | ->append($this->builderSection('field')) |
|
126 | 33 | ->append($this->builderSection('args')) |
|
127 | 33 | ->end() |
|
128 | 33 | ->end() |
|
129 | |||
130 | 33 | ->end() |
|
131 | 33 | ->end(); |
|
132 | |||
133 | 33 | return $node; |
|
134 | } |
||
135 | |||
136 | 33 | private function servicesSection() |
|
159 | |||
160 | 33 | private function securitySection() |
|
161 | { |
||
162 | 33 | $builder = new TreeBuilder('security'); |
|
163 | /** @var ArrayNodeDefinition $node */ |
||
164 | 33 | $node = \method_exists($builder, 'getRootNode') ? $builder->getRootNode() : $builder->root('security'); |
|
165 | $node |
||
166 | 33 | ->addDefaultsIfNotSet() |
|
167 | 33 | ->children() |
|
168 | 33 | ->append($this->securityQuerySection('query_max_depth', QueryDepth::DISABLED)) |
|
169 | 33 | ->append($this->securityQuerySection('query_max_complexity', QueryComplexity::DISABLED)) |
|
170 | 33 | ->booleanNode('enable_introspection')->defaultTrue()->end() |
|
171 | 33 | ->booleanNode('handle_cors')->defaultFalse()->end() |
|
172 | 33 | ->end() |
|
173 | 33 | ->end(); |
|
174 | |||
175 | 33 | return $node; |
|
176 | } |
||
177 | |||
178 | 33 | private function definitionsSchemaSection() |
|
213 | |||
214 | 33 | private function definitionsAutoMappingSection() |
|
215 | { |
||
216 | 33 | $builder = new TreeBuilder('auto_mapping'); |
|
217 | /** @var ArrayNodeDefinition $node */ |
||
218 | 33 | $node = self::getRootNodeWithoutDeprecation($builder, 'auto_mapping'); |
|
235 | |||
236 | 33 | private function definitionsMappingsSection() |
|
284 | |||
285 | /** |
||
286 | * @param string $name |
||
287 | * |
||
288 | * @return ArrayNodeDefinition |
||
289 | */ |
||
290 | 33 | private function builderSection($name) |
|
323 | |||
324 | /** |
||
325 | * @param string $name |
||
326 | * @param bool $disabledValue |
||
327 | * |
||
328 | * @return ScalarNodeDefinition |
||
329 | */ |
||
330 | 33 | private function securityQuerySection($name, $disabledValue) |
|
365 | |||
366 | /** |
||
367 | * @internal |
||
368 | * |
||
369 | * @param TreeBuilder $builder |
||
370 | * @param string|null $name |
||
371 | * @param string $type |
||
372 | * |
||
373 | * @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition |
||
374 | */ |
||
375 | 38 | public static function getRootNodeWithoutDeprecation(TreeBuilder $builder, $name, $type = 'array') |
|
380 | } |
||
381 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.