File tree Expand file tree Collapse file tree 2 files changed +59
-1
lines changed Expand file tree Collapse file tree 2 files changed +59
-1
lines changed Original file line number Diff line number Diff line change 2020 "behat/mink" : " ^1.8" ,
2121 "composer/installers" : " ^1.9" ,
2222 "drupal/core-recommended" : " ^8.8@alpha || ^9.0" ,
23- "drush/drush" : " ^9.6 || ^10.0" ,
23+ "drush/drush" : " ^9.6 || ^10.0 || ^11.0 " ,
2424 "phpstan/extension-installer" : " ^1.1" ,
2525 "phpstan/phpstan-deprecation-rules" : " ^1.0" ,
2626 "phpstan/phpstan-strict-rules" : " ^1.0" ,
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace mglaman \PHPStanDrupal \Drush \Commands ;
4+
5+ use Drush \Commands \DrushCommands ;
6+
7+ final class PhpstanDrupalDrushCommands extends DrushCommands
8+ {
9+
10+ /**
11+ * @command phpstan-drupal:setup
12+ * @option file
13+ * @bootstrap full
14+ */
15+ public function setup ($ options = ['file ' => null ]): void
16+ {
17+ $ parameters = [
18+ 'level ' => 2 ,
19+ 'paths ' => [
20+ // @todo use drupal-finder for docroot
21+ 'web/modules/custom ' ,
22+ 'web/themes/custom ' ,
23+ 'web/profiles/custom ' ,
24+ ],
25+ // @todo can we have this override _everything_ phpstan-drupal provides? or is it a merge.
26+ 'entityMapping ' => [
27+ ],
28+ ];
29+
30+ $ entity_type_manager = \Drupal::entityTypeManager ();
31+ foreach ($ entity_type_manager ->getDefinitions () as $ definition ) {
32+ $ parameters ['entityMapping ' ][$ definition ->id ()] = [
33+ 'class ' => $ definition ->getClass (),
34+ 'storage ' => $ definition ->getStorageClass (),
35+ ];
36+ }
37+
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+ }
50+
51+ if ($ options ['file ' ] !== null ) {
52+ file_put_contents ($ options ['file ' ], $ output );
53+ } else {
54+ $ this ->io ()->writeln ($ output );
55+ }
56+ }
57+
58+ }
You can’t perform that action at this time.
0 commit comments