From 58978254457cb38f51eb24a2355995a9bcaf9beb Mon Sep 17 00:00:00 2001 From: Kolodkin Valentin Date: Thu, 19 Sep 2024 15:29:59 +0300 Subject: [PATCH] Replaced the function empty with a more strict comparison --- src/Utils/NormalizedName.php | 2 +- tests/Basic/BasicSchemaGenerationTest.php | 4 +++- tests/Schema/BasicSchemaGenerationTest/NameNormalization.json | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Utils/NormalizedName.php b/src/Utils/NormalizedName.php index d13a00e9..c4325b4e 100644 --- a/src/Utils/NormalizedName.php +++ b/src/Utils/NormalizedName.php @@ -28,7 +28,7 @@ static function (string $element): string { $attributeName = join('', $elements); - if (empty($attributeName)) { + if ($attributeName === '') { throw new SchemaException( sprintf( "Name '%s' results in an empty name in file %s", diff --git a/tests/Basic/BasicSchemaGenerationTest.php b/tests/Basic/BasicSchemaGenerationTest.php index dee303c2..21ff215e 100644 --- a/tests/Basic/BasicSchemaGenerationTest.php +++ b/tests/Basic/BasicSchemaGenerationTest.php @@ -275,7 +275,8 @@ public function testPropertyNamesAreNormalized(): void 'space property' => ' ', 'numeric42' => 13, '1000' => 1000, - '1000string' => '1000' + '1000string' => '1000', + '0' => 0, ]); $this->assertSame('___', $object->getUnderscoreProperty()); @@ -284,6 +285,7 @@ public function testPropertyNamesAreNormalized(): void $this->assertSame(13, $object->getNumeric42()); $this->assertSame(1000, $object->get1000()); $this->assertSame('1000', $object->get1000string()); + $this->assertSame(0, $object->get0()); } public function testEmptyNormalizedPropertyNameThrowsAnException(): void diff --git a/tests/Schema/BasicSchemaGenerationTest/NameNormalization.json b/tests/Schema/BasicSchemaGenerationTest/NameNormalization.json index 7b9a3f19..14f8f9f2 100644 --- a/tests/Schema/BasicSchemaGenerationTest/NameNormalization.json +++ b/tests/Schema/BasicSchemaGenerationTest/NameNormalization.json @@ -21,6 +21,9 @@ }, "1000string": { "type": "string" + }, + "0": { + "type": "integer" } } } \ No newline at end of file