File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,10 @@ use Symfony\Component\Console\Helper\ProgressBar;
72
72
73
73
$ autoloaderInWorkingDirectory = getcwd () . '/vendor/autoload.php ' ;
74
74
$ composerAutoloaderProjectPaths = [];
75
+
76
+ /** @var array<callable>|false $autoloadFunctionsBefore */
77
+ $ autoloadFunctionsBefore = spl_autoload_functions ();
78
+
75
79
if (is_file ($ autoloaderInWorkingDirectory )) {
76
80
$ composerAutoloaderProjectPaths [] = dirname ($ autoloaderInWorkingDirectory , 2 );
77
81
@@ -107,6 +111,32 @@ use Symfony\Component\Console\Helper\ProgressBar;
107
111
108
112
$ autoloadProjectAutoloaderFile ('/../../autoload.php ' );
109
113
114
+ /** @var array<callable>|false $autoloadFunctionsAfter */
115
+ $ autoloadFunctionsAfter = spl_autoload_functions ();
116
+
117
+ if ($ autoloadFunctionsBefore !== false && $ autoloadFunctionsAfter !== false ) {
118
+ $ newAutoloadFunctions = [];
119
+ foreach ($ autoloadFunctionsAfter as $ after ) {
120
+ if (
121
+ is_array ($ after )
122
+ && count ($ after ) > 0
123
+ && is_object ($ after [0 ])
124
+ && get_class ($ after [0 ]) === \Composer \Autoload \ClassLoader::class
125
+ ) {
126
+ continue ;
127
+ }
128
+ foreach ($ autoloadFunctionsBefore as $ before ) {
129
+ if ($ after === $ before ) {
130
+ continue 2 ;
131
+ }
132
+ }
133
+
134
+ $ newAutoloadFunctions [] = $ after ;
135
+ }
136
+
137
+ $ GLOBALS ['__phpstanAutoloadFunctions ' ] = $ newAutoloadFunctions ;
138
+ }
139
+
110
140
$ devOrPharLoader ->register (true );
111
141
112
142
$ version = 'Version unknown ' ;
Original file line number Diff line number Diff line change @@ -379,9 +379,8 @@ public static function begin(
379
379
/** @var array<callable>|false $autoloadFunctionsAfter */
380
380
$ autoloadFunctionsAfter = spl_autoload_functions ();
381
381
382
- $ newAutoloadFunctions = [];
383
382
if ($ autoloadFunctionsBefore !== false && $ autoloadFunctionsAfter !== false ) {
384
- $ newAutoloadFunctions = [];
383
+ $ newAutoloadFunctions = $ GLOBALS [ ' __phpstanAutoloadFunctions ' ] ?? [];
385
384
foreach ($ autoloadFunctionsAfter as $ after ) {
386
385
foreach ($ autoloadFunctionsBefore as $ before ) {
387
386
if ($ after === $ before ) {
You can’t perform that action at this time.
0 commit comments