File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,13 @@ use Symfony\Component\Console\Helper\ProgressBar;
2020
2121 $ devOrPharLoader = require_once __DIR__ . '/../vendor/autoload.php ' ;
2222 require_once __DIR__ . '/../preload.php ' ;
23+ $ composerJsonPath = ComposerHelper::getComposerJsonPath (getcwd ());
2324 $ composer = ComposerHelper::getComposerConfig (getcwd ());
2425
2526 if ($ composer !== null ) {
2627 $ vendorDirectory = ComposerHelper::getVendorDirFromComposerConfig (getcwd (), $ composer );
2728 } else {
28- $ vendorDirectory = getcwd () . '/ ' . ' vendor ' ;
29+ $ vendorDirectory = getcwd () . '/vendor ' ;
2930 }
3031 $ devOrPharLoader ->unregister ();
3132
@@ -43,7 +44,9 @@ use Symfony\Component\Console\Helper\ProgressBar;
4344 $ autoloadFunctionsBefore = spl_autoload_functions ();
4445
4546 if (@is_file ($ autoloaderInWorkingDirectory )) {
46- $ composerAutoloaderProjectPaths [] = dirname ($ autoloaderInWorkingDirectory , 2 );
47+ if ($ composerJsonPath !== null ) {
48+ $ composerAutoloaderProjectPaths [] = dirname ($ composerJsonPath );
49+ }
4750
4851 require_once $ autoloaderInWorkingDirectory ;
4952 }
Original file line number Diff line number Diff line change @@ -25,8 +25,7 @@ final class ComposerHelper
2525 public static function getComposerConfig (string $ root ): ?array
2626 {
2727 $ composerJsonPath = self ::getComposerJsonPath ($ root );
28-
29- if (!is_file ($ composerJsonPath )) {
28+ if ($ composerJsonPath === null ) {
3029 return null ;
3130 }
3231
@@ -39,13 +38,18 @@ public static function getComposerConfig(string $root): ?array
3938 }
4039 }
4140
42- private static function getComposerJsonPath (string $ root ): string
41+ public static function getComposerJsonPath (string $ root ): ? string
4342 {
4443 $ envComposer = getenv ('COMPOSER ' );
4544 $ fileName = is_string ($ envComposer ) ? $ envComposer : 'composer.json ' ;
4645 $ fileName = basename (trim ($ fileName ));
4746
48- return $ root . '/ ' . $ fileName ;
47+ $ path = $ root . '/ ' . $ fileName ;
48+ if (!is_file ($ path )) {
49+ return null ;
50+ }
51+
52+ return $ path ;
4953 }
5054
5155 /**
You can’t perform that action at this time.
0 commit comments