diff --git a/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php index 16b9af4431..f221a68f8c 100644 --- a/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php @@ -12,7 +12,6 @@ namespace Symfony\Bundle\AsseticBundle\DependencyInjection; use Symfony\Component\Process\ExecutableFinder; -use Symfony\Component\Process\Exception\ExecutableNotFoundException; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -58,9 +57,9 @@ class Configuration implements ConfigurationInterface ->booleanNode('use_controller')->defaultValue($this->debug)->end() ->scalarNode('read_from')->defaultValue('%kernel.root_dir%/../web')->end() ->scalarNode('write_to')->defaultValue('%assetic.read_from%')->end() - ->scalarNode('java')->defaultValue(function() use ($finder) { try { return $finder->find('java'); } catch(ExecutableNotFoundException $ex) { return null; } })->end() - ->scalarNode('node')->defaultValue(function() use ($finder) { try { return $finder->find('node'); } catch(ExecutableNotFoundException $ex) { return null; } })->end() - ->scalarNode('sass')->defaultValue(function() use ($finder) { try { return $finder->find('sass'); } catch(ExecutableNotFoundException $ex) { return null; } })->end() + ->scalarNode('java')->defaultValue(function() use ($finder) { $java = $finder->find('java'); return $java ? $java : '/usr/bin/java'; })->end() + ->scalarNode('node')->defaultValue(function() use ($finder) { $node = $finder->find('node'); return $node ? $node : '/usr/bin/node'; })->end() + ->scalarNode('sass')->defaultValue(function() use ($finder) { $saas = $finder->find('saas'); return $saas ? $saas : '/usr/bin/saas'; })->end() ->end() // bundles diff --git a/src/Symfony/Component/Process/Exception/Exception.php b/src/Symfony/Component/Process/Exception/Exception.php deleted file mode 100644 index 0f4e490d02..0000000000 --- a/src/Symfony/Component/Process/Exception/Exception.php +++ /dev/null @@ -1,12 +0,0 @@ - - */ -interface Exception -{ -} \ No newline at end of file diff --git a/src/Symfony/Component/Process/Exception/ExecutableNotFoundException.php b/src/Symfony/Component/Process/Exception/ExecutableNotFoundException.php deleted file mode 100644 index 7fc87c22ed..0000000000 --- a/src/Symfony/Component/Process/Exception/ExecutableNotFoundException.php +++ /dev/null @@ -1,25 +0,0 @@ - - */ -class ExecutableNotFoundException extends RuntimeException -{ - private $name; - - public function __construct($name) - { - parent::__construct(sprintf('Could not find executable "%s".', $name)); - - $this->name = $name; - } - - public function getName() - { - return $this->name; - } -} \ No newline at end of file diff --git a/src/Symfony/Component/Process/Exception/RuntimeException.php b/src/Symfony/Component/Process/Exception/RuntimeException.php deleted file mode 100644 index 4dd0f5f203..0000000000 --- a/src/Symfony/Component/Process/Exception/RuntimeException.php +++ /dev/null @@ -1,12 +0,0 @@ - - */ -class RuntimeException extends \RuntimeException implements Exception -{ -} \ No newline at end of file diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index 6c774d6900..630e10b8ee 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Process; -use Symfony\Component\Process\Exception\ExecutableNotFoundException; - /** * Generic executable finder. * @@ -33,6 +31,13 @@ class ExecutableFinder $this->suffixes[] = $suffix; } + /** + * Finds an executable by name. + * + * @param string $name The executable name (without the extension) + * + * @return string|false The executable path or false if it cannot be found + */ public function find($name) { $dirs = explode(PATH_SEPARATOR, getenv('PATH') ? getenv('PATH') : getenv('Path')); @@ -45,6 +50,6 @@ class ExecutableFinder } } - throw new ExecutableNotFoundException($name); + return false; } -} \ No newline at end of file +} diff --git a/src/Symfony/Component/Process/PhpExecutableFinder.php b/src/Symfony/Component/Process/PhpExecutableFinder.php index a53a922f66..f15ebe0b52 100644 --- a/src/Symfony/Component/Process/PhpExecutableFinder.php +++ b/src/Symfony/Component/Process/PhpExecutableFinder.php @@ -28,11 +28,16 @@ class PhpExecutableFinder $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; } return $php; @@ -53,4 +58,4 @@ class PhpExecutableFinder return $this->executableFinder->find('php'); } -} \ No newline at end of file +} diff --git a/src/Symfony/Component/Process/PhpProcess.php b/src/Symfony/Component/Process/PhpProcess.php index 1dd15886c2..2bd5600451 100644 --- a/src/Symfony/Component/Process/PhpProcess.php +++ b/src/Symfony/Component/Process/PhpProcess.php @@ -67,7 +67,10 @@ class PhpProcess extends Process public function run($callback = null) { if (null === $this->getCommandLine()) { - $this->setCommandLine($this->executableFinder->find()); + if (false === $php = $this->executableFinder->find()) { + throw new \RuntimeException('Unable to find the PHP executable.'); + } + $this->setCommandLine($php); } return parent::run($callback);