Skip to content

Commit f1aff05

Browse files
clemlatzGrahamCampbell
authored andcommitted
Fix deprecation errors for symfony/process v3.x (#138)
1 parent 37793d6 commit f1aff05

File tree

3 files changed

+4
-49
lines changed

3 files changed

+4
-49
lines changed

.travis.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,12 @@ language: php
33
sudo: false
44

55
php:
6-
- 5.4
7-
- 5.5
86
- 5.6
97
- 7.0
108
- 7.1
119
- 7.2
1210
- 7.3
1311

14-
matrix:
15-
include:
16-
- php: 5.3
17-
dist: precise
18-
1912
before_install:
2013
# turn off XDebug, if present
2114
- phpenv config-rm xdebug.ini || return 0

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
}
2727
},
2828
"require": {
29-
"php": "^5.3 || ^7.0",
30-
"symfony/process": "^2.3|^3.0|^4.0"
29+
"php": "^5.6 || ^7.0",
30+
"symfony/process": "^3.4|^4.0"
3131
},
3232
"require-dev": {
3333
"phpunit/phpunit": "^4.8.35|^5.7",

src/Gitonomy/Git/Repository.php

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,7 @@ public function getDiff($revisions)
417417
*/
418418
public function getSize()
419419
{
420-
$commandlineArguments = array('du', '-skc', $this->gitDir);
421-
$commandline = $this->normalizeCommandlineArguments($commandlineArguments);
422-
$process = new Process($commandline);
420+
$process = new Process(array('du', '-skc', $this->gitDir));
423421
$process->run();
424422

425423
if (!preg_match('/(\d+)\s+total$/', trim($process->getOutput()), $vars)) {
@@ -621,47 +619,11 @@ private function getProcess($command, $args = array())
621619

622620
$base[] = $command;
623621

624-
$commandlineArguments = array_merge($base, $args);
625-
$commandline = $this->normalizeCommandlineArguments($commandlineArguments);
626-
627-
$process = new Process($commandline);
622+
$process = new Process(array_merge($base, $args));
628623
$process->setEnv($this->environmentVariables);
629624
$process->setTimeout($this->processTimeout);
630625
$process->setIdleTimeout($this->processTimeout);
631626

632627
return $process;
633628
}
634-
635-
/**
636-
* This internal helper method is used to convert an array of commandline
637-
* arguments to an escaped commandline string for older versions of the
638-
* Symfony Process component.
639-
*
640-
* It acts as a backward compatible layer for Symfony Process < 3.3.
641-
*
642-
* @param array $arguments a list of command line arguments
643-
*
644-
* @return string|array a single escaped string (< 4.0) or a raw array of
645-
* the arguments passed in (4.0+)
646-
*
647-
* @see Process::escapeArgument()
648-
* @see ProcessUtils::escapeArgument()
649-
*/
650-
private function normalizeCommandlineArguments(array $arguments)
651-
{
652-
// From version 4.0 and onwards, the Process accepts an array of
653-
// arguments, and escaping is taken care of automatically.
654-
if (!class_exists('Symfony\Component\Process\ProcessBuilder')) {
655-
return $arguments;
656-
}
657-
658-
// For version < 3.3, the Process only accepts a simple string
659-
// as commandline, and escaping has to happen manually.
660-
$commandline = implode(' ', array_map(
661-
'Symfony\Component\Process\ProcessUtils::escapeArgument',
662-
$arguments
663-
));
664-
665-
return $commandline;
666-
}
667629
}

0 commit comments

Comments
 (0)