Skip to content

Commit

Permalink
initialize fields to null to make them type safe
Browse files Browse the repository at this point in the history
  • Loading branch information
lmfmaier committed May 8, 2024
1 parent 518853f commit 005664a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Generator/Snippet.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function getAttributes($type, $visibility, \Phalcon\Db\ColumnInterface $f
$field->getName(),
$type,
$field->getSize() ? ', length=' . $field->getSize() : '',
$field->isNotNull() ? 'false' : 'true', $visibility, $phpTypedProp, $fieldName, ($field->getName()==='id' ? ' = null' : '')).PHP_EOL;
$field->isNotNull() ? 'false' : 'true', $visibility, $phpTypedProp, $fieldName, ' = null').PHP_EOL;
} else {
$templateAttributes = <<<EOD
/**
Expand All @@ -189,7 +189,7 @@ public function getAttributes($type, $visibility, \Phalcon\Db\ColumnInterface $f
%s %s \$%s%s;
EOD;

return PHP_EOL.sprintf($templateAttributes, $phpTypedProp, $visibility, $phpTypedProp, $fieldName, ($field->getName()==='id' ? ' = null' : '')).PHP_EOL;
return PHP_EOL.sprintf($templateAttributes, $phpTypedProp, $visibility, $phpTypedProp, $fieldName, ' = null').PHP_EOL;
}
}

Expand Down

0 comments on commit 005664a

Please sign in to comment.