Skip to content

Commit f0f2f2b

Browse files
committed
Improve builder logic
1 parent 1e302dd commit f0f2f2b

6 files changed

+17
-17
lines changed

src/Exception/Definition/Shape/ShapeFieldsNotSupportedException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ShapeFieldsNotSupportedException extends ShapeFieldsException
1010
{
1111
public static function becauseShapeFieldsNotSupported(
1212
TypeStatement $type,
13-
?\Throwable $previous = null
13+
?\Throwable $previous = null,
1414
): self {
1515
$template = 'Type "{{type}}" does not support shape fields';
1616

src/Exception/Definition/Template/Hint/TemplateArgumentHintsNotSupportedException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TemplateArgumentHintsNotSupportedException extends TemplateArgumentHintExc
1515
public static function becauseTemplateArgumentHintsNotSupported(
1616
TemplateArgumentNode $argument,
1717
TypeStatement $type,
18-
?\Throwable $previous = null
18+
?\Throwable $previous = null,
1919
): self {
2020
$template = 'Template argument #{{index}} ({{argument}}) of "{{type}}" does not support any hints, '
2121
. 'but "{{hint}}" were passed';

src/Exception/Definition/Template/MissingTemplateArgumentsException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static function becauseTemplateArgumentsRangeRequired(
1919
int $minSupportedArgumentsCount,
2020
int $maxSupportedArgumentsCount,
2121
NamedTypeNode $type,
22-
?\Throwable $previous = null
22+
?\Throwable $previous = null,
2323
): self {
2424
$template = 'Type "{{type}}" expects at least %s template argument(s), '
2525
. 'but {{passedArgumentsCount}} were passed';

src/Exception/Definition/Template/TemplateArgumentsCountException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct(
2323
NamedTypeNode $type,
2424
string $template,
2525
int $code = 0,
26-
?\Throwable $previous = null
26+
?\Throwable $previous = null,
2727
) {
2828
parent::__construct(
2929
type: $type,

src/Exception/Definition/Template/TemplateArgumentsNotSupportedException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TemplateArgumentsNotSupportedException extends TemplateArgumentsCountExcep
1313
{
1414
public static function becauseTemplateArgumentsNotSupported(
1515
NamedTypeNode $type,
16-
?\Throwable $previous = null
16+
?\Throwable $previous = null,
1717
): self {
1818
$template = 'Type "{{type}}" does not support template arguments, '
1919
. 'but {{passedArgumentsCount}} were passed';

src/Platform/Builder/Builder.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ abstract class Builder implements TypeBuilderInterface
2626
*
2727
* @throws TemplateArgumentsNotSupportedException
2828
*/
29-
protected function expectNoTemplateArguments(NamedTypeNode $stmt): void
29+
protected static function expectNoTemplateArguments(NamedTypeNode $stmt): void
3030
{
3131
if ($stmt->arguments === null) {
3232
return;
@@ -42,7 +42,7 @@ protected function expectNoTemplateArguments(NamedTypeNode $stmt): void
4242
*
4343
* @throws ShapeFieldsNotSupportedException
4444
*/
45-
protected function expectNoShapeFields(NamedTypeNode $stmt): void
45+
protected static function expectNoShapeFields(NamedTypeNode $stmt): void
4646
{
4747
if ($stmt->fields === null) {
4848
return;
@@ -59,10 +59,10 @@ protected function expectNoShapeFields(NamedTypeNode $stmt): void
5959
* @throws MissingTemplateArgumentsException
6060
* @throws TooManyTemplateArgumentsException
6161
*/
62-
protected function expectTemplateArgumentsCount(NamedTypeNode $stmt, int $count): void
62+
protected static function expectTemplateArgumentsCount(NamedTypeNode $stmt, int $count): void
6363
{
64-
$this->expectTemplateArgumentsLessOrEqualThan($stmt, $count, $count);
65-
$this->expectTemplateArgumentsGreaterOrEqualThan($stmt, $count, $count);
64+
static::expectTemplateArgumentsLessOrEqualThan($stmt, $count, $count);
65+
static::expectTemplateArgumentsGreaterOrEqualThan($stmt, $count, $count);
6666
}
6767

6868
/**
@@ -73,9 +73,9 @@ protected function expectTemplateArgumentsCount(NamedTypeNode $stmt, int $count)
7373
*
7474
* @throws TooManyTemplateArgumentsException
7575
*/
76-
protected function expectTemplateArgumentsLessThan(NamedTypeNode $stmt, int $max, int $min = 0): void
76+
protected static function expectTemplateArgumentsLessThan(NamedTypeNode $stmt, int $max, int $min = 0): void
7777
{
78-
$this->expectTemplateArgumentsLessOrEqualThan($stmt, $max + 1, $min);
78+
static::expectTemplateArgumentsLessOrEqualThan($stmt, $max + 1, $min);
7979
}
8080

8181
/**
@@ -86,7 +86,7 @@ protected function expectTemplateArgumentsLessThan(NamedTypeNode $stmt, int $max
8686
*
8787
* @throws TooManyTemplateArgumentsException
8888
*/
89-
protected function expectTemplateArgumentsLessOrEqualThan(NamedTypeNode $stmt, int $max, int $min = 0): void
89+
protected static function expectTemplateArgumentsLessOrEqualThan(NamedTypeNode $stmt, int $max, int $min = 0): void
9090
{
9191
if ($stmt->arguments === null || $stmt->arguments->count() <= $max) {
9292
return;
@@ -107,9 +107,9 @@ protected function expectTemplateArgumentsLessOrEqualThan(NamedTypeNode $stmt, i
107107
*
108108
* @throws MissingTemplateArgumentsException
109109
*/
110-
protected function expectTemplateArgumentsGreaterThan(NamedTypeNode $stmt, int $min, ?int $max = null): void
110+
protected static function expectTemplateArgumentsGreaterThan(NamedTypeNode $stmt, int $min, ?int $max = null): void
111111
{
112-
$this->expectTemplateArgumentsGreaterOrEqualThan($stmt, $min + 1, $max);
112+
static::expectTemplateArgumentsGreaterOrEqualThan($stmt, $min + 1, $max);
113113
}
114114

115115
/**
@@ -120,7 +120,7 @@ protected function expectTemplateArgumentsGreaterThan(NamedTypeNode $stmt, int $
120120
*
121121
* @throws MissingTemplateArgumentsException
122122
*/
123-
protected function expectTemplateArgumentsGreaterOrEqualThan(NamedTypeNode $stmt, int $min, ?int $max = null): void
123+
protected static function expectTemplateArgumentsGreaterOrEqualThan(NamedTypeNode $stmt, int $min, ?int $max = null): void
124124
{
125125
$actualArgumentsCount = $stmt->arguments?->count() ?? 0;
126126

@@ -140,7 +140,7 @@ protected function expectTemplateArgumentsGreaterOrEqualThan(NamedTypeNode $stmt
140140
*
141141
* @throws TemplateArgumentHintsNotSupportedException
142142
*/
143-
protected function expectNoTemplateArgumentHint(TypeStatement $stmt, TemplateArgumentNode $argument): void
143+
protected static function expectNoTemplateArgumentHint(TypeStatement $stmt, TemplateArgumentNode $argument): void
144144
{
145145
if ($argument->hint === null) {
146146
return;

0 commit comments

Comments
 (0)