Skip to content

Commit 587a286

Browse files
committed
better ajv tests compliance
1 parent 4a1dc14 commit 587a286

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

src/RefResolver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function resolveReference($referencePath)
206206

207207

208208
/**
209-
* @param $data
209+
* @param mixed $data
210210
* @param Context $options
211211
* @param int $nestingLevel
212212
* @throws Exception
@@ -229,7 +229,7 @@ public function preProcessReferences($data, Context $options, $nestingLevel = 0)
229229
) {
230230
$prev = $this->setupResolutionScope($data->{Schema::ID_D4}, $data);
231231
/** @noinspection PhpUnusedLocalVariableInspection */
232-
$_ = new ScopeExit(function () use ($prev, $options) {
232+
$_ = new ScopeExit(function () use ($prev) {
233233
$this->setResolutionScope($prev);
234234
});
235235
}
@@ -240,7 +240,7 @@ public function preProcessReferences($data, Context $options, $nestingLevel = 0)
240240
) {
241241
$prev = $this->setupResolutionScope($data->{Schema::ID}, $data);
242242
/** @noinspection PhpUnusedLocalVariableInspection */
243-
$_ = new ScopeExit(function () use ($prev, $options) {
243+
$_ = new ScopeExit(function () use ($prev) {
244244
$this->setResolutionScope($prev);
245245
});
246246
}

src/RemoteRef/Preloaded.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@ class Preloaded implements RemoteRefProvider
1111
{
1212
private $storage;
1313

14-
private $cachePaths = array(
15-
'http://json-schema.org/draft-04/schema' => __DIR__ . '/../../spec/json-schema.json',
16-
'http://json-schema.org/draft-06/schema' => __DIR__ . '/../../spec/json-schema-draft6.json',
17-
'http://json-schema.org/draft-07/schema' => __DIR__ . '/../../spec/json-schema-draft7.json',
18-
);
14+
private $schemaFiles;
15+
16+
public function __construct()
17+
{
18+
$this->schemaFiles = array(
19+
'http://json-schema.org/draft-04/schema' => __DIR__ . '/../../spec/json-schema.json',
20+
'http://json-schema.org/draft-06/schema' => __DIR__ . '/../../spec/json-schema-draft6.json',
21+
'http://json-schema.org/draft-07/schema' => __DIR__ . '/../../spec/json-schema-draft7.json',
22+
);
23+
}
1924

2025
public function getSchemaData($url)
2126
{
2227
if (isset($this->storage[$url])) {
2328
return $this->storage[$url];
24-
} elseif (isset($this->cachePaths[$url])) {
25-
$this->storage[$url] = json_decode(file_get_contents($this->cachePaths[$url]));
29+
} elseif (isset($this->schemaFiles[$url])) {
30+
$this->storage[$url] = json_decode(file_get_contents($this->schemaFiles[$url]));
2631
return $this->storage[$url];
2732
}
2833
return false;
@@ -56,5 +61,11 @@ public function setSchemaData($url, $schemaData)
5661
return $this;
5762
}
5863

64+
public function setSchemaFile($url, $path)
65+
{
66+
$this->schemaFiles[$url] = $path;
67+
return $this;
68+
}
69+
5970

6071
}

src/Schema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public static function import($data, Context $options = null)
118118
}
119119

120120
/**
121-
* @param $data
121+
* @param mixed $data
122122
* @param Context|null $options
123123
* @return array|mixed|null|object|\stdClass
124124
* @throws Exception

0 commit comments

Comments
 (0)