File tree Expand file tree Collapse file tree 2 files changed +32
-8
lines changed
Expand file tree Collapse file tree 2 files changed +32
-8
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ public function find($includeArgs = true)
4747 }
4848 }
4949
50+ if (@is_dir ($ php )) {
51+ return false ;
52+ }
53+
5054 return $ php ;
5155 }
5256
@@ -59,20 +63,20 @@ public function find($includeArgs = true)
5963 }
6064
6165 if ($ php = getenv ('PHP_PATH ' )) {
62- if (!@is_executable ($ php )) {
66+ if (!@is_executable ($ php ) || @ is_dir ( $ php ) ) {
6367 return false ;
6468 }
6569
6670 return $ php ;
6771 }
6872
6973 if ($ php = getenv ('PHP_PEAR_PHP_BIN ' )) {
70- if (@is_executable ($ php )) {
74+ if (@is_executable ($ php ) && !@ is_dir ( $ php ) ) {
7175 return $ php ;
7276 }
7377 }
7478
75- if (@is_executable ($ php = \PHP_BINDIR .('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe ' : '/php ' ))) {
79+ if (@is_executable ($ php = \PHP_BINDIR .('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe ' : '/php ' )) && !@ is_dir ( $ php ) ) {
7680 return $ php ;
7781 }
7882
Original file line number Diff line number Diff line change @@ -50,12 +50,32 @@ public function testFindArguments()
5050 public function testNotExitsBinaryFile ()
5151 {
5252 $ f = new PhpExecutableFinder ();
53- $ phpBinaryEnv = \PHP_BINARY ;
54- putenv ('PHP_BINARY=/usr/local/php/bin/php-invalid ' );
5553
56- $ this ->assertFalse ($ f ->find (), '::find() returns false because of not exist file ' );
57- $ this ->assertFalse ($ f ->find (false ), '::find(false) returns false because of not exist file ' );
54+ $ originalPhpBinary = getenv ('PHP_BINARY ' );
5855
59- putenv ('PHP_BINARY= ' .$ phpBinaryEnv );
56+ try {
57+ putenv ('PHP_BINARY=/usr/local/php/bin/php-invalid ' );
58+
59+ $ this ->assertFalse ($ f ->find (), '::find() returns false because of not exist file ' );
60+ $ this ->assertFalse ($ f ->find (false ), '::find(false) returns false because of not exist file ' );
61+ } finally {
62+ putenv ('PHP_BINARY= ' .$ originalPhpBinary );
63+ }
64+ }
65+
66+ public function testFindWithExecutableDirectory ()
67+ {
68+ $ originalPhpBinary = getenv ('PHP_BINARY ' );
69+
70+ try {
71+ $ executableDirectoryPath = sys_get_temp_dir ().'/PhpExecutableFinderTest_testFindWithExecutableDirectory ' ;
72+ @mkdir ($ executableDirectoryPath );
73+ $ this ->assertTrue (is_executable ($ executableDirectoryPath ));
74+ putenv ('PHP_BINARY= ' .$ executableDirectoryPath );
75+
76+ $ this ->assertFalse ((new PhpExecutableFinder ())->find ());
77+ } finally {
78+ putenv ('PHP_BINARY= ' .$ originalPhpBinary );
79+ }
6080 }
6181}
You can’t perform that action at this time.
0 commit comments