Skip to content

Commit 534d894

Browse files
committed
expand constants
in nearly every circumstance of this project we will want constants
1 parent 933c45a commit 534d894

File tree

7 files changed

+27
-3
lines changed

7 files changed

+27
-3
lines changed

Processor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function processFile(array $config)
3131
$this->io->write(sprintf('<info>%s the "%s" file</info>', $action, $realFile));
3232

3333
// Find the expected params
34-
$expectedValues = $yamlParser->parse(file_get_contents($config['dist-file']));
34+
$expectedValues = $yamlParser->parse(file_get_contents($config['dist-file']), Yaml::PARSE_CONSTANT);
3535
if (!isset($expectedValues[$parameterKey])) {
3636
throw new \InvalidArgumentException(sprintf('The top-level key %s is missing.', $parameterKey));
3737
}
@@ -44,7 +44,7 @@ public function processFile(array $config)
4444
array($parameterKey => array())
4545
);
4646
if ($exists) {
47-
$existingValues = $yamlParser->parse(file_get_contents($realFile));
47+
$existingValues = $yamlParser->parse(file_get_contents($realFile), Yaml::PARSE_CONSTANT);
4848
if ($existingValues === null) {
4949
$existingValues = array();
5050
}

Tests/ProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function testParameterHandling($testCaseName)
107107
'environment' => array(),
108108
'interactive' => false,
109109
),
110-
(array) Yaml::parse(file_get_contents($dataDir.'/setup.yml'))
110+
(array) Yaml::parse(file_get_contents($dataDir.'/setup.yml'), Yaml::PARSE_CONSTANT)
111111
);
112112

113113
$workingDir = sys_get_temp_dir() . '/incenteev_parameter_handler';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
transitions:
3+
!php/const 'Symfony\Component\Yaml\Yaml::PARSE_CONSTANT':
4+
from:
5+
- !php/const 'Symfony\Component\Yaml\Yaml::PARSE_CUSTOM_TAGS'
6+
to: !php/const 'Symfony\Component\Yaml\Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is auto-generated during the composer install
2+
parameters:
3+
transitions:
4+
!php/const 'Symfony\Component\Yaml\Yaml::PARSE_CONSTANT':
5+
from:
6+
- !php/const 'Symfony\Component\Yaml\Yaml::PARSE_CUSTOM_TAGS'
7+
to: !php/const 'Symfony\Component\Yaml\Yaml::PARSE_OBJECT'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is auto-generated during the composer install
2+
parameters:
3+
transitions:
4+
256:
5+
from:
6+
- 512
7+
to: 4
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: Constants are parsed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
"autoload": {
2323
"psr-4": { "Incenteev\\ParameterHandler\\": "" }
2424
},
25+
"autoload-dev": {
26+
"psr-4": { "Symfony\\Component\\Yaml\\": "" }
27+
},
2528
"extra": {
2629
"branch-alias": {
2730
"dev-master": "2.1.x-dev"

0 commit comments

Comments
 (0)