Skip to content

Commit

Permalink
Replaced the function empty with a more strict comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
kolodkinvalentin authored and Kolodkin Valentin committed Sep 19, 2024
1 parent da0bc3e commit 5897825
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Utils/NormalizedName.php
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion tests/Basic/BasicSchemaGenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ public function testPropertyNamesAreNormalized(): void
'space property' => ' ',
'numeric42' => 13,
'1000' => 1000,
'1000string' => '1000'
'1000string' => '1000',
'0' => 0,
]);

$this->assertSame('___', $object->getUnderscoreProperty());
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/Schema/BasicSchemaGenerationTest/NameNormalization.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
},
"1000string": {
"type": "string"
},
"0": {
"type": "integer"
}
}
}

0 comments on commit 5897825

Please sign in to comment.