Skip to content

Commit 793a2a9

Browse files
committed
Compatibility with Graphpinator 2.0
1 parent 98b61de commit 793a2a9

17 files changed

+417
-373
lines changed

infection.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"perMutator": "build/per-mutator.md"
1212
},
1313
"tmpDir": "/tmp/infection",
14-
"minMsi": 77,
14+
"minMsi": 74,
1515
"minCoveredMsi": 77,
1616
"mutators": {
1717
"@default": true,

src/FloatConstraintDirective.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace Graphpinator\ConstraintDirectives;
66

7+
use Graphpinator\ConstraintDirectives\Exception\MaxConstraintNotSatisfied;
8+
use Graphpinator\ConstraintDirectives\Exception\MinConstraintNotSatisfied;
9+
use Graphpinator\ConstraintDirectives\Exception\OneOfConstraintNotSatisfied;
710
use Graphpinator\Normalizer\Variable\Variable;
811
use Graphpinator\Typesystem\Argument\Argument;
912
use Graphpinator\Typesystem\Argument\ArgumentSet;
@@ -87,15 +90,15 @@ protected function specificValidateValue(
8790
$oneOf = $arguments->offsetGet('oneOf')->getValue()->getRawValue();
8891

8992
if (\is_float($min) && $rawValue < $min) {
90-
throw new Exception\MinConstraintNotSatisfied();
93+
throw new MinConstraintNotSatisfied();
9194
}
9295

9396
if (\is_float($max) && $rawValue > $max) {
94-
throw new Exception\MaxConstraintNotSatisfied();
97+
throw new MaxConstraintNotSatisfied();
9598
}
9699

97100
if (\is_array($oneOf) && !\in_array($rawValue, $oneOf, true)) {
98-
throw new Exception\OneOfConstraintNotSatisfied();
101+
throw new OneOfConstraintNotSatisfied();
99102
}
100103
}
101104

src/IntConstraintDirective.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace Graphpinator\ConstraintDirectives;
66

7+
use Graphpinator\ConstraintDirectives\Exception\MaxConstraintNotSatisfied;
8+
use Graphpinator\ConstraintDirectives\Exception\MinConstraintNotSatisfied;
9+
use Graphpinator\ConstraintDirectives\Exception\OneOfConstraintNotSatisfied;
710
use Graphpinator\Normalizer\Variable\Variable;
811
use Graphpinator\Typesystem\Argument\Argument;
912
use Graphpinator\Typesystem\Argument\ArgumentSet;
@@ -86,15 +89,15 @@ protected function specificValidateValue(
8689
$oneOf = $arguments->offsetGet('oneOf')->getValue()->getRawValue();
8790

8891
if (\is_int($min) && $rawValue < $min) {
89-
throw new Exception\MinConstraintNotSatisfied();
92+
throw new MinConstraintNotSatisfied();
9093
}
9194

9295
if (\is_int($max) && $rawValue > $max) {
93-
throw new Exception\MaxConstraintNotSatisfied();
96+
throw new MaxConstraintNotSatisfied();
9497
}
9598

9699
if (\is_array($oneOf) && !\in_array($rawValue, $oneOf, true)) {
97-
throw new Exception\OneOfConstraintNotSatisfied();
100+
throw new OneOfConstraintNotSatisfied();
98101
}
99102
}
100103

src/ListConstraintDirective.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
namespace Graphpinator\ConstraintDirectives;
66

7+
use Graphpinator\ConstraintDirectives\Exception\MaxItemsConstraintNotSatisfied;
8+
use Graphpinator\ConstraintDirectives\Exception\MinItemsConstraintNotSatisfied;
9+
use Graphpinator\ConstraintDirectives\Exception\UniqueConstraintNotSatisfied;
10+
use Graphpinator\ConstraintDirectives\Exception\UniqueConstraintOnlyScalar;
711
use Graphpinator\Normalizer\Variable\Variable;
812
use Graphpinator\Typesystem\Argument\Argument;
913
use Graphpinator\Typesystem\Argument\ArgumentSet;
@@ -105,7 +109,7 @@ private static function recursiveValidateType(
105109
$usedType = $usedType->getInnerType()->accept(new GetShapingTypeVisitor());
106110

107111
if ($options->unique && !$usedType instanceof LeafType) {
108-
throw new Exception\UniqueConstraintOnlyScalar();
112+
throw new UniqueConstraintOnlyScalar();
109113
}
110114

111115
if ($options->innerList instanceof \stdClass) {
@@ -118,11 +122,11 @@ private static function recursiveValidateType(
118122
private static function recursiveValidate(array $rawValue, \stdClass $options) : void
119123
{
120124
if (\is_int($options->minItems) && \count($rawValue) < $options->minItems) {
121-
throw new Exception\MinItemsConstraintNotSatisfied();
125+
throw new MinItemsConstraintNotSatisfied();
122126
}
123127

124128
if (\is_int($options->maxItems) && \count($rawValue) > $options->maxItems) {
125-
throw new Exception\MaxItemsConstraintNotSatisfied();
129+
throw new MaxItemsConstraintNotSatisfied();
126130
}
127131

128132
if ($options->unique) {
@@ -135,7 +139,7 @@ private static function recursiveValidate(array $rawValue, \stdClass $options) :
135139
continue;
136140
}
137141

138-
throw new Exception\UniqueConstraintNotSatisfied();
142+
throw new UniqueConstraintNotSatisfied();
139143
}
140144
}
141145

src/ObjectConstraintDirective.php

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

55
namespace Graphpinator\ConstraintDirectives;
66

7+
use Graphpinator\ConstraintDirectives\Exception\AtLeastConstraintNotSatisfied;
8+
use Graphpinator\ConstraintDirectives\Exception\AtMostConstraintNotSatisfied;
9+
use Graphpinator\ConstraintDirectives\Exception\ExactlyConstraintNotSatisfied;
710
use Graphpinator\Typesystem\Argument\Argument;
811
use Graphpinator\Typesystem\Argument\ArgumentSet;
912
use Graphpinator\Typesystem\Container;
@@ -152,31 +155,31 @@ private static function resolveAtLeast(TypeValue|InputValue $value, array $atLea
152155
[$currentCount, $notRequested] = self::countFieldsType($value, $atLeast);
153156

154157
if ($currentCount + $notRequested < $count) {
155-
throw new Exception\AtLeastConstraintNotSatisfied();
158+
throw new AtLeastConstraintNotSatisfied();
156159
}
157160

158161
return;
159162
}
160163

161164
if (self::countFieldsInput($value, $atLeast) < $count) {
162-
throw new Exception\AtLeastConstraintNotSatisfied();
165+
throw new AtLeastConstraintNotSatisfied();
163166
}
164167
}
165168

166169
private static function resolveAtMost(TypeValue|InputValue $value, array $atMost, int $count = 1) : void
167170
{
168171
if ($value instanceof TypeValue) {
169-
[$currentCount, $notRequested] = self::countFieldsType($value, $atMost);
172+
[$currentCount] = self::countFieldsType($value, $atMost);
170173

171174
if ($currentCount > $count) {
172-
throw new Exception\AtMostConstraintNotSatisfied();
175+
throw new AtMostConstraintNotSatisfied();
173176
}
174177

175178
return;
176179
}
177180

178181
if (self::countFieldsInput($value, $atMost) > $count) {
179-
throw new Exception\AtMostConstraintNotSatisfied();
182+
throw new AtMostConstraintNotSatisfied();
180183
}
181184
}
182185

@@ -186,14 +189,14 @@ private static function resolveExactly(TypeValue|InputValue $value, array $exact
186189
[$currentCount, $notRequested] = self::countFieldsType($value, $exactly);
187190

188191
if ($currentCount > $count || ($currentCount + $notRequested) < $count) {
189-
throw new Exception\ExactlyConstraintNotSatisfied();
192+
throw new ExactlyConstraintNotSatisfied();
190193
}
191194

192195
return;
193196
}
194197

195198
if (self::countFieldsInput($value, $exactly) !== $count) {
196-
throw new Exception\ExactlyConstraintNotSatisfied();
199+
throw new ExactlyConstraintNotSatisfied();
197200
}
198201
}
199202

tests/Integration/ConstraintArgumentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function testArgument(Json $request, Json $expected) : void
141141
$result = $graphpinator->run(new JsonRequestFactory($request));
142142

143143
self::assertSame($expected->toString(), $result->toString());
144-
self::assertNull($result->getErrors());
144+
self::assertNull($result->errors);
145145
}
146146

147147
public static function argumentInvalidDataProvider() : array

0 commit comments

Comments
 (0)