@@ -20,7 +20,7 @@ class DrupalExtension extends CompilerExtension
20
20
];
21
21
22
22
/**
23
- * @var string
23
+ * @var ? string
24
24
*/
25
25
private $ autoloaderPath ;
26
26
@@ -62,18 +62,21 @@ public function loadConfiguration(): void
62
62
throw new \InvalidArgumentException ('Cannot determine the realpath of the autoloader. ' );
63
63
}
64
64
$ project_root = dirname ($ realpath , 2 );
65
+ $ drupalRoot = null ;
65
66
if (is_dir ($ project_root . '/core ' )) {
66
- $ this -> drupalRoot = $ project_root ;
67
+ $ drupalRoot = $ project_root ;
67
68
}
68
69
foreach (['web ' , 'docroot ' ] as $ possible_docroot ) {
69
70
if (is_dir ("$ project_root/ $ possible_docroot/core " )) {
70
- $ this -> drupalRoot = "$ project_root/ $ possible_docroot " ;
71
+ $ drupalRoot = "$ project_root/ $ possible_docroot " ;
71
72
}
72
73
}
73
- if ($ this -> drupalRoot === null ) {
74
+ if ($ drupalRoot === null ) {
74
75
throw new \InvalidArgumentException ('Unable to determine the Drupal root ' );
75
76
}
76
77
78
+ $ this ->drupalRoot = $ drupalRoot ;
79
+
77
80
$ builder = $ this ->getContainerBuilder ();
78
81
$ builder ->parameters ['drupalRoot ' ] = $ this ->drupalRoot ;
79
82
@@ -99,7 +102,7 @@ public function loadConfiguration(): void
99
102
$ extensionDiscovery = new ExtensionDiscovery ($ this ->drupalRoot );
100
103
$ extensionDiscovery ->setProfileDirectories ([]);
101
104
$ profiles = $ extensionDiscovery ->scan ('profile ' );
102
- $ profile_directories = array_map (function ($ profile ) {
105
+ $ profile_directories = array_map (function (\ PHPStan \ Drupal \ Extension $ profile ) : string {
103
106
return $ profile ->getPath ();
104
107
}, $ profiles );
105
108
$ extensionDiscovery ->setProfileDirectories ($ profile_directories );
@@ -139,7 +142,7 @@ public function loadConfiguration(): void
139
142
// Prevent \Nette\DI\ContainerBuilder::completeStatement from array_walk_recursive into the arguments
140
143
// and thinking these are real services for PHPStan's container.
141
144
if (isset ($ serviceDefinition ['arguments ' ]) && is_array ($ serviceDefinition ['arguments ' ])) {
142
- array_walk ($ serviceDefinition ['arguments ' ], function (&$ argument ) {
145
+ array_walk ($ serviceDefinition ['arguments ' ], function (string &$ argument ) : void {
143
146
$ argument = str_replace ('@ ' , '' , $ argument );
144
147
});
145
148
}
0 commit comments