Skip to content

Commit 4387a72

Browse files
committed
spec compliance
Tests: 275, Assertions: 267, Errors: 8.
1 parent 4993718 commit 4387a72

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/Schema.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public function import($data)
8888
{
8989
$result = $data;
9090
if ($this->ref !== null) {
91-
$result = $this->ref->getSchema()->import($data);
91+
// https://github.com/json-schema-org/JSON-Schema-Test-Suite/pull/129
92+
return $this->ref->getSchema()->import($data);
9293
}
9394

9495
if ($this->type !== null) {

src/SchemaLoader.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,18 @@ private function resolveReference($referencePath)
242242
$branch = &$this->rootData;
243243
while ($path) {
244244
$folder = array_shift($path);
245-
if (isset($branch->$folder)) {
245+
246+
// unescaping special characters
247+
// https://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07#section-4
248+
// https://github.com/json-schema-org/JSON-Schema-Test-Suite/issues/130
249+
$folder = str_replace(array('~0','~1', '%25'), array('~', '/', '%'), $folder);
250+
251+
if ($branch instanceof \stdClass && isset($branch->$folder)) {
246252
$branch = &$branch->$folder;
253+
} elseif (is_array($branch) && isset($branch[$folder])) {
254+
$branch = &$branch[$folder];
247255
} else {
248-
throw new \Exception('Could not resolve ' . $referencePath . ', ' . $folder);
256+
throw new \Exception('Could not resolve ' . $referencePath . ': ' . $folder);
249257
}
250258
}
251259
$ref = new Ref($referencePath, $this->readSchema($branch));

0 commit comments

Comments
 (0)