PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / lib / packages / Symfony / Component / Process / PhpProcess.php

PhpProcess.php in Defender Security – Malware Scanner, Login Security & Firewall 6.3.0, at lib/packages/Symfony/Component/Process/PhpProcess.php

73 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace WP_DEFENDER_VENDOR\Symfony\Component\Process;
13
14 use WP_DEFENDER_VENDOR\Symfony\Component\Process\Exception\LogicException;
15 use WP_DEFENDER_VENDOR\Symfony\Component\Process\Exception\RuntimeException;
16
17 /**
18 * PhpProcess runs a PHP script in an independent process.
19 *
20 * $p = new PhpProcess('<?php echo "foo"; ?>');
21 * $p->run();
22 * print $p->getOutput()."\n";
23 *
24 * @author Fabien Potencier <[email protected]>
25 */
26 class PhpProcess extends Process
27 {
28 /**
29 * @param string $script The PHP script to run (as a string)
30 * @param string|null $cwd The working directory or null to use the working dir of the current PHP process
31 * @param array|null $env The environment variables or null to use the same environment as the current PHP process
32 * @param int $timeout The timeout in seconds
33 * @param array|null $php Path to the PHP binary to use with any additional arguments
34 */
35 public function __construct(string $script, ?string $cwd = null, ?array $env = null, int $timeout = 60, ?array $php = null)
36 {
37 if (null === $php) {
38 $executableFinder = new PhpExecutableFinder();
39 $php = $executableFinder->find(false);
40 $php = false === $php ? null : array_merge([$php], $executableFinder->findArguments());
41 }
42 if ('phpdbg' === \PHP_SAPI) {
43 $file = tempnam(sys_get_temp_dir(), 'dbg');
44 file_put_contents($file, $script);
45 register_shutdown_function('unlink', $file);
46 $php[] = $file;
47 $script = null;
48 }
49
50 parent::__construct($php, $cwd, $env, $script, $timeout);
51 }
52
53 /**
54 * {@inheritdoc}
55 */
56 public static function fromShellCommandline(string $command, ?string $cwd = null, ?array $env = null, $input = null, ?float $timeout = 60)
57 {
58 throw new LogicException(sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
59 }
60
61 /**
62 * {@inheritdoc}
63 */
64 public function start(?callable $callback = null, array $env = [])
65 {
66 if (null === $this->getCommandLine()) {
67 throw new RuntimeException('Unable to find the PHP executable.');
68 }
69
70 parent::start($callback, $env);
71 }
72 }
73