Skip to content

Commit

Permalink
#117. Remove null assignment from props + 2 images
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkushman committed Nov 16, 2018
1 parent 5e9b2e9 commit c4fb73b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/blocks/ContentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/**
Expand Down
Binary file modified tests/images/Console_generator_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/images/Dirs_and_files_module_structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c4fb73b

Please sign in to comment.