From a8f975aaffacaa85e9c8df8d3564ea5f5d8b10de Mon Sep 17 00:00:00 2001 From: DrWarpMan <36279265+DrWarpMan@users.noreply.github.com> Date: Mon, 22 Apr 2024 23:41:20 +0200 Subject: [PATCH 1/2] Fix nullable detection In Symfony production environment, since Doctrine 3.x, values for 'nullable' property can be either null, false or true. In Doctrine 2.x, it was only false or true. When Doctrine returned 'null' for the nullable property, the required option for the field was set to false. While in fact, Doctrine considers 'nullable => null' as 'nullable => false', thus should make the field required. --- src/Field/Configurator/CommonPreConfigurator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Field/Configurator/CommonPreConfigurator.php b/src/Field/Configurator/CommonPreConfigurator.php index e242c2a932..b7ba3b87fc 100644 --- a/src/Field/Configurator/CommonPreConfigurator.php +++ b/src/Field/Configurator/CommonPreConfigurator.php @@ -227,7 +227,7 @@ private function buildRequiredOption(FieldDto $field, EntityDto $entityDto): boo return false; } - return false === $doctrinePropertyMetadata->get('nullable'); + return !$doctrinePropertyMetadata->get('nullable'); } private function humanizeString(string $string): string From 8cfb233ab784b6cca42870f8ba815409ccd5146a Mon Sep 17 00:00:00 2001 From: DrWarpMan <36279265+DrWarpMan@users.noreply.github.com> Date: Tue, 23 Apr 2024 00:08:13 +0200 Subject: [PATCH 2/2] phpstan --- src/Field/Configurator/CommonPreConfigurator.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Field/Configurator/CommonPreConfigurator.php b/src/Field/Configurator/CommonPreConfigurator.php index b7ba3b87fc..ca3c1304d4 100644 --- a/src/Field/Configurator/CommonPreConfigurator.php +++ b/src/Field/Configurator/CommonPreConfigurator.php @@ -227,7 +227,9 @@ private function buildRequiredOption(FieldDto $field, EntityDto $entityDto): boo return false; } - return !$doctrinePropertyMetadata->get('nullable'); + $nullable = $doctrinePropertyMetadata->get('nullable'); + + return false === $nullable || null === $nullable; } private function humanizeString(string $string): string