From 3c7aea63bf50e6f45f19e1f0f321eb688f6f1426 Mon Sep 17 00:00:00 2001 From: alexey Date: Tue, 25 Jul 2017 13:03:14 +0400 Subject: [PATCH] Fix output format selection on PHP 5.3.3 --- CHANGELOG.md | 1 + src/Infrastructure/ContainerBuilder.php | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d874fa..9175c15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/Infrastructure/ContainerBuilder.php b/src/Infrastructure/ContainerBuilder.php index ddc5981..18968e8 100644 --- a/src/Infrastructure/ContainerBuilder.php +++ b/src/Infrastructure/ContainerBuilder.php @@ -151,8 +151,6 @@ public function buildContainer(OutputInterface $output, $intSize) $container = new Container(); - $self = $this; - $container['lexer'] = function () { return new ExtendedLexer(array( 'usedAttributes' => array( @@ -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']); };