Skip to content

Commit

Permalink
merged branch stof/fix_5_3 (PR #7662)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

Fixed the Console code on PHP 5.3

| Q             | A
| ------------- | ---
| Fixed tickets | none (catched by the Travis builds)
| License       | MIT

The PR #7657 introduced a requirement on PHP 5.4 by mistake.

Commits
-------

1356050 Fixed the Console code on PHP 5.3
  • Loading branch information
fabpot committed Apr 13, 2013
2 parents bedac11 + 1356050 commit 9b6d30c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/Symfony/Component/Console/Input/ArgvInput.php
Expand Up @@ -320,11 +320,14 @@ public function getParameterOption($values, $default = false)
*/
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;
Expand Down
4 changes: 3 additions & 1 deletion src/Symfony/Component/Console/Input/Input.php
Expand Up @@ -214,9 +214,11 @@ public function hasOption($name)
/**
* 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);
}
Expand Down

0 comments on commit 9b6d30c

Please sign in to comment.