Skip to content

Commit

Permalink
Fix output format selection on PHP 5.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sstalle committed Jul 25, 2017
1 parent d3bcab8 commit 3c7aea6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Version 1.2.1-dev
* Fixed fatal error when trying to access ```ContainerBuilder::$outputFormat``` on PHP 5.3.3

## Version 1.2.0
* Fixed some false positives related to yield usage in expression context
Expand Down
11 changes: 6 additions & 5 deletions src/Infrastructure/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ public function buildContainer(OutputInterface $output, $intSize)

$container = new Container();

$self = $this;

$container['lexer'] = function () {
return new ExtendedLexer(array(
'usedAttributes' => array(
Expand Down Expand Up @@ -206,15 +204,18 @@ public function buildContainer(OutputInterface $output, $intSize)
$container['nodePrinter'] = function () {
return new StandardPrettyPrinter();
};
$container['resultPrinter'] = function ($c) use ($self) {
switch ($self->outputFormat) {

$outputFormat = $this->outputFormat;
$container['resultPrinter'] = function ($c) use ($outputFormat) {
switch ($outputFormat) {
case ResultPrinterInterface::PLAIN_FORMAT:
return new CLIResultPrinter($c['output'], $c['nodePrinter'], $c['nodeStatementsRemover']);
case ResultPrinterInterface::JSON_FORMAT:
return new JsonResultPrinter($c['output']);
default: throw new \InvalidArgumentException('Invalid output format: ' . $self->outputFormat);
default: throw new \InvalidArgumentException('Invalid output format: ' . $outputFormat);
}
};

$container['pathChecker'] = function ($c) {
return new PathChecker($c['contextChecker'], $c['resultPrinter']);
};
Expand Down

0 comments on commit 3c7aea6

Please sign in to comment.