1919 */ 
2020class  ExecutableFinder
2121{
22-     private  array  $ suffixes'.exe ' , '.bat ' , '.cmd ' , '.com ' ];
2322    private  const  CMD_BUILTINS  = [
2423        'assoc ' , 'break ' , 'call ' , 'cd ' , 'chdir ' , 'cls ' , 'color ' , 'copy ' , 'date ' ,
2524        'del ' , 'dir ' , 'echo ' , 'endlocal ' , 'erase ' , 'exit ' , 'for ' , 'ftype ' , 'goto ' ,
@@ -28,6 +27,8 @@ class ExecutableFinder
2827        'setlocal ' , 'shift ' , 'start ' , 'time ' , 'title ' , 'type ' , 'ver ' , 'vol ' ,
2928    ];
3029
30+     private  array  $ suffixes
31+ 
3132    /** 
3233     * Replaces default suffixes of executable. 
3334     */ 
@@ -63,11 +64,13 @@ public function find(string $name, ?string $default = null, array $extraDirs = [
6364            $ extraDirs
6465        );
6566
66-         $ suffixes'' ];
67+         $ suffixes
6768        if  ('\\'  === \DIRECTORY_SEPARATOR ) {
6869            $ pathExtgetenv ('PATHEXT ' );
69-             $ suffixesarray_merge ($ pathExtexplode (\PATH_SEPARATOR , $ pathExt$ this suffixes , $ suffixes
70+             $ suffixes$ this suffixes ;
71+             $ suffixesarray_merge ($ suffixes$ pathExtexplode (\PATH_SEPARATOR , $ pathExt'.exe ' , '.bat ' , '.cmd ' , '.com ' ]);
7072        }
73+         $ suffixes''  !== pathinfo ($ namePATHINFO_EXTENSION ) ? array_merge (['' ], $ suffixesarray_merge ($ suffixes'' ]);
7174        foreach  ($ suffixesas  $ suffix
7275            foreach  ($ dirsas  $ dir
7376                if  (''  === $ dir
@@ -83,12 +86,11 @@ public function find(string $name, ?string $default = null, array $extraDirs = [
8386            }
8487        }
8588
86-         if  (!\function_exists ('exec ' ) || \strlen ($ namestrcspn ($ name'/ ' .\DIRECTORY_SEPARATOR )) {
89+         if  ('\\'  === \ DIRECTORY_SEPARATOR  ||  !\function_exists ('exec ' ) || \strlen ($ namestrcspn ($ name'/ ' .\DIRECTORY_SEPARATOR )) {
8790            return  $ default
8891        }
8992
90-         $ command'\\'  === \DIRECTORY_SEPARATOR  ? 'where %s 2> NUL '  : 'command -v -- %s ' ;
91-         $ execResultexec (\sprintf ($ commandescapeshellarg ($ name
93+         $ execResultexec ('command -v --  ' .escapeshellarg ($ name
9294
9395        if  (($ executablePathsubstr ($ execResult0 , strpos ($ execResultPHP_EOL ) ?: null )) && @is_executable ($ executablePath
9496            return  $ executablePath
0 commit comments