Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5a71da0

Browse filesBrowse files
author
Hugo Hamon
committed
[DependencyInjection] remove deprecated code in YamlFileLoader class
1 parent 15b7cdb commit 5a71da0
Copy full SHA for 5a71da0

File tree

3 files changed

+13
-6
lines changed
Filter options

3 files changed

+13
-6
lines changed

‎src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ private function loadFromExtensions(array $content)
782782
*/
783783
private function checkDefinition($id, array $definition, $file)
784784
{
785-
if ($throw = $this->isLoadingInstanceof) {
785+
if ($this->isLoadingInstanceof) {
786786
$keywords = self::$instanceofKeywords;
787787
} elseif ($throw = isset($definition['resource'])) {
788788
$keywords = self::$prototypeKeywords;
@@ -792,11 +792,7 @@ private function checkDefinition($id, array $definition, $file)
792792

793793
foreach ($definition as $key => $value) {
794794
if (!isset($keywords[$key])) {
795-
if ($throw) {
796-
throw new InvalidArgumentException(sprintf('The configuration key "%s" is unsupported for definition "%s" in "%s". Allowed configuration keys are "%s".', $key, $id, $file, implode('", "', $keywords)));
797-
}
798-
799-
@trigger_error(sprintf('The configuration key "%s" is unsupported for service definition "%s" in "%s". Allowed configuration keys are "%s". The YamlFileLoader object will raise an exception instead in Symfony 4.0 when detecting an unsupported service configuration key.', $key, $id, $file, implode('", "', $keywords)), E_USER_DEPRECATED);
795+
throw new InvalidArgumentException(sprintf('The configuration key "%s" is unsupported for definition "%s" in "%s". Allowed configuration keys are "%s".', $key, $id, $file, implode('", "', $keywords)));
800796
}
801797
}
802798
}

‎src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,17 @@ public function testEmptyInstanceofThrowsClearException()
633633
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
634634
$loader->load('bad_empty_instanceof.yml');
635635
}
636+
637+
/**
638+
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
639+
* @expectedExceptionMessageRegExp /^The configuration key "private" is unsupported for definition "bar"/
640+
*/
641+
public function testUnsupportedKeywordThrowsException()
642+
{
643+
$container = new ContainerBuilder();
644+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
645+
$loader->load('bad_keyword.yml');
646+
}
636647
}
637648

638649
interface FooInterface

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.