1 | <?php |
||
23 | class Walker |
||
24 | { |
||
25 | /** |
||
26 | * @var Registry |
||
27 | */ |
||
28 | private $registry; |
||
29 | |||
30 | /** |
||
31 | * @var Resolver |
||
32 | */ |
||
33 | private $resolver; |
||
34 | |||
35 | /** |
||
36 | * @var SplObjectStorage |
||
37 | */ |
||
38 | private $parsedSchemas; |
||
39 | |||
40 | /** |
||
41 | * @var SplObjectStorage |
||
42 | */ |
||
43 | private $resolvedSchemas; |
||
44 | |||
45 | /** |
||
46 | * @var Constraint[][] |
||
47 | */ |
||
48 | private $constraintsCache = []; |
||
49 | |||
50 | /** |
||
51 | * Constructor. |
||
52 | * |
||
53 | * @param Registry $registry |
||
54 | * @param Resolver $resolver |
||
55 | */ |
||
56 | 494 | public function __construct(Registry $registry, Resolver $resolver) |
|
63 | |||
64 | /** |
||
65 | * Recursively resolves JSON pointer references within a given schema. |
||
66 | * |
||
67 | * @param stdClass $schema The schema to resolve |
||
68 | * @param Uri $uri The URI of the schema |
||
69 | * |
||
70 | * @return stdClass |
||
71 | */ |
||
72 | 308 | public function resolveReferences(stdClass $schema, Uri $uri) |
|
78 | |||
79 | /** |
||
80 | * @param stdClass $schema |
||
81 | * @param Uri $uri |
||
82 | * @param bool $inProperties |
||
83 | * |
||
84 | * @return stdClass |
||
85 | */ |
||
86 | 308 | private function doResolveReferences(stdClass $schema, Uri $uri, $inProperties = false) |
|
128 | |||
129 | /** |
||
130 | * Recursively normalizes a given schema and validates its syntax. |
||
131 | * |
||
132 | * @param stdClass $schema |
||
133 | * @param Context $context |
||
134 | * |
||
135 | * @return stdClass |
||
136 | */ |
||
137 | 366 | public function parseSchema(stdClass $schema, Context $context) |
|
153 | |||
154 | /** |
||
155 | * Validates an instance against a given schema, populating a context |
||
156 | * with encountered violations. |
||
157 | * |
||
158 | * @param mixed $instance |
||
159 | * @param stdClass $schema |
||
160 | * @param Context $context |
||
161 | */ |
||
162 | 357 | public function applyConstraints($instance, stdClass $schema, Context $context) |
|
178 | |||
179 | /** |
||
180 | * Returns whether a schema has already been processed and stored in |
||
181 | * a given collection. This acts as an infinite recursion check. |
||
182 | * |
||
183 | * @param stdClass $schema |
||
184 | * @param SplObjectStorage $storage |
||
185 | * |
||
186 | * @return bool |
||
187 | */ |
||
188 | 372 | private function isProcessed(stdClass $schema, SplObjectStorage $storage) |
|
198 | |||
199 | /** |
||
200 | * Returns the version of a schema. |
||
201 | * |
||
202 | * @param stdClass $schema |
||
203 | * |
||
204 | * @return string |
||
205 | */ |
||
206 | 372 | private function getVersion(stdClass $schema) |
|
212 | |||
213 | /** |
||
214 | * Filters constraints which should be triggered for given schema. |
||
215 | * |
||
216 | * @param Constraint[] $constraints |
||
217 | * @param stdClass $schema |
||
218 | * |
||
219 | * @return Constraint[] |
||
220 | */ |
||
221 | 366 | private function filterConstraintsForSchema(array $constraints, stdClass $schema) |
|
236 | } |
||
237 |