22
33namespace mglaman \PHPStanDrupal \Drush \Commands ;
44
5+ use Drupal \Core \Serialization \Yaml ;
56use Drush \Commands \DrushCommands ;
67
78final class PhpstanDrupalDrushCommands extends DrushCommands
@@ -22,31 +23,28 @@ public function setup($options = ['file' => null]): void
2223 'web/themes/custom ' ,
2324 'web/profiles/custom ' ,
2425 ],
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+ ],
2730 ],
31+
2832 ];
2933
3034 $ entity_type_manager = \Drupal::entityTypeManager ();
3135 foreach ($ entity_type_manager ->getDefinitions () as $ definition ) {
32- $ parameters ['entityMapping ' ][$ definition ->id ()] = [
36+ $ parameters ['drupal ' ][ ' entityMapping ' ][$ definition ->id ()] = [
3337 'class ' => $ definition ->getClass (),
3438 'storage ' => $ definition ->getStorageClass (),
3539 ];
3640 }
3741
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 );
5048
5149 if ($ options ['file ' ] !== null ) {
5250 file_put_contents ($ options ['file ' ], $ output );
0 commit comments