@@ -12,10 +12,19 @@ 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+ */
1522 public function __construct (
16- protected readonly NodeTypeFieldInterface $ field ,
17- protected readonly ParameterBag $ nodeTypesBag,
23+ NodeTypeFieldInterface $ field ,
24+ ParameterBag $ nodeTypesBag
1825 ) {
26+ $ this ->field = $ field ;
27+ $ this ->nodeTypesBag = $ nodeTypesBag ;
1928 }
2029
2130 protected function getNullableAssertion (): string
@@ -27,18 +36,18 @@ abstract protected function getType(): string;
2736
2837 private function getDeclaration (): string
2938 {
30- return static ::INDENTATION_MARK .
31- $ this ->field ->getVarName ().
32- $ this ->getNullableAssertion (). ': ' .
39+ return static ::INDENTATION_MARK .
40+ $ this ->field ->getVarName () .
41+ $ this ->getNullableAssertion () . ': ' .
3342 $ this ->getType ();
3443 }
3544
3645 public function getContents (): string
3746 {
3847 return implode (PHP_EOL , [
39- $ this ->getIntroduction (),
40- $ this ->getDeclaration (),
41- ]);
48+ $ this ->getIntroduction (),
49+ $ this ->getDeclaration ()
50+ ]);
4251 }
4352
4453 protected function getIntroductionLines (): array
@@ -51,16 +60,19 @@ protected function getIntroductionLines(): array
5160 }
5261
5362 if (!empty ($ this ->field ->getGroupName ())) {
54- $ lines [] = 'Group: ' . $ this ->field ->getGroupName ();
63+ $ lines [] = 'Group: ' . $ this ->field ->getGroupName ();
5564 }
5665
5766 return $ lines ;
5867 }
5968
69+ /**
70+ * @return string
71+ */
6072 public function getIntroduction (): string
6173 {
6274 return implode (PHP_EOL , array_map (function (string $ line ) {
63- return static ::INDENTATION_MARK . '// ' . $ line ;
75+ return static ::INDENTATION_MARK . '// ' . $ line ;
6476 }, $ this ->getIntroductionLines ()));
6577 }
6678}
0 commit comments