PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / symfony / process / PhpExecutableFinder.php

PhpExecutableFinder.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/symfony/process/PhpExecutableFinder.php

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