PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.8.1
Defender Security – Malware Scanner, Login Security & Firewall v5.8.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 5.8.1, at vendor/symfony/process/PhpExecutableFinder.php

97 lines 2.3 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 * @return string|false
33 */
34 public function find(bool $includeArgs = true)
35 {
36 if ($php = getenv('PHP_BINARY')) {
37 if (!is_executable($php) && !$php = $this->executableFinder->find($php)) {
38 return false;
39 }
40
41 if (@is_dir($php)) {
42 return false;
43 }
44
45 return $php;
46 }
47
48 $args = $this->findArguments();
49 $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
50
51 // PHP_BINARY return the current sapi executable
52 if (\PHP_BINARY && \in_array(\PHP_SAPI, ['cli', 'cli-server', 'phpdbg'], true)) {
53 return \PHP_BINARY.$args;
54 }
55
56 if ($php = getenv('PHP_PATH')) {
57 if (!@is_executable($php) || @is_dir($php)) {
58 return false;
59 }
60
61 return $php;
62 }
63
64 if ($php = getenv('PHP_PEAR_PHP_BIN')) {
65 if (@is_executable($php) && !@is_dir($php)) {
66 return $php;
67 }
68 }
69
70 if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php')) && !@is_dir($php)) {
71 return $php;
72 }
73
74 $dirs = [\PHP_BINDIR];
75 if ('\\' === \DIRECTORY_SEPARATOR) {
76 $dirs[] = 'C:\xampp\php\\';
77 }
78
79 return $this->executableFinder->find('php', false, $dirs);
80 }
81
82 /**
83 * Finds the PHP executable arguments.
84 *
85 * @return array
86 */
87 public function findArguments()
88 {
89 $arguments = [];
90 if ('phpdbg' === \PHP_SAPI) {
91 $arguments[] = '-qrr';
92 }
93
94 return $arguments;
95 }
96 }
97