Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../vendor/symfony/process
File: ProcessBuilder.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/*
[2] Fix | Delete
* This file is part of the Symfony package.
[3] Fix | Delete
*
[4] Fix | Delete
* (c) Fabien Potencier <fabien@symfony.com>
[5] Fix | Delete
*
[6] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[7] Fix | Delete
* file that was distributed with this source code.
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
namespace Symfony\Component\Process;
[11] Fix | Delete
[12] Fix | Delete
@trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use the Process class instead.', ProcessBuilder::class), \E_USER_DEPRECATED);
[13] Fix | Delete
[14] Fix | Delete
use Symfony\Component\Process\Exception\InvalidArgumentException;
[15] Fix | Delete
use Symfony\Component\Process\Exception\LogicException;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* @author Kris Wallsmith <kris@symfony.com>
[19] Fix | Delete
*
[20] Fix | Delete
* @deprecated since version 3.4, to be removed in 4.0. Use the Process class instead.
[21] Fix | Delete
*/
[22] Fix | Delete
class ProcessBuilder
[23] Fix | Delete
{
[24] Fix | Delete
private $arguments;
[25] Fix | Delete
private $cwd;
[26] Fix | Delete
private $env = [];
[27] Fix | Delete
private $input;
[28] Fix | Delete
private $timeout = 60;
[29] Fix | Delete
private $options;
[30] Fix | Delete
private $inheritEnv = true;
[31] Fix | Delete
private $prefix = [];
[32] Fix | Delete
private $outputDisabled = false;
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* @param string[] $arguments An array of arguments
[36] Fix | Delete
*/
[37] Fix | Delete
public function __construct(array $arguments = [])
[38] Fix | Delete
{
[39] Fix | Delete
$this->arguments = $arguments;
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Creates a process builder instance.
[44] Fix | Delete
*
[45] Fix | Delete
* @param string[] $arguments An array of arguments
[46] Fix | Delete
*
[47] Fix | Delete
* @return static
[48] Fix | Delete
*/
[49] Fix | Delete
public static function create(array $arguments = [])
[50] Fix | Delete
{
[51] Fix | Delete
return new static($arguments);
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Adds an unescaped argument to the command string.
[56] Fix | Delete
*
[57] Fix | Delete
* @param string $argument A command argument
[58] Fix | Delete
*
[59] Fix | Delete
* @return $this
[60] Fix | Delete
*/
[61] Fix | Delete
public function add($argument)
[62] Fix | Delete
{
[63] Fix | Delete
$this->arguments[] = $argument;
[64] Fix | Delete
[65] Fix | Delete
return $this;
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Adds a prefix to the command string.
[70] Fix | Delete
*
[71] Fix | Delete
* The prefix is preserved when resetting arguments.
[72] Fix | Delete
*
[73] Fix | Delete
* @param string|array $prefix A command prefix or an array of command prefixes
[74] Fix | Delete
*
[75] Fix | Delete
* @return $this
[76] Fix | Delete
*/
[77] Fix | Delete
public function setPrefix($prefix)
[78] Fix | Delete
{
[79] Fix | Delete
$this->prefix = \is_array($prefix) ? $prefix : [$prefix];
[80] Fix | Delete
[81] Fix | Delete
return $this;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Sets the arguments of the process.
[86] Fix | Delete
*
[87] Fix | Delete
* Arguments must not be escaped.
[88] Fix | Delete
* Previous arguments are removed.
[89] Fix | Delete
*
[90] Fix | Delete
* @param string[] $arguments
[91] Fix | Delete
*
[92] Fix | Delete
* @return $this
[93] Fix | Delete
*/
[94] Fix | Delete
public function setArguments(array $arguments)
[95] Fix | Delete
{
[96] Fix | Delete
$this->arguments = $arguments;
[97] Fix | Delete
[98] Fix | Delete
return $this;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* Sets the working directory.
[103] Fix | Delete
*
[104] Fix | Delete
* @param string|null $cwd The working directory
[105] Fix | Delete
*
[106] Fix | Delete
* @return $this
[107] Fix | Delete
*/
[108] Fix | Delete
public function setWorkingDirectory($cwd)
[109] Fix | Delete
{
[110] Fix | Delete
$this->cwd = $cwd;
[111] Fix | Delete
[112] Fix | Delete
return $this;
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
/**
[116] Fix | Delete
* Sets whether environment variables will be inherited or not.
[117] Fix | Delete
*
[118] Fix | Delete
* @param bool $inheritEnv
[119] Fix | Delete
*
[120] Fix | Delete
* @return $this
[121] Fix | Delete
*/
[122] Fix | Delete
public function inheritEnvironmentVariables($inheritEnv = true)
[123] Fix | Delete
{
[124] Fix | Delete
$this->inheritEnv = $inheritEnv;
[125] Fix | Delete
[126] Fix | Delete
return $this;
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
/**
[130] Fix | Delete
* Sets an environment variable.
[131] Fix | Delete
*
[132] Fix | Delete
* Setting a variable overrides its previous value. Use `null` to unset a
[133] Fix | Delete
* defined environment variable.
[134] Fix | Delete
*
[135] Fix | Delete
* @param string $name The variable name
[136] Fix | Delete
* @param string|null $value The variable value
[137] Fix | Delete
*
[138] Fix | Delete
* @return $this
[139] Fix | Delete
*/
[140] Fix | Delete
public function setEnv($name, $value)
[141] Fix | Delete
{
[142] Fix | Delete
$this->env[$name] = $value;
[143] Fix | Delete
[144] Fix | Delete
return $this;
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
/**
[148] Fix | Delete
* Adds a set of environment variables.
[149] Fix | Delete
*
[150] Fix | Delete
* Already existing environment variables with the same name will be
[151] Fix | Delete
* overridden by the new values passed to this method. Pass `null` to unset
[152] Fix | Delete
* a variable.
[153] Fix | Delete
*
[154] Fix | Delete
* @param array $variables The variables
[155] Fix | Delete
*
[156] Fix | Delete
* @return $this
[157] Fix | Delete
*/
[158] Fix | Delete
public function addEnvironmentVariables(array $variables)
[159] Fix | Delete
{
[160] Fix | Delete
$this->env = array_replace($this->env, $variables);
[161] Fix | Delete
[162] Fix | Delete
return $this;
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
/**
[166] Fix | Delete
* Sets the input of the process.
[167] Fix | Delete
*
[168] Fix | Delete
* @param resource|string|int|float|bool|\Traversable|null $input The input content
[169] Fix | Delete
*
[170] Fix | Delete
* @return $this
[171] Fix | Delete
*
[172] Fix | Delete
* @throws InvalidArgumentException In case the argument is invalid
[173] Fix | Delete
*/
[174] Fix | Delete
public function setInput($input)
[175] Fix | Delete
{
[176] Fix | Delete
$this->input = ProcessUtils::validateInput(__METHOD__, $input);
[177] Fix | Delete
[178] Fix | Delete
return $this;
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
/**
[182] Fix | Delete
* Sets the process timeout.
[183] Fix | Delete
*
[184] Fix | Delete
* To disable the timeout, set this value to null.
[185] Fix | Delete
*
[186] Fix | Delete
* @param float|null $timeout
[187] Fix | Delete
*
[188] Fix | Delete
* @return $this
[189] Fix | Delete
*
[190] Fix | Delete
* @throws InvalidArgumentException
[191] Fix | Delete
*/
[192] Fix | Delete
public function setTimeout($timeout)
[193] Fix | Delete
{
[194] Fix | Delete
if (null === $timeout) {
[195] Fix | Delete
$this->timeout = null;
[196] Fix | Delete
[197] Fix | Delete
return $this;
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
$timeout = (float) $timeout;
[201] Fix | Delete
[202] Fix | Delete
if ($timeout < 0) {
[203] Fix | Delete
throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
$this->timeout = $timeout;
[207] Fix | Delete
[208] Fix | Delete
return $this;
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
/**
[212] Fix | Delete
* Adds a proc_open option.
[213] Fix | Delete
*
[214] Fix | Delete
* @param string $name The option name
[215] Fix | Delete
* @param string $value The option value
[216] Fix | Delete
*
[217] Fix | Delete
* @return $this
[218] Fix | Delete
*/
[219] Fix | Delete
public function setOption($name, $value)
[220] Fix | Delete
{
[221] Fix | Delete
$this->options[$name] = $value;
[222] Fix | Delete
[223] Fix | Delete
return $this;
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
/**
[227] Fix | Delete
* Disables fetching output and error output from the underlying process.
[228] Fix | Delete
*
[229] Fix | Delete
* @return $this
[230] Fix | Delete
*/
[231] Fix | Delete
public function disableOutput()
[232] Fix | Delete
{
[233] Fix | Delete
$this->outputDisabled = true;
[234] Fix | Delete
[235] Fix | Delete
return $this;
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
/**
[239] Fix | Delete
* Enables fetching output and error output from the underlying process.
[240] Fix | Delete
*
[241] Fix | Delete
* @return $this
[242] Fix | Delete
*/
[243] Fix | Delete
public function enableOutput()
[244] Fix | Delete
{
[245] Fix | Delete
$this->outputDisabled = false;
[246] Fix | Delete
[247] Fix | Delete
return $this;
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
/**
[251] Fix | Delete
* Creates a Process instance and returns it.
[252] Fix | Delete
*
[253] Fix | Delete
* @return Process
[254] Fix | Delete
*
[255] Fix | Delete
* @throws LogicException In case no arguments have been provided
[256] Fix | Delete
*/
[257] Fix | Delete
public function getProcess()
[258] Fix | Delete
{
[259] Fix | Delete
if (0 === \count($this->prefix) && 0 === \count($this->arguments)) {
[260] Fix | Delete
throw new LogicException('You must add() command arguments before calling getProcess().');
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
$arguments = array_merge($this->prefix, $this->arguments);
[264] Fix | Delete
$process = new Process($arguments, $this->cwd, $this->env, $this->input, $this->timeout, $this->options);
[265] Fix | Delete
// to preserve the BC with symfony <3.3, we convert the array structure
[266] Fix | Delete
// to a string structure to avoid the prefixing with the exec command
[267] Fix | Delete
$process->setCommandLine($process->getCommandLine());
[268] Fix | Delete
[269] Fix | Delete
if ($this->inheritEnv) {
[270] Fix | Delete
$process->inheritEnvironmentVariables();
[271] Fix | Delete
}
[272] Fix | Delete
if ($this->outputDisabled) {
[273] Fix | Delete
$process->disableOutput();
[274] Fix | Delete
}
[275] Fix | Delete
[276] Fix | Delete
return $process;
[277] Fix | Delete
}
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function