Skip to content

Commit f1c7653

Browse files
committed
improved nullable ids
1 parent 92412f5 commit f1c7653

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/DataModelGenerator/DataModelGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ protected function generateBaseEntities(): void
291291
/** @var EntityClassProperty[] $properties */
292292
$properties = [];
293293

294-
$properties[] = new EntityClassProperty('id', 'int|null', null, [
294+
$properties[] = new EntityClassProperty('id', 'int', null, [
295295
'@ORM\Id()',
296296
'@ORM\GeneratedValue()',
297297
'@ORM\Column(type="integer")',

src/Make/MakeFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ protected function getPropertyAccessors(): array
254254
$propertyName = ucfirst($propertyNameOriginal);
255255
$propertyType = static::parseReturnType($propertyTypeOriginal);
256256

257-
$getterReturnType = $propertyType !== null ? ": {$propertyType}" : '';
257+
$nullableIds = $propertyNameOriginal === 'id' ? '?' : '';
258+
$getterReturnType = $propertyType !== null ? ": {$nullableIds}{$propertyType}" : '';
258259
$setterParameterType = $propertyType !== null ? "{$propertyType} " : '';
259260

260261
// GETTER

0 commit comments

Comments
 (0)