Skip to content

Commit 281ccbb

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

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

Processor.php

+2-2
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

+1-1
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';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
transitions:
3+
!php/const 'Symfony\Component\Yaml\Tests\B::FOO':
4+
from:
5+
- !php/const 'Symfony\Component\Yaml\Tests\B::BAR'
6+
to: !php/const 'Symfony\Component\Yaml\Tests\B::BAZ'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
transitions:
3+
!php/const 'Symfony\Component\Yaml\Tests\B::FOO':
4+
from:
5+
- !php/const 'Symfony\Component\Yaml\Tests\B::BAR'
6+
to: ~
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
transitions:
3+
foo:
4+
from:
5+
- bar
6+
to: baz
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: Constants are parsed

0 commit comments

Comments
 (0)