diff --git a/src/blocks/ContentManager.php b/src/blocks/ContentManager.php index d44459a..b6516fd 100644 --- a/src/blocks/ContentManager.php +++ b/src/blocks/ContentManager.php @@ -144,9 +144,14 @@ private function setArrayProperty($key, array $value) : void */ protected function createProperty(string $prop, string $modifier, $value = PhpInterface::PHP_TYPES_NULL, bool $isString = false) : void { - $this->sourceCode .= PhpInterface::TAB_PSR4 . $modifier . PhpInterface::SPACE . PhpInterface::DOLLAR_SIGN . - $prop . PhpInterface::SPACE . PhpInterface::EQUALS . PhpInterface::SPACE - . (($isString === false) ? $value : PhpInterface::QUOTES . $value . PhpInterface::QUOTES) . PhpInterface::SEMICOLON . PHP_EOL; + if ($value === PhpInterface::PHP_TYPES_NULL) { // drop null assignments as they are already nullable by default + $this->sourceCode .= PhpInterface::TAB_PSR4 . $modifier . PhpInterface::SPACE . PhpInterface::DOLLAR_SIGN . + $prop . PhpInterface::SEMICOLON . PHP_EOL; + } else { + $this->sourceCode .= PhpInterface::TAB_PSR4 . $modifier . PhpInterface::SPACE . PhpInterface::DOLLAR_SIGN . + $prop . PhpInterface::SPACE . PhpInterface::EQUALS . PhpInterface::SPACE + . (($isString === false) ? $value : PhpInterface::QUOTES . $value . PhpInterface::QUOTES) . PhpInterface::SEMICOLON . PHP_EOL; + } } /** diff --git a/tests/images/Console_generator_output.png b/tests/images/Console_generator_output.png index 5559e7c..c1abb65 100644 Binary files a/tests/images/Console_generator_output.png and b/tests/images/Console_generator_output.png differ diff --git a/tests/images/Dirs_and_files_module_structure.png b/tests/images/Dirs_and_files_module_structure.png index 40db350..a015188 100644 Binary files a/tests/images/Dirs_and_files_module_structure.png and b/tests/images/Dirs_and_files_module_structure.png differ