ProcessUtils is a bunch of utility methods.
More...
ProcessUtils is a bunch of utility methods.
This class contains static methods only and is not meant to be instantiated.
- Author
- Martin HasoĊ marti.nosp@m.n.ha.nosp@m.son@g.nosp@m.mail.nosp@m..com
Definition at line 23 of file ProcessUtils.php.
◆ __construct()
Symfony\Component\Process\ProcessUtils::__construct |
( |
| ) |
|
|
private |
◆ escapeArgument()
static Symfony\Component\Process\ProcessUtils::escapeArgument |
( |
|
$argument | ) |
|
|
static |
Escapes a string to be used as a shell argument.
- Parameters
-
string | $argument | The argument that will be escaped |
- Returns
- string The escaped argument
Definition at line 39 of file ProcessUtils.php.
Referenced by Symfony\Component\Process\Process\start(), and Symfony\Component\Process\Tests\ProcessUtilsTest\testEscapeArgument().
45 if (
'\\' === DIRECTORY_SEPARATOR) {
46 if (
'' === $argument) {
47 return escapeshellarg($argument);
50 $escapedArgument =
'';
52 foreach (preg_split(
'/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
54 $escapedArgument .=
'\\"';
55 } elseif (self::isSurroundedBy($part,
'%')) {
57 $escapedArgument .=
'^%"'.substr($part, 1, -1).
'"^%';
60 if (
'\\' === substr($part, -1)) {
64 $escapedArgument .= $part;
68 $escapedArgument =
'"'.$escapedArgument.
'"';
71 return $escapedArgument;
74 return escapeshellarg($argument);
◆ isSurroundedBy()
static Symfony\Component\Process\ProcessUtils::isSurroundedBy |
( |
|
$arg, |
|
|
|
$char |
|
) |
| |
|
staticprivate |
Definition at line 115 of file ProcessUtils.php.
117 return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1];
◆ validateInput()
static Symfony\Component\Process\ProcessUtils::validateInput |
( |
|
$caller, |
|
|
|
$input |
|
) |
| |
|
static |
The documentation for this class was generated from the following file: