|
32 | 32 | */
|
33 | 33 | class YamlFileLoader extends FileLoader
|
34 | 34 | {
|
| 35 | + private static $keywords = array( |
| 36 | + 'alias' => 'alias', |
| 37 | + 'parent' => 'parent', |
| 38 | + 'class' => 'class', |
| 39 | + 'shared' => 'shared', |
| 40 | + 'synthetic' => 'synthetic', |
| 41 | + 'lazy' => 'lazy', |
| 42 | + 'public' => 'public', |
| 43 | + 'abstract' => 'abstract', |
| 44 | + 'deprecated' => 'deprecated', |
| 45 | + 'factory' => 'factory', |
| 46 | + 'file' => 'file', |
| 47 | + 'arguments' => 'arguments', |
| 48 | + 'properties' => 'properties', |
| 49 | + 'configurator' => 'configurator', |
| 50 | + 'calls' => 'calls', |
| 51 | + 'tags' => 'tags', |
| 52 | + 'decorates' => 'decorates', |
| 53 | + 'decoration_inner_name' => 'decoration_inner_name', |
| 54 | + 'decoration_priority' => 'decoration_priority', |
| 55 | + 'autowire' => 'autowire', |
| 56 | + 'autowiring_types' => 'autowiring_types', |
| 57 | + ); |
| 58 | + |
35 | 59 | private $yamlParser;
|
36 | 60 |
|
37 | 61 | /**
|
@@ -147,6 +171,8 @@ private function parseDefinition($id, $service, $file)
|
147 | 171 | throw new InvalidArgumentException(sprintf('A service definition must be an array or a string starting with "@" but %s found for service "%s" in %s. Check your YAML syntax.', gettype($service), $id, $file));
|
148 | 172 | }
|
149 | 173 |
|
| 174 | + static::checkDefinition($id, $service); |
| 175 | + |
150 | 176 | if (isset($service['alias'])) {
|
151 | 177 | $public = !array_key_exists('public', $service) || (bool) $service['public'];
|
152 | 178 | $this->container->setAlias($id, new Alias($service['alias'], $public));
|
@@ -432,4 +458,21 @@ private function loadFromExtensions($content)
|
432 | 458 | $this->container->loadFromExtension($namespace, $values);
|
433 | 459 | }
|
434 | 460 | }
|
| 461 | + |
| 462 | + /** |
| 463 | + * Checks the keywords used to define a service. |
| 464 | + * |
| 465 | + * @param string $id The service name |
| 466 | + * @param array $definition The service definition to check |
| 467 | + * |
| 468 | + * @throws InvalidArgumentException When an invalid keyword is used |
| 469 | + */ |
| 470 | + private static function checkDefinition($id, array $definition) |
| 471 | + { |
| 472 | + foreach ($definition as $key => $value) { |
| 473 | + if (!isset(static::$keywords[$key])) { |
| 474 | + @trigger_error(sprintf('The "%s" key in "%s" service definition is not supported. It must be one of "%s".', $key, $id, implode('", "', static::$keywords)), E_USER_DEPRECATED); |
| 475 | + } |
| 476 | + } |
| 477 | + } |
435 | 478 | }
|
0 commit comments