@@ -12,19 +12,10 @@ abstract class AbstractFieldGenerator
1212 // Four spaces
1313 public const INDENTATION_MARK = ' ' ;
1414
15- protected NodeTypeFieldInterface $ field ;
16- protected ParameterBag $ nodeTypesBag ;
17-
18- /**
19- * @param NodeTypeFieldInterface $field
20- * @param ParameterBag $nodeTypesBag
21- */
2215 public function __construct (
23- NodeTypeFieldInterface $ field ,
24- ParameterBag $ nodeTypesBag
16+ protected readonly NodeTypeFieldInterface $ field ,
17+ protected readonly ParameterBag $ nodeTypesBag,
2518 ) {
26- $ this ->field = $ field ;
27- $ this ->nodeTypesBag = $ nodeTypesBag ;
2819 }
2920
3021 protected function getNullableAssertion (): string
@@ -36,18 +27,18 @@ abstract protected function getType(): string;
3627
3728 private function getDeclaration (): string
3829 {
39- return static ::INDENTATION_MARK .
40- $ this ->field ->getVarName () .
41- $ this ->getNullableAssertion () . ': ' .
30+ return static ::INDENTATION_MARK .
31+ $ this ->field ->getVarName ().
32+ $ this ->getNullableAssertion (). ': ' .
4233 $ this ->getType ();
4334 }
4435
4536 public function getContents (): string
4637 {
4738 return implode (PHP_EOL , [
48- $ this ->getIntroduction (),
49- $ this ->getDeclaration ()
50- ]);
39+ $ this ->getIntroduction (),
40+ $ this ->getDeclaration (),
41+ ]);
5142 }
5243
5344 protected function getIntroductionLines (): array
@@ -60,19 +51,16 @@ protected function getIntroductionLines(): array
6051 }
6152
6253 if (!empty ($ this ->field ->getGroupName ())) {
63- $ lines [] = 'Group: ' . $ this ->field ->getGroupName ();
54+ $ lines [] = 'Group: ' . $ this ->field ->getGroupName ();
6455 }
6556
6657 return $ lines ;
6758 }
6859
69- /**
70- * @return string
71- */
7260 public function getIntroduction (): string
7361 {
7462 return implode (PHP_EOL , array_map (function (string $ line ) {
75- return static ::INDENTATION_MARK . '// ' . $ line ;
63+ return static ::INDENTATION_MARK . '// ' . $ line ;
7664 }, $ this ->getIntroductionLines ()));
7765 }
7866}
0 commit comments