Commit
…g an exception when the executable is not found I've made the change as the executable goal is to find the executable. The fact that it does not find it is part of the contract and it is not exceptional.
- Loading branch information
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,11 +28,16 @@ public function __construct() | |
$this->executableFinder = new ExecutableFinder(); | ||
} | ||
|
||
/** | ||
* Finds The PHP executable. | ||
* | ||
* @return string|false The PHP executable path or false if it cannot be found | ||
*/ | ||
public function find() | ||
{ | ||
if ($php = getenv('PHP_PATH')) { | ||
if (!is_executable($php)) { | ||
throw new RuntimeException('The defined PHP_PATH environment variable is not a valid PHP executable.'); | ||
return false; | ||
This comment has been minimized.
Sorry, something went wrong.
avalanche123
Contributor
|
||
} | ||
|
||
return $php; | ||
|
@@ -53,4 +58,4 @@ public function find() | |
|
||
return $this->executableFinder->find('php'); | ||
} | ||
} | ||
} |
4 comments
on commit e2741ce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you claim that it is not exceptional, could you please show me examples where not finding the executable does not eventually lead to abortion of the normal control flow? I think your changes to the PhpProcess class exemplify quite well, that it is exceptional.
If the problem lies in the naming of the method, then we should rather change "find" to "get" to make the contract stronger, but I cannot come up with any use case where the normal control flow can proceed if the executable does not exist. It's like trying to load a class and if that fails you continue like normal which obviously doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Déjà vu.
I could think of ways where if you don't have an executable you try to resort to some crappy php emulation of whatever you were trying to do with an exec() call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A related PR #663.
Why not use something like (skip unneeded variable assign):