Skip to content

Commit 7d50d41

Browse files
committed
feat: Add method to get property keys
1 parent 95d64fa commit 7d50d41

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/Types/Concerns/HasProperties.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ public function propertyNames(Schema $schema): static
112112
return $this;
113113
}
114114

115+
/**
116+
* @return array<int, string>
117+
*/
118+
public function getPropertyKeys(): array
119+
{
120+
return array_keys($this->properties);
121+
}
122+
115123
/**
116124
* Add properties to schema array
117125
*

tests/Unit/Support/DocParserTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,13 @@
9292
expect($variable->types)->toBe(['string', 'int']);
9393
expect($variable->description)->toBe('The nickname of the user');
9494
});
95+
96+
it('can parse a multiline description', function (): void {
97+
$docblock = '/** This is a test docblock
98+
* with multiple lines
99+
* and a new line
100+
*/';
101+
$parser = new DocParser($docblock);
102+
103+
expect($parser->description())->toBe("This is a test docblock\nwith multiple lines\nand a new line");
104+
});

tests/Unit/Targets/ObjectSchemaTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
expect($schemaArray)->toHaveKey('properties.age.minimum', 18);
4242
expect($schemaArray)->toHaveKey('properties.age.maximum', 150);
4343
expect($schemaArray)->toHaveKey('required', ['name', 'email']);
44+
expect($schema->getPropertyKeys())->toBe(['name', 'email', 'age']);
4445

4546
// Validation tests
4647
expect(fn() => $schema->validate([

0 commit comments

Comments
 (0)