2
2
3
3
namespace mglaman \PHPStanDrupal \Drush \Commands ;
4
4
5
+ use Drupal \Core \Serialization \Yaml ;
5
6
use Drush \Commands \DrushCommands ;
6
7
7
8
final class PhpstanDrupalDrushCommands extends DrushCommands
@@ -22,31 +23,28 @@ public function setup($options = ['file' => null]): void
22
23
'web/themes/custom ' ,
23
24
'web/profiles/custom ' ,
24
25
],
25
- // @todo can we have this override _everything_ phpstan-drupal provides? or is it a merge.
26
- 'entityMapping ' => [
26
+ 'drupal ' => [
27
+ // @todo can we have this override _everything_ phpstan-drupal provides? or is it a merge.
28
+ 'entityMapping ' => [
29
+ ],
27
30
],
31
+
28
32
];
29
33
30
34
$ entity_type_manager = \Drupal::entityTypeManager ();
31
35
foreach ($ entity_type_manager ->getDefinitions () as $ definition ) {
32
- $ parameters ['entityMapping ' ][$ definition ->id ()] = [
36
+ $ parameters ['drupal ' ][ ' entityMapping ' ][$ definition ->id ()] = [
33
37
'class ' => $ definition ->getClass (),
34
38
'storage ' => $ definition ->getStorageClass (),
35
39
];
36
40
}
37
41
38
- // @todo this is just silly, reinventing NEON encoder so it's not a Drupal dependency.
39
- $ output = <<<NEON
40
- parameters:
41
-
42
- NEON ;
43
- ;
44
- foreach ($ parameters as $ key => $ value ) {
45
- $ output .= "$ key: " ;
46
- if (is_array ($ value )) {
47
- $ output .= "\n\t" ;
48
- }
49
- }
42
+ $ config = [
43
+ 'parameters ' => $ parameters ,
44
+ ];
45
+ $ output = Yaml::encode ($ config );
46
+ // Replace 2 spaces with tabs for NEON compatibility.
47
+ $ output = str_replace (' ' , "\t" , $ output );
50
48
51
49
if ($ options ['file ' ] !== null ) {
52
50
file_put_contents ($ options ['file ' ], $ output );
0 commit comments