Skip to content

Commit 245f417

Browse files
committed
Fixed keyword and instance location, if a path fragment is 0
1 parent 8bc8b44 commit 245f417

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/EvaluationContext/EvaluationContextTrait.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ trait EvaluationContextTrait
2222

2323
public function pushSchema(
2424
\stdClass|bool|null $schema = null,
25-
string $keywordLocationFragment = null,
25+
?string $keywordLocationFragment = null,
2626
?string $baseUri = null,
2727
string $schemaLocation = ''
2828
): void {
@@ -36,7 +36,7 @@ public function pushSchema(
3636
$schemaKeywordLocation = $schemaLocation;
3737
}
3838

39-
if ($keywordLocationFragment) {
39+
if (is_string($keywordLocationFragment) && strlen($keywordLocationFragment)) {
4040
$schemaKeywordLocation .= '/' . $keywordLocationFragment;
4141
$keywordLocation = $currentStackEntry['keywordLocation'] . '/' . $keywordLocationFragment;
4242
} else {
@@ -126,7 +126,7 @@ public function getCurrentAbsoluteKeywordLocation(): ?string
126126
$currentStackEntry = $this->schemaStack[$this->schemaStackPointer];
127127

128128
$baseUri = $currentStackEntry['baseUri'];
129-
if (!$baseUri) {
129+
if (!is_string($baseUri) || !strlen($baseUri)) {
130130
return null;
131131
}
132132

src/EvaluationContext/RuntimeEvaluationContext.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ public function __construct(
4444
$this->draft = $staticEvaluationContext->config->defaultDraft;
4545
}
4646

47-
public function pushInstance(mixed &$instance, string $instanceLocationFragment = null): void
47+
public function pushInstance(mixed &$instance, ?string $instanceLocationFragment = null): void
4848
{
49-
if ($instanceLocationFragment === null) {
50-
$instanceLocation = $this->getCurrentInstanceLocation();
51-
} else {
49+
if (is_string($instanceLocationFragment) && strlen($instanceLocationFragment)) {
5250
$instanceLocation = $this->getCurrentInstanceLocation() . '/' . $instanceLocationFragment;
51+
} else {
52+
$instanceLocation = $this->getCurrentInstanceLocation();
5353
}
5454

5555
$this->instanceStack[++$this->instanceStackPointer] = [

0 commit comments

Comments
 (0)