Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand constants #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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\Yaml::PARSE_CONSTANT':
from:
- !php/const 'Symfony\Component\Yaml\Yaml::PARSE_CUSTOM_TAGS'
to: !php/const 'Symfony\Component\Yaml\Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE'
7 changes: 7 additions & 0 deletions Tests/fixtures/testcases/parse_constants/existing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file is auto-generated during the composer install
parameters:
transitions:
!php/const 'Symfony\Component\Yaml\Yaml::PARSE_CONSTANT':
from:
- !php/const 'Symfony\Component\Yaml\Yaml::PARSE_CUSTOM_TAGS'
to: !php/const 'Symfony\Component\Yaml\Yaml::PARSE_OBJECT'
7 changes: 7 additions & 0 deletions Tests/fixtures/testcases/parse_constants/expected.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file is auto-generated during the composer install
parameters:
transitions:
256:
from:
- 512
to: 4
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
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"autoload": {
"psr-4": { "Incenteev\\ParameterHandler\\": "" }
},
"autoload-dev": {
"psr-4": { "Symfony\\Component\\Yaml\\": "" }
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use spaces instead of tabs

"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
Expand Down