Skip to content

Commit

Permalink
expand constants
Browse files Browse the repository at this point in the history
in nearly every circumstance of this project we will want constants
  • Loading branch information
EntranceJew committed Jul 25, 2018
1 parent 933c45a commit 281ccbb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function processFile(array $config)
$this->io->write(sprintf('<info>%s the "%s" file</info>', $action, $realFile));

// Find the expected params
$expectedValues = $yamlParser->parse(file_get_contents($config['dist-file']));
$expectedValues = $yamlParser->parse(file_get_contents($config['dist-file']), Yaml::PARSE_CONSTANT);
if (!isset($expectedValues[$parameterKey])) {
throw new \InvalidArgumentException(sprintf('The top-level key %s is missing.', $parameterKey));
}
Expand All @@ -44,7 +44,7 @@ public function processFile(array $config)
array($parameterKey => array())
);
if ($exists) {
$existingValues = $yamlParser->parse(file_get_contents($realFile));
$existingValues = $yamlParser->parse(file_get_contents($realFile), Yaml::PARSE_CONSTANT);
if ($existingValues === null) {
$existingValues = array();
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function testParameterHandling($testCaseName)
'environment' => array(),
'interactive' => false,
),
(array) Yaml::parse(file_get_contents($dataDir.'/setup.yml'))
(array) Yaml::parse(file_get_contents($dataDir.'/setup.yml'), Yaml::PARSE_CONSTANT)
);

$workingDir = sys_get_temp_dir() . '/incenteev_parameter_handler';
Expand Down
6 changes: 6 additions & 0 deletions Tests/fixtures/testcases/parse_constants/dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
transitions:
!php/const 'Symfony\Component\Yaml\Tests\B::FOO':
from:
- !php/const 'Symfony\Component\Yaml\Tests\B::BAR'
to: !php/const 'Symfony\Component\Yaml\Tests\B::BAZ'
6 changes: 6 additions & 0 deletions Tests/fixtures/testcases/parse_constants/existing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
transitions:
!php/const 'Symfony\Component\Yaml\Tests\B::FOO':
from:
- !php/const 'Symfony\Component\Yaml\Tests\B::BAR'
to: ~
6 changes: 6 additions & 0 deletions Tests/fixtures/testcases/parse_constants/expected.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
transitions:
foo:
from:
- bar
to: baz
1 change: 1 addition & 0 deletions Tests/fixtures/testcases/parse_constants/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title: Constants are parsed

0 comments on commit 281ccbb

Please sign in to comment.