Fixed the Console code on PHP 5.3

The PR #7657 introduced a requirement on PHP 5.4 by mistake.
This commit is contained in:
Christophe Coevoet 2013-04-13 16:06:01 +02:00
parent bedac11d57
commit 1356050f21
2 changed files with 10 additions and 5 deletions

View File

@ -320,11 +320,14 @@ class ArgvInput extends Input
*/
public function __toString()
{
$tokens = array_map(function ($token) {
$self = $this;
$tokens = array_map(function ($token) use ($self) {
if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
return $match[1] . $this->escapeToken($match[2]);
} elseif ($token && $token[0] !== '-') {
return $this->escapeToken($token);
return $match[1] . $self->escapeToken($match[2]);
}
if ($token && $token[0] !== '-') {
return $self->escapeToken($token);
}
return $token;

View File

@ -214,9 +214,11 @@ abstract class Input implements InputInterface
/**
* Escapes a token through escapeshellarg if it contains unsafe chars
*
* @param string $token
*
* @return string
*/
protected function escapeToken($token)
public function escapeToken($token)
{
return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
}