Skip to content

Commit 488f687

Browse files
Replaced the function empty with a more strict comparison (#83)
1 parent 1bb1374 commit 488f687

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/Utils/NormalizedName.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static function (string $element): string {
2828

2929
$attributeName = join('', $elements);
3030

31-
if (empty($attributeName)) {
31+
if ($attributeName === '') {
3232
throw new SchemaException(
3333
sprintf(
3434
"Name '%s' results in an empty name in file %s",

tests/Basic/BasicSchemaGenerationTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ public function testPropertyNamesAreNormalized(): void
275275
'space property' => ' ',
276276
'numeric42' => 13,
277277
'1000' => 1000,
278-
'1000string' => '1000'
278+
'1000string' => '1000',
279+
'0' => 0,
279280
]);
280281

281282
$this->assertSame('___', $object->getUnderscoreProperty());
@@ -284,6 +285,7 @@ public function testPropertyNamesAreNormalized(): void
284285
$this->assertSame(13, $object->getNumeric42());
285286
$this->assertSame(1000, $object->get1000());
286287
$this->assertSame('1000', $object->get1000string());
288+
$this->assertSame(0, $object->get0());
287289
}
288290

289291
public function testEmptyNormalizedPropertyNameThrowsAnException(): void

tests/Schema/BasicSchemaGenerationTest/NameNormalization.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
},
2222
"1000string": {
2323
"type": "string"
24+
},
25+
"0": {
26+
"type": "integer"
2427
}
2528
}
2629
}

0 commit comments

Comments
 (0)