File tree 2 files changed +32
-8
lines changed
src/Symfony/Component/Process
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)
47
47
}
48
48
}
49
49
50
+ if (@is_dir ($ php )) {
51
+ return false ;
52
+ }
53
+
50
54
return $ php ;
51
55
}
52
56
@@ -59,20 +63,20 @@ public function find($includeArgs = true)
59
63
}
60
64
61
65
if ($ php = getenv ('PHP_PATH ' )) {
62
- if (!@is_executable ($ php )) {
66
+ if (!@is_executable ($ php ) || @ is_dir ( $ php ) ) {
63
67
return false ;
64
68
}
65
69
66
70
return $ php ;
67
71
}
68
72
69
73
if ($ php = getenv ('PHP_PEAR_PHP_BIN ' )) {
70
- if (@is_executable ($ php )) {
74
+ if (@is_executable ($ php ) && !@ is_dir ( $ php ) ) {
71
75
return $ php ;
72
76
}
73
77
}
74
78
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 ) ) {
76
80
return $ php ;
77
81
}
78
82
Original file line number Diff line number Diff line change @@ -50,12 +50,32 @@ public function testFindArguments()
50
50
public function testNotExitsBinaryFile ()
51
51
{
52
52
$ f = new PhpExecutableFinder ();
53
- $ phpBinaryEnv = \PHP_BINARY ;
54
- putenv ('PHP_BINARY=/usr/local/php/bin/php-invalid ' );
55
53
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 ' );
58
55
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
+ }
60
80
}
61
81
}
You can’t perform that action at this time.
0 commit comments