Skip to content

Commit b0e5976

Browse files
committed
Improve shape fields
1 parent 17cadd3 commit b0e5976

2 files changed

Lines changed: 27 additions & 18 deletions

File tree

src/Type/Builder/Assert.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace TypeLang\Mapper\Type\Builder;
66

7+
use TypeLang\Mapper\Exception\Definition\Shape\ShapeFieldsNotSupportedException;
78
use TypeLang\Mapper\Exception\Definition\Template\Hint\TemplateArgumentHintsNotSupportedException;
89
use TypeLang\Mapper\Exception\Definition\Template\MissingTemplateArgumentsException;
910
use TypeLang\Mapper\Exception\Definition\Template\MissingTemplateArgumentsInRangeException;
@@ -15,6 +16,18 @@
1516

1617
final class Assert
1718
{
19+
/**
20+
* @throws ShapeFieldsNotSupportedException
21+
*/
22+
public static function expectNoShapeFields(NamedTypeNode $stmt): void
23+
{
24+
if ($stmt->fields === null) {
25+
return;
26+
}
27+
28+
throw ShapeFieldsNotSupportedException::becauseTooManyShapeFields($stmt);
29+
}
30+
1831
/**
1932
* @throws TemplateArgumentsNotSupportedException
2033
*/

src/Type/Builder/Builder.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,6 @@ protected function expectNoTemplateArguments(TypeStatement $stmt): void
3737
Assert::expectNoTemplateArguments($stmt);
3838
}
3939

40-
/**
41-
* @api
42-
*
43-
* @throws ShapeFieldsNotSupportedException
44-
*/
45-
protected function expectNoShapeFields(TypeStatement $stmt): void
46-
{
47-
if (!$stmt instanceof NamedTypeNode) {
48-
return;
49-
}
50-
51-
if ($stmt->fields === null) {
52-
return;
53-
}
54-
55-
throw ShapeFieldsNotSupportedException::becauseTooManyShapeFields($stmt);
56-
}
57-
5840
/**
5941
* @api
6042
*
@@ -173,4 +155,18 @@ protected function expectNoAnyTemplateArgumentHint(TypeStatement $stmt): void
173155

174156
Assert::expectNoAnyTemplateArgumentsHints($stmt);
175157
}
158+
159+
/**
160+
* @api
161+
*
162+
* @throws ShapeFieldsNotSupportedException
163+
*/
164+
protected function expectNoShapeFields(TypeStatement $stmt): void
165+
{
166+
if (!$stmt instanceof NamedTypeNode) {
167+
return;
168+
}
169+
170+
Assert::expectNoShapeFields($stmt);
171+
}
176172
}

0 commit comments

Comments
 (0)