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 OverblogGraphQLTypesExtension extends Extension |
||
| 17 | { |
||
| 18 | const SUPPORTED_TYPES_EXTENSIONS = ['yaml' => '{yaml,yml}', 'xml' => 'xml', 'graphql' => '{graphql,graphqls}']; |
||
| 19 | |||
| 20 | const PARSERS = [ |
||
| 21 | 'yaml' => YamlParser::class, |
||
| 22 | 'xml' => XmlParser::class, |
||
| 23 | 'graphql' => GraphQLParser::class, |
||
| 24 | ]; |
||
| 25 | |||
| 26 | private static $defaultDefaultConfig = [ |
||
| 27 | 'definitions' => [ |
||
| 28 | 'mappings' => [ |
||
| 29 | 'auto_discover' => [ |
||
| 30 | 'root_dir' => true, |
||
| 31 | 'bundles' => true, |
||
| 32 | ], |
||
| 33 | 'types' => [], |
||
| 34 | ], |
||
| 35 | 30 | ], |
|
| 36 | ]; |
||
| 37 | 30 | ||
| 38 | private $treatedFiles = []; |
||
| 39 | 29 | ||
| 40 | 29 | const DEFAULT_TYPES_SUFFIX = '.types'; |
|
| 41 | 29 | ||
| 42 | public function load(array $configs, ContainerBuilder $container) |
||
| 43 | 24 | { |
|
| 44 | 24 | $this->checkTypesDuplication($configs); |
|
| 45 | // flatten config is a requirement to support inheritance |
||
| 46 | 25 | $flattenConfig = [call_user_func_array('array_merge', $configs)]; |
|
| 47 | $configuration = $this->getConfiguration($flattenConfig, $container); |
||
| 48 | 25 | $config = $this->processConfiguration($configuration, $flattenConfig); |
|
|
|
|||
| 49 | |||
| 50 | 25 | $container->setParameter($this->getAlias().'.config', $config); |
|
| 51 | } |
||
| 52 | 25 | ||
| 53 | 25 | public function containerPrependExtensionConfig(array $config, ContainerBuilder $container) |
|
| 54 | { |
||
| 55 | 23 | $typesMappings = $this->mappingConfig($config, $container); |
|
| 56 | // reset treated files |
||
| 57 | $this->treatedFiles = []; |
||
| 58 | $typesMappings = call_user_func_array('array_merge', $typesMappings); |
||
| 59 | // treats mappings |
||
| 60 | foreach ($typesMappings as $params) { |
||
| 61 | $this->prependExtensionConfigFromFiles($params['type'], $params['files'], $container); |
||
| 62 | 25 | } |
|
| 63 | } |
||
| 64 | 25 | ||
| 65 | 25 | /** |
|
| 66 | 25 | * @param $type |
|
| 67 | 1 | * @param SplFileInfo[] $files |
|
| 68 | * @param ContainerBuilder $container |
||
| 69 | */ |
||
| 70 | 25 | private function prependExtensionConfigFromFiles($type, $files, ContainerBuilder $container) |
|
| 83 | 30 | ||
| 84 | 30 | private function checkTypesDuplication(array $typeConfigs) |
|
| 85 | 1 | { |
|
| 97 | 25 | ||
| 98 | 25 | private function mappingConfig(array $config, ContainerBuilder $container) |
|
| 126 | 25 | ||
| 127 | 25 | private function detectFilesFromTypesMappings(array $typesMappings, ContainerBuilder $container) |
|
| 140 | 3 | ||
| 141 | 3 | private function mappingFromBundles(ContainerBuilder $container) |
|
| 156 | |||
| 157 | 25 | private function detectFilesByTypes(ContainerBuilder $container, $path, $suffix, array $types = null) |
|
| 191 | |||
| 192 | 24 | private function bundleDir($bundleClass) |
|
| 199 | 24 | ||
| 200 | public function getAliasPrefix() |
||
| 204 | 29 | ||
| 205 | public function getAlias() |
||
| 209 | |||
| 210 | public function getConfiguration(array $config, ContainerBuilder $container) |
||
| 214 | } |
||
| 215 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: