Skip to content

Commit

Permalink
Make nullable parameters explicit in generated entities (#11625)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus authored Oct 8, 2024
1 parent d18126a commit b13564c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Tools/EntityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,9 @@ private function generateEmbeddableConstructor(ClassMetadataInfo $metadata): str

if ($fieldMapping['type'] === 'datetime') {
$param = $this->getType($fieldMapping['type']) . ' ' . $param;
if (! empty($fieldMapping['nullable'])) {
$param = '?' . $param;
}
}

if (! empty($fieldMapping['nullable'])) {
Expand Down Expand Up @@ -1385,6 +1388,9 @@ protected function generateEntityStubMethod(ClassMetadataInfo $metadata, $type,
if ($typeHint && ! isset($types[$typeHint])) {
$variableType = '\\' . ltrim($variableType, '\\');
$methodTypeHint = '\\' . $typeHint . ' ';
if ($defaultValue === 'null') {
$methodTypeHint = '?' . $methodTypeHint;
}
}

$replacements = [
Expand Down

0 comments on commit b13564c

Please sign in to comment.