Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit17ec26e

Browse files
committed
[DI] added support for PHP constants in yaml configuration files
1 parent02d1dea commit17ec26e

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

‎src/Symfony/Component/DependencyInjection/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
-----
66

77
* allowed to prioritize compiler passes by introducing a third argument to`PassConfig::addPass()`, to`Compiler::addPass` and to`ContainerBuilder::addCompilerPass()`
8+
* added support for PHP constants in YAML configuration files
89

910
3.0.0
1011
-----

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
useSymfony\Component\Config\Resource\FileResource;
2222
useSymfony\Component\Yaml\Exception\ParseException;
2323
useSymfony\Component\Yaml\ParserasYamlParser;
24+
useSymfony\Component\Yaml\Yaml;
2425
useSymfony\Component\ExpressionLanguage\Expression;
2526

2627
/**
@@ -366,7 +367,7 @@ protected function loadFile($file)
366367
}
367368

368369
try {
369-
$configuration =$this->yamlParser->parse(file_get_contents($file));
370+
$configuration =$this->yamlParser->parse(file_get_contents($file), Yaml::PARSE_CONSTANT);
370371
}catch (ParseException$e) {
371372
thrownewInvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.',$file),0,$e);
372373
}

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services2.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ parameters:
55
-false
66
-0
77
-1000.3
8+
-!php/const:PHP_INT_MAX
89
bar:foo
910
escape:'@@escapeme'
1011
foo_bar:'@foo_bar'

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function testLoadParameters()
9797
$container =newContainerBuilder();
9898
$loader =newYamlFileLoader($container,newFileLocator(self::$fixturesPath.'/yaml'));
9999
$loader->load('services2.yml');
100-
$this->assertEquals(array('foo' =>'bar','mixedcase' =>array('MixedCaseKey' =>'value'),'values' =>array(true,false,0,1000.3),'bar' =>'foo','escape' =>'@escapeme','foo_bar' =>newReference('foo_bar')),$container->getParameterBag()->all(),'->load() converts YAML keys to lowercase');
100+
$this->assertEquals(array('foo' =>'bar','mixedcase' =>array('MixedCaseKey' =>'value'),'values' =>array(true,false,0,1000.3,PHP_INT_MAX),'bar' =>'foo','escape' =>'@escapeme','foo_bar' =>newReference('foo_bar')),$container->getParameterBag()->all(),'->load() converts YAML keys to lowercase');
101101
}
102102

103103
publicfunctiontestLoadImports()
@@ -113,7 +113,7 @@ public function testLoadImports()
113113
$loader->load('services4.yml');
114114

115115
$actual =$container->getParameterBag()->all();
116-
$expected =array('foo' =>'bar','values' =>array(true,false),'bar' =>'%foo%','escape' =>'@escapeme','foo_bar' =>newReference('foo_bar'),'mixedcase' =>array('MixedCaseKey' =>'value'),'imported_from_ini' =>true,'imported_from_xml' =>true);
116+
$expected =array('foo' =>'bar','values' =>array(true,false,PHP_INT_MAX),'bar' =>'%foo%','escape' =>'@escapeme','foo_bar' =>newReference('foo_bar'),'mixedcase' =>array('MixedCaseKey' =>'value'),'imported_from_ini' =>true,'imported_from_xml' =>true);
117117
$this->assertEquals(array_keys($expected),array_keys($actual),'->load() imports and merges imported files');
118118

119119
// Bad import throws no exception due to ignore_errors value.

‎src/Symfony/Component/DependencyInjection/composer.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php":">=5.5.9"
2020
},
2121
"require-dev": {
22-
"symfony/yaml":"~2.8|~3.0",
22+
"symfony/yaml":"~3.2",
2323
"symfony/config":"~2.8|~3.0",
2424
"symfony/expression-language":"~2.8|~3.0"
2525
},
@@ -29,6 +29,9 @@
2929
"symfony/expression-language":"For using expressions in service container configuration",
3030
"symfony/proxy-manager-bridge":"Generate service proxies to lazy load them"
3131
},
32+
"conflict": {
33+
"symfony/yaml":"<3.2"
34+
},
3235
"autoload": {
3336
"psr-4": {"Symfony\\Component\\DependencyInjection\\":"" },
3437
"exclude-from-classmap": [

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp