Skip to content

Commit b7f838e

Browse files
committed
Fixed annotation handling for invalid assertion results
1 parent 93cd59a commit b7f838e

9 files changed

+11
-22
lines changed

src/EvaluationContext/RuntimeEvaluationContext.php

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ public function getLastResultNumber(): int
9797
return $this->lastResultNumber;
9898
}
9999

100+
/**
101+
* @return RuntimeEvaluationResult[]
102+
*/
100103
public function getResultsByKeywordName(string $keywordName): array
101104
{
102105
$results = [];

src/EvaluationContext/RuntimeEvaluationResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function setAnnotation(mixed $annotation): void
4343

4444
public function getAnnotation(bool $force = false): mixed
4545
{
46-
if (!$force && (!$this->valid || $this->suppressAnnotation)) {
46+
if (!$force && $this->suppressAnnotation) {
4747
return null;
4848
}
4949

src/Keyword/Applicator/AdditionalPropertiesKeyword.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ public function evaluate(mixed $keywordValue, RuntimeEvaluationContext $context)
9696
$additionalEvaluatedPropertyNames[$propertyName] = $propertyName;
9797
}
9898

99-
if ($result->valid) {
100-
$result->setAnnotation($additionalEvaluatedPropertyNames);
101-
}
99+
$result->setAnnotation($additionalEvaluatedPropertyNames);
102100

103101
return $result;
104102
}

src/Keyword/Applicator/ItemsKeyword.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ public function evaluate(mixed $keywordValue, RuntimeEvaluationContext $context)
7272
}
7373
}
7474

75-
if ($result->valid) {
76-
$result->setAnnotation(true);
77-
}
75+
$result->setAnnotation(true);
7876

7977
return $result;
8078
}

src/Keyword/Applicator/PatternPropertiesKeyword.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ public function evaluate(mixed $keywordValue, RuntimeEvaluationContext $context)
9494
}
9595
}
9696

97-
if ($result->valid) {
98-
$result->setAnnotation($matchedPropertyNames);
99-
}
97+
$result->setAnnotation($matchedPropertyNames);
10098

10199
return $result;
102100
}

src/Keyword/Applicator/PrefixItemsKeyword.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ public function evaluate(mixed $keywordValue, RuntimeEvaluationContext $context)
8686
}
8787
}
8888

89-
if ($result->valid) {
90-
$result->setAnnotation(($prefixItemsKey === count($instance) - 1) ?: $prefixItemsKey);
91-
}
89+
$result->setAnnotation(($prefixItemsKey === count($instance) - 1) ?: $prefixItemsKey);
9290

9391
return $result;
9492
}

src/Keyword/Applicator/PropertiesKeyword.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ public function evaluate(mixed $keywordValue, RuntimeEvaluationContext $context)
102102
$evaluatedProperties[$propertyName] = $propertyName;
103103
}
104104

105-
if ($result->valid) {
106-
$result->setAnnotation($evaluatedProperties);
107-
}
105+
$result->setAnnotation($evaluatedProperties);
108106

109107
return $result;
110108
}

src/Keyword/Applicator/UnevaluatedItemsKeyword.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ public function evaluate(mixed $keywordValue, RuntimeEvaluationContext $context)
107107
}
108108
}
109109

110-
if ($result->valid) {
111-
$result->setAnnotation(true);
112-
}
110+
$result->setAnnotation(true);
113111

114112
return $result;
115113
}

src/Keyword/Applicator/UnevaluatedPropertiesKeyword.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ public function evaluate(mixed $keywordValue, RuntimeEvaluationContext $context)
8585
$evaluatedPropertyNames[$propertyName] = $propertyName;
8686
}
8787

88-
if ($result->valid) {
89-
$result->setAnnotation($evaluatedPropertyNames);
90-
}
88+
$result->setAnnotation($evaluatedPropertyNames);
9189

9290
return $result;
9391
}

0 commit comments

Comments
 (0)