From caff32309132a9418974017f3dfcdf4a50e7c55f Mon Sep 17 00:00:00 2001 From: Michael Schmidt-Voigt Date: Mon, 5 Mar 2018 22:36:08 +1300 Subject: [PATCH] Update dependencies --- CHANGELOG.md | 5 +++++ composer.json | 4 ++-- src/Drafter.php | 30 ++++++++++++++---------------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb97471..b3a3b78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The change log itself is written the way that [keepachangelog.com](http://keepac ## [Unreleased] +## [5.0.0] - 2018-03-05 +## Changed +- Allow v4 of Symfony component +- Update Robo task runner + ## [4.0.1] - 2016-09-20 ## Changed - Removed the cumbersome way to install drafter and added a reference to hmaus/drafter-installer diff --git a/composer.json b/composer.json index cb5d8aa..83ab504 100644 --- a/composer.json +++ b/composer.json @@ -11,11 +11,11 @@ "minimum-stability": "stable", "require": { "php": ">=5.6", - "symfony/process": "^2.7|^3.1.4" + "symfony/process": "^2.7|^3.1.4|^4" }, "require-dev": { "phpunit/phpunit": "^5.0", - "codegyre/robo": "^0.7.2", + "consolidation/robo": "^1.2.2", "codeclimate/php-test-reporter": "^0.3", "hmaus/drafter-installer": "^1.0" }, diff --git a/src/Drafter.php b/src/Drafter.php index ef3e53c..60ebfe0 100644 --- a/src/Drafter.php +++ b/src/Drafter.php @@ -47,7 +47,6 @@ namespace Hmaus\DrafterPhp; use Symfony\Component\Process\Process; -use Symfony\Component\Process\ProcessBuilder; class Drafter implements DrafterInterface { @@ -145,16 +144,13 @@ public function useLineNum() public function build() { - $builder = new ProcessBuilder(); - $builder->setPrefix($this->binary); - $this->validateOptionsAndArguments(); - $builder->setArguments( - $this->getProcessBuilderArguments() + $process = new Process( + $this->getProcessCommand() ); - return $builder->getProcess(); + return $process; } public function run(Process $process = null) @@ -241,29 +237,31 @@ private function isVersionOptionSet() } /** - * Get arguments array to pass it into the process builder. + * Get command to pass it into the process. * * The method will append the input file path argument to the end, like * described in the `drafter --help` output. * - * @return array|\string[] + * @return string */ - private function getProcessBuilderArguments() + private function getProcessCommand() { $options = $this->transformOptions(); $options[] = $this->input; - return $options; + $command = $this->binary . ' ' . implode(' ', $options); + + return $command; } /** - * Return options prepared to be passed into the ProcessBuilder. + * Return options prepared to be passed into the Process. * * E.g.: ["--output" => "path/to/file"] -> ["--output=path/to/file"] * * The original format is an associative array, where the key is the * option name and the value is the respective value. - * The process builder will want those as single strings to escape them + * The process will want those as single strings to escape them * for the command line. Hence, we have to turn ["--output" => "path/to/file"] * into ["--output=path/to/file"]. * @@ -271,7 +269,7 @@ private function getProcessBuilderArguments() */ private function transformOptions() { - $builderOptions = []; + $processOptions = []; foreach ($this->options as $key => $value) { $option = $key; @@ -280,9 +278,9 @@ private function transformOptions() $option .= '=' . $value; } - $builderOptions[] = $option; + $processOptions[] = $option; } - return $builderOptions; + return $processOptions; } }