File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace PHPStan \Drupal ;
4
4
5
+ use Drupal \Core \DependencyInjection \ContainerNotInitializedException ;
5
6
use PHPStan \Analyser \Analyser ;
6
7
use PHPStan \DependencyInjection \ContainerFactory ;
7
8
use PHPStan \File \FileHelper ;
@@ -53,7 +54,12 @@ private function runAnalyze(string $path) {
53
54
(static function (string $ file ): void {
54
55
require_once $ file ;
55
56
})($ bootstrapFile );
56
- } catch (\Throwable $ e ) {
57
+ } catch (ContainerNotInitializedException $ e ) {
58
+ $ trace = $ e ->getTrace ();
59
+ $ offending_file = $ trace [1 ];
60
+ $ this ->fail (sprintf ('%s called the Drupal container from unscoped code. ' , $ offending_file ['file ' ]));
61
+ }
62
+ catch (\Throwable $ e ) {
57
63
$ this ->fail ('Could not load the bootstrap file ' );
58
64
}
59
65
}
You can’t perform that action at this time.
0 commit comments