PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.0.1
Defender Security – Malware Scanner, Login Security & Firewall v3.0.1
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 / vendor / symfony / process / PhpExecutableFinder.php

PhpExecutableFinder.php in Defender Security – Malware Scanner, Login Security & Firewall 3.0.1, at vendor/symfony/process/PhpExecutableFinder.php

106 lines 2.7 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 Symfony\Component\Process;
13
14 /**
15 * An executable finder specifically designed for the PHP executable.
16 *
17 * @author Fabien Potencier <[email protected]>
18 * @author Johannes M. Schmitt <[email protected]>
19 */
20 class PhpExecutableFinder
21 {
22 private $executableFinder;
23
24 public function __construct()
25 {
26 $this->executableFinder = new ExecutableFinder();
27 }
28
29 /**
30 * Finds The PHP executable.
31 *
32 * @param bool $includeArgs Whether or not include command arguments
33 *
34 * @return string|false The PHP executable path or false if it cannot be found
35 */
36 public function find($includeArgs = true)
37 {
38 if ($php = getenv('PHP_BINARY')) {
39 if (!is_executable($php)) {
40 $command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v';
41 if ($php = strtok(exec($command.' '.escapeshellarg($php)), \PHP_EOL)) {
42 if (!is_executable($php)) {
43 return false;
44 }
45 } else {
46 return false;
47 }
48 }
49
50 if (@is_dir($php)) {
51 return false;
52 }
53
54 return $php;
55 }
56
57 $args = $this->findArguments();
58 $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
59
60 // PHP_BINARY return the current sapi executable
61 if (\PHP_BINARY && \in_array(\PHP_SAPI, ['cgi-fcgi', 'cli', 'cli-server', 'phpdbg'], true)) {
62 return \PHP_BINARY.$args;
63 }
64
65 if ($php = getenv('PHP_PATH')) {
66 if (!@is_executable($php) || @is_dir($php)) {
67 return false;
68 }
69
70 return $php;
71 }
72
73 if ($php = getenv('PHP_PEAR_PHP_BIN')) {
74 if (@is_executable($php) && !@is_dir($php)) {
75 return $php;
76 }
77 }
78
79 if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php')) && !@is_dir($php)) {
80 return $php;
81 }
82
83 $dirs = [\PHP_BINDIR];
84 if ('\\' === \DIRECTORY_SEPARATOR) {
85 $dirs[] = 'C:\xampp\php\\';
86 }
87
88 return $this->executableFinder->find('php', false, $dirs);
89 }
90
91 /**
92 * Finds the PHP executable arguments.
93 *
94 * @return array The PHP executable arguments
95 */
96 public function findArguments()
97 {
98 $arguments = [];
99 if ('phpdbg' === \PHP_SAPI) {
100 $arguments[] = '-qrr';
101 }
102
103 return $arguments;
104 }
105 }
106