Skip to content

Commit

Permalink
[Process] Clean-up/simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Jul 3, 2012
1 parent 0995610 commit 9c35e1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 5 additions & 1 deletion ExecutableFinder.php
Expand Up @@ -71,7 +71,11 @@ public function find($name, $default = null, array $extraDirs = array())
);
}

$suffixes = DIRECTORY_SEPARATOR == '\\' ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : $this->suffixes) : array('');
$suffixes = array('');
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$pathExt = getenv('PATHEXT');
$suffixes = $pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes;
}
foreach ($suffixes as $suffix) {
foreach ($dirs as $dir) {
if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && (self::$isWindows || is_executable($file))) {
Expand Down
11 changes: 3 additions & 8 deletions PhpExecutableFinder.php
Expand Up @@ -46,19 +46,14 @@ public function find()
return $php;
}

$suffixes = DIRECTORY_SEPARATOR == '\\' ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : array('.exe', '.bat', '.cmd', '.com')) : array('');
foreach ($suffixes as $suffix) {
if (is_executable($php = PHP_BINDIR.DIRECTORY_SEPARATOR.'php'.$suffix)) {
return $php;
}
}

if ($php = getenv('PHP_PEAR_PHP_BIN')) {
if (is_executable($php)) {
return $php;
}
}

return $this->executableFinder->find('php');
$dirs = array(PHP_BINDIR);

return $this->executableFinder->find('php', false, $dirs);
}
}

0 comments on commit 9c35e1e

Please sign in to comment.