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 | 30 | public function __construct($debug, $cacheDir = null) |
|
| 37 | |||
| 38 | 30 | public function getConfigTreeBuilder() |
|
| 39 | { |
||
| 40 | 30 | $treeBuilder = new TreeBuilder(); |
|
| 41 | 30 | $rootNode = $treeBuilder->root(self::NAME); |
|
| 42 | |||
| 43 | $rootNode |
||
| 44 | 30 | ->children() |
|
| 45 | 30 | ->append($this->batchingMethodSection()) |
|
| 46 | 30 | ->append($this->definitionsSection()) |
|
| 47 | 30 | ->append($this->errorsHandlerSection()) |
|
| 48 | 30 | ->append($this->servicesSection()) |
|
| 49 | 30 | ->append($this->securitySection()) |
|
| 50 | 30 | ->end(); |
|
| 51 | |||
| 52 | 30 | return $treeBuilder; |
|
| 53 | } |
||
| 54 | |||
| 55 | 30 | private function batchingMethodSection() |
|
| 68 | |||
| 69 | 30 | private function errorsHandlerSection() |
|
| 70 | { |
||
| 71 | 30 | $builder = new TreeBuilder(); |
|
| 72 | /** @var ArrayNodeDefinition $node */ |
||
| 73 | 30 | $node = $builder->root('errors_handler'); |
|
| 74 | $node |
||
| 75 | 30 | ->treatFalseLike(['enabled' => false]) |
|
| 76 | 30 | ->treatTrueLike(['enabled' => true]) |
|
| 77 | 30 | ->treatNullLike(['enabled' => true]) |
|
| 78 | 30 | ->addDefaultsIfNotSet() |
|
| 79 | 30 | ->children() |
|
| 80 | 30 | ->booleanNode('enabled')->defaultTrue()->end() |
|
| 81 | 30 | ->scalarNode('internal_error_message')->defaultValue(ErrorHandler::DEFAULT_ERROR_MESSAGE)->end() |
|
| 82 | 30 | ->booleanNode('rethrow_internal_exceptions')->defaultFalse()->end() |
|
| 83 | 30 | ->booleanNode('debug')->defaultValue($this->debug)->end() |
|
| 84 | 30 | ->booleanNode('log')->defaultTrue()->end() |
|
| 85 | 30 | ->scalarNode('logger_service')->defaultValue(ErrorLoggerListener::DEFAULT_LOGGER_SERVICE)->end() |
|
| 86 | 30 | ->booleanNode('map_exceptions_to_parent')->defaultFalse()->end() |
|
| 87 | 30 | ->arrayNode('exceptions') |
|
| 88 | 30 | ->addDefaultsIfNotSet() |
|
| 89 | 30 | ->children() |
|
| 90 | 30 | ->arrayNode('warnings') |
|
| 91 | 30 | ->treatNullLike([]) |
|
| 92 | 30 | ->prototype('scalar')->end() |
|
| 93 | 30 | ->end() |
|
| 94 | 30 | ->arrayNode('errors') |
|
| 95 | 30 | ->treatNullLike([]) |
|
| 96 | 30 | ->prototype('scalar')->end() |
|
| 97 | 30 | ->end() |
|
| 98 | 30 | ->end() |
|
| 99 | 30 | ->end(); |
|
| 100 | |||
| 101 | 30 | return $node; |
|
| 102 | } |
||
| 103 | |||
| 104 | 30 | private function definitionsSection() |
|
| 105 | { |
||
| 106 | 30 | $builder = new TreeBuilder(); |
|
| 107 | /** @var ArrayNodeDefinition $node */ |
||
| 108 | 30 | $node = $builder->root('definitions'); |
|
| 109 | $node |
||
| 110 | 30 | ->addDefaultsIfNotSet() |
|
| 111 | 30 | ->children() |
|
| 112 | 30 | ->variableNode('default_resolver')->defaultValue([Resolver::class, 'defaultResolveFn'])->end() |
|
| 113 | 30 | ->scalarNode('class_namespace')->defaultValue('Overblog\\GraphQLBundle\\__DEFINITIONS__')->end() |
|
| 114 | 30 | ->scalarNode('cache_dir')->defaultNull()->end() |
|
| 115 | 30 | ->booleanNode('use_classloader_listener')->defaultTrue()->end() |
|
| 116 | 30 | ->booleanNode('auto_compile')->defaultTrue()->end() |
|
| 117 | 30 | ->booleanNode('show_debug_info')->info('Show some performance stats in extensions')->defaultFalse()->end() |
|
| 118 | 30 | ->booleanNode('config_validation')->defaultValue($this->debug)->end() |
|
| 119 | 30 | ->append($this->definitionsSchemaSection()) |
|
| 120 | 30 | ->append($this->definitionsAutoMappingSection()) |
|
| 121 | 30 | ->append($this->definitionsMappingsSection()) |
|
| 122 | 30 | ->arrayNode('builders') |
|
| 123 | 30 | ->children() |
|
| 124 | 30 | ->append($this->builderSection('field')) |
|
| 125 | 30 | ->append($this->builderSection('args')) |
|
| 126 | 30 | ->end() |
|
| 127 | 30 | ->end() |
|
| 128 | |||
| 129 | 30 | ->end() |
|
| 130 | 30 | ->end(); |
|
| 131 | |||
| 132 | 30 | return $node; |
|
| 133 | } |
||
| 134 | |||
| 135 | 30 | private function servicesSection() |
|
| 136 | { |
||
| 137 | 30 | $builder = new TreeBuilder(); |
|
| 138 | /** @var ArrayNodeDefinition $node */ |
||
| 139 | 30 | $node = $builder->root('services'); |
|
| 140 | $node |
||
| 141 | 30 | ->addDefaultsIfNotSet() |
|
| 142 | 30 | ->children() |
|
| 143 | 30 | ->scalarNode('executor') |
|
| 144 | 30 | ->defaultValue(self::NAME.'.executor.default') |
|
| 145 | 30 | ->end() |
|
| 146 | 30 | ->scalarNode('promise_adapter') |
|
| 147 | 30 | ->defaultValue(self::NAME.'.promise_adapter.default') |
|
| 148 | 30 | ->end() |
|
| 149 | 30 | ->scalarNode('expression_language') |
|
| 150 | 30 | ->defaultValue(self::NAME.'.expression_language.default') |
|
| 151 | 30 | ->end() |
|
| 152 | 30 | ->scalarNode('cache_expression_language_parser')->end() |
|
| 153 | 30 | ->end() |
|
| 154 | 30 | ->end(); |
|
| 155 | |||
| 156 | 30 | return $node; |
|
| 157 | } |
||
| 158 | |||
| 159 | 30 | private function securitySection() |
|
| 160 | { |
||
| 161 | 30 | $builder = new TreeBuilder(); |
|
| 162 | /** @var ArrayNodeDefinition $node */ |
||
| 163 | 30 | $node = $builder->root('security'); |
|
| 164 | $node |
||
| 165 | 30 | ->addDefaultsIfNotSet() |
|
| 166 | 30 | ->children() |
|
| 167 | 30 | ->append($this->securityQuerySection('query_max_depth', QueryDepth::DISABLED)) |
|
| 168 | 30 | ->append($this->securityQuerySection('query_max_complexity', QueryComplexity::DISABLED)) |
|
| 169 | 30 | ->booleanNode('handle_cors')->defaultFalse()->end() |
|
| 170 | 30 | ->end() |
|
| 171 | 30 | ->end(); |
|
| 172 | |||
| 173 | 30 | return $node; |
|
| 174 | } |
||
| 175 | |||
| 176 | 30 | private function definitionsSchemaSection() |
|
| 177 | { |
||
| 178 | 30 | $builder = new TreeBuilder(); |
|
| 179 | /** @var ArrayNodeDefinition $node */ |
||
| 180 | 30 | $node = $builder->root('schema'); |
|
| 181 | $node |
||
| 182 | 30 | ->beforeNormalization() |
|
| 183 | 30 | ->ifTrue(function ($v) { |
|
| 184 | 26 | return isset($v['query']) && is_string($v['query']) || isset($v['mutation']) && is_string($v['mutation']); |
|
| 185 | 30 | }) |
|
| 186 | 30 | ->then(function ($v) { |
|
| 187 | 26 | return ['default' => $v]; |
|
| 188 | 30 | }) |
|
| 189 | 30 | ->end() |
|
| 190 | 30 | ->useAttributeAsKey('name') |
|
| 191 | 30 | ->prototype('array') |
|
| 192 | 30 | ->addDefaultsIfNotSet() |
|
| 193 | 30 | ->children() |
|
| 194 | 30 | ->scalarNode('query')->defaultNull()->end() |
|
| 195 | 30 | ->scalarNode('mutation')->defaultNull()->end() |
|
| 196 | 30 | ->scalarNode('subscription')->defaultNull()->end() |
|
| 197 | 30 | ->arrayNode('resolver_maps') |
|
| 198 | 30 | ->defaultValue([]) |
|
| 199 | 30 | ->prototype('scalar')->end() |
|
| 200 | 30 | ->end() |
|
| 201 | 30 | ->arrayNode('types') |
|
| 202 | 30 | ->defaultValue([]) |
|
| 203 | 30 | ->prototype('scalar')->end() |
|
| 204 | 30 | ->end() |
|
| 205 | 30 | ->end() |
|
| 206 | 30 | ->end() |
|
| 207 | 30 | ->end(); |
|
| 208 | |||
| 209 | 30 | return $node; |
|
| 210 | } |
||
| 211 | |||
| 212 | 30 | private function definitionsAutoMappingSection() |
|
| 213 | { |
||
| 214 | 30 | $builder = new TreeBuilder(); |
|
| 215 | /** @var ArrayNodeDefinition $node */ |
||
| 216 | 30 | $node = $builder->root('auto_mapping'); |
|
| 217 | $node |
||
| 218 | 30 | ->treatFalseLike(['enabled' => false]) |
|
| 219 | 30 | ->treatTrueLike(['enabled' => true]) |
|
| 220 | 30 | ->treatNullLike(['enabled' => true]) |
|
| 221 | 30 | ->addDefaultsIfNotSet() |
|
| 222 | 30 | ->children() |
|
| 223 | 30 | ->booleanNode('enabled')->defaultTrue()->end() |
|
| 224 | 30 | ->arrayNode('directories') |
|
| 225 | 30 | ->info('List of directories containing GraphQL classes.') |
|
| 226 | 30 | ->prototype('scalar')->end() |
|
| 227 | 30 | ->end() |
|
| 228 | 30 | ->end() |
|
| 229 | 30 | ->end(); |
|
| 230 | |||
| 231 | 30 | return $node; |
|
| 232 | } |
||
| 233 | |||
| 234 | 30 | private function definitionsMappingsSection() |
|
| 235 | { |
||
| 236 | 30 | $builder = new TreeBuilder(); |
|
| 237 | 30 | $node = $builder->root('mappings'); |
|
| 238 | $node |
||
| 239 | 30 | ->children() |
|
| 240 | 30 | ->arrayNode('auto_discover') |
|
| 241 | 30 | ->treatFalseLike(['bundles' => false, 'root_dir' => false]) |
|
| 242 | 30 | ->treatTrueLike(['bundles' => true, 'root_dir' => true]) |
|
| 243 | 30 | ->treatNullLike(['bundles' => true, 'root_dir' => true]) |
|
| 244 | 30 | ->addDefaultsIfNotSet() |
|
| 245 | 30 | ->children() |
|
| 246 | 30 | ->booleanNode('bundles')->defaultTrue()->end() |
|
| 247 | 30 | ->booleanNode('root_dir')->defaultTrue()->end() |
|
| 248 | 30 | ->end() |
|
| 249 | 30 | ->end() |
|
| 250 | 30 | ->arrayNode('types') |
|
| 251 | 30 | ->prototype('array') |
|
| 252 | 30 | ->addDefaultsIfNotSet() |
|
| 253 | 30 | ->beforeNormalization() |
|
| 254 | 30 | ->ifTrue(function ($v) { |
|
| 255 | 25 | return isset($v['type']) && is_string($v['type']); |
|
| 256 | 30 | }) |
|
| 257 | 30 | ->then(function ($v) { |
|
| 258 | 24 | if ('yml' === $v['type']) { |
|
| 259 | 7 | $v['types'] = ['yaml']; |
|
| 260 | } else { |
||
| 261 | 17 | $v['types'] = [$v['type']]; |
|
| 262 | } |
||
| 263 | 24 | unset($v['type']); |
|
| 264 | |||
| 265 | 24 | return $v; |
|
| 266 | 30 | }) |
|
| 267 | 30 | ->end() |
|
| 268 | 30 | ->children() |
|
| 269 | 30 | ->arrayNode('types') |
|
| 270 | 30 | ->prototype('enum')->values(array_keys(OverblogGraphQLTypesExtension::SUPPORTED_TYPES_EXTENSIONS))->isRequired()->end() |
|
| 271 | 30 | ->end() |
|
| 272 | 30 | ->scalarNode('dir')->defaultNull()->end() |
|
| 273 | 30 | ->scalarNode('suffix')->defaultValue(OverblogGraphQLTypesExtension::DEFAULT_TYPES_SUFFIX)->end() |
|
| 274 | 30 | ->end() |
|
| 275 | 30 | ->end() |
|
| 276 | 30 | ->end() |
|
| 277 | 30 | ->end() |
|
| 278 | ; |
||
| 279 | |||
| 280 | 30 | return $node; |
|
| 281 | } |
||
| 282 | |||
| 283 | /** |
||
| 284 | * @param string $name |
||
| 285 | * |
||
| 286 | * @return ArrayNodeDefinition |
||
| 287 | */ |
||
| 288 | 30 | private function builderSection($name) |
|
| 321 | |||
| 322 | /** |
||
| 323 | * @param string $name |
||
| 324 | * @param bool $disabledValue |
||
| 325 | * |
||
| 326 | * @return ScalarNodeDefinition |
||
| 327 | */ |
||
| 328 | 30 | private function securityQuerySection($name, $disabledValue) |
|
| 363 | } |
||
| 364 |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call: