Skip to content

Commit f09456d

Browse files
committed
fixed variance check for graphpinator v1.0-rc13
1 parent f6fd4f1 commit f09456d

File tree

7 files changed

+66
-49
lines changed

7 files changed

+66
-49
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"infinityloop-dev/graphpinator": "^1.0-rc12",
15+
"infinityloop-dev/graphpinator": "^1.0-rc13",
1616
"infinityloop-dev/utils": "^2.1.2",
1717
"nette/utils": "^3.2"
1818
},

composer.lock

Lines changed: 33 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/FloatConstraintDirective.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ protected function specificValidateVariance(
7070
\Graphpinator\Value\ArgumentValueSet $smallerSet,
7171
) : void
7272
{
73-
$lhs = $biggerSet->getRawValues();
74-
$rhs = $smallerSet->getRawValues();
73+
$lhs = $biggerSet->getValuesForResolver();
74+
$rhs = $smallerSet->getValuesForResolver();
7575

76-
if (\is_float($lhs->min) && ($rhs->min === null || $rhs->min < $lhs->min)) {
76+
if (\is_float($lhs['min']) && ($rhs['min'] === null || $rhs['min'] < $lhs['min'])) {
7777
throw new \Exception();
7878
}
7979

80-
if (\is_float($lhs->max) && ($rhs->max === null || $rhs->max > $lhs->max)) {
80+
if (\is_float($lhs['max']) && ($rhs['max'] === null || $rhs['max'] > $lhs['max'])) {
8181
throw new \Exception();
8282
}
8383

84-
if (\is_array($lhs->oneOf) && ($rhs->oneOf === null || !self::varianceValidateOneOf($lhs->oneOf, $rhs->oneOf))) {
84+
if (\is_array($lhs['oneOf']) && ($rhs['oneOf'] === null || !self::varianceValidateOneOf($lhs['oneOf'], $rhs['oneOf']))) {
8585
throw new \Exception();
8686
}
8787
}

src/IntConstraintDirective.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ protected function specificValidateVariance(
7070
\Graphpinator\Value\ArgumentValueSet $smallerSet,
7171
) : void
7272
{
73-
$lhs = $biggerSet->getRawValues();
74-
$rhs = $smallerSet->getRawValues();
73+
$lhs = $biggerSet->getValuesForResolver();
74+
$rhs = $smallerSet->getValuesForResolver();
7575

76-
if (\is_int($lhs->min) && ($rhs->min === null || $rhs->min < $lhs->min)) {
76+
if (\is_int($lhs['min']) && ($rhs['min'] === null || $rhs['min'] < $lhs['min'])) {
7777
throw new \Exception();
7878
}
7979

80-
if (\is_int($lhs->max) && ($rhs->max === null || $rhs->max > $lhs->max)) {
80+
if (\is_int($lhs['max']) && ($rhs['max'] === null || $rhs['max'] > $lhs['max'])) {
8181
throw new \Exception();
8282
}
8383

84-
if (\is_array($lhs->oneOf) && ($rhs->oneOf === null || !self::varianceValidateOneOf($lhs->oneOf, $rhs->oneOf))) {
84+
if (\is_array($lhs['oneOf']) && ($rhs['oneOf'] === null || !self::varianceValidateOneOf($lhs['oneOf'], $rhs['oneOf']))) {
8585
throw new \Exception();
8686
}
8787
}

src/ListConstraintDirective.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ protected function specificValidateVariance(
5050
) : void
5151
{
5252
self::recursiveSpecificValidateVariance(
53-
$biggerSet->getRawValues(),
54-
$smallerSet->getRawValues(),
53+
(object) $biggerSet->getValuesForResolver(),
54+
(object) $smallerSet->getValuesForResolver(),
5555
);
5656
}
5757

src/StringConstraintDirective.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,22 @@ protected function specificValidateVariance(
9090
\Graphpinator\Value\ArgumentValueSet $smallerSet,
9191
) : void
9292
{
93-
$lhs = $biggerSet->getRawValues();
94-
$rhs = $smallerSet->getRawValues();
93+
$lhs = $biggerSet->getValuesForResolver();
94+
$rhs = $smallerSet->getValuesForResolver();
9595

96-
if (\is_int($lhs->minLength) && ($rhs->minLength === null || $rhs->minLength < $lhs->minLength)) {
96+
if (\is_int($lhs['minLength']) && ($rhs['minLength'] === null || $rhs['minLength'] < $lhs['minLength'])) {
9797
throw new \Exception();
9898
}
9999

100-
if (\is_int($lhs->maxLength) && ($rhs->maxLength === null || $rhs->maxLength > $lhs->maxLength)) {
100+
if (\is_int($lhs['maxLength']) && ($rhs['maxLength'] === null || $rhs['maxLength'] > $lhs['maxLength'])) {
101101
throw new \Exception();
102102
}
103103

104-
if (\is_string($lhs->regex) && ($rhs->regex === null || $rhs->regex !== $lhs->regex)) {
104+
if (\is_string($lhs['regex']) && ($rhs['regex'] === null || $rhs['regex'] !== $lhs['regex'])) {
105105
throw new \Exception();
106106
}
107107

108-
if (\is_array($lhs->oneOf) && ($rhs->oneOf === null || !self::varianceValidateOneOf($lhs->oneOf, $rhs->oneOf))) {
108+
if (\is_array($lhs['oneOf']) && ($rhs['oneOf'] === null || !self::varianceValidateOneOf($lhs['oneOf'], $rhs['oneOf']))) {
109109
throw new \Exception();
110110
}
111111
}

tests/Integration/VarianceTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ public function testMissingBiggerSet() : void
1515

1616
\assert($directive instanceof \Graphpinator\Directive\Directive);
1717

18-
$values = \Graphpinator\Value\ArgumentValueSet::fromRaw([], $directive->getArguments());
18+
$values = new \Graphpinator\Value\ArgumentValueSet(
19+
(array) \Graphpinator\Value\ConvertRawValueVisitor::convertArgumentSet(
20+
$directive->getArguments(),
21+
new \stdClass(),
22+
new \Graphpinator\Common\Path(),
23+
),
24+
);
1925

2026
$directive->validateVariance(null, $values);
2127
}
@@ -27,7 +33,13 @@ public function testMissingSmallerSet() : void
2733
$directive = TestSchema::getType('stringConstraint');
2834
\assert($directive instanceof \Graphpinator\Directive\Directive);
2935

30-
$values = \Graphpinator\Value\ArgumentValueSet::fromRaw([], $directive->getArguments());
36+
$values = new \Graphpinator\Value\ArgumentValueSet(
37+
(array) \Graphpinator\Value\ConvertRawValueVisitor::convertArgumentSet(
38+
$directive->getArguments(),
39+
new \stdClass(),
40+
new \Graphpinator\Common\Path(),
41+
),
42+
);
3143

3244
$directive->validateVariance($values, null);
3345
}

0 commit comments

Comments
 (0)