1 | <?php |
||
22 | class Walker |
||
23 | { |
||
24 | /** |
||
25 | * @var Registry |
||
26 | */ |
||
27 | private $registry; |
||
28 | |||
29 | /** |
||
30 | * @var Resolver |
||
31 | */ |
||
32 | private $resolver; |
||
33 | |||
34 | /** |
||
35 | * @var stdClass[] |
||
36 | */ |
||
37 | private $parsedSchemas = []; |
||
38 | |||
39 | /** |
||
40 | * @var stdClass[] |
||
41 | */ |
||
42 | private $resolvedSchemas = []; |
||
43 | |||
44 | /** |
||
45 | * @var Constraint[][] |
||
46 | */ |
||
47 | private $constraintsCacheA = []; |
||
48 | |||
49 | /** |
||
50 | * @var Constraint[][] |
||
51 | */ |
||
52 | private $constraintsCacheB = []; |
||
53 | |||
54 | /** |
||
55 | * Constructor. |
||
56 | * |
||
57 | * @param Registry $registry |
||
58 | * @param Resolver $resolver |
||
59 | */ |
||
60 | 485 | public function __construct(Registry $registry, Resolver $resolver) |
|
65 | |||
66 | /** |
||
67 | * Recursively resolve JSON pointer references within a given schema. |
||
68 | * |
||
69 | * @param stdClass $schema The schema to resolve |
||
70 | * @param Uri $uri The URI of the schema |
||
71 | * |
||
72 | * @return stdClass |
||
73 | */ |
||
74 | 299 | public function resolveReferences(stdClass $schema, Uri $uri) |
|
116 | |||
117 | /** |
||
118 | * Recursively normalizes a given schema and validates its syntax. |
||
119 | * |
||
120 | * @param stdClass $schema |
||
121 | * @param Context $context |
||
122 | * |
||
123 | * @return stdClass |
||
124 | */ |
||
125 | 357 | public function parseSchema(stdClass $schema, Context $context) |
|
142 | |||
143 | /** |
||
144 | * Validates an instance against a given schema, populating a context |
||
145 | * with encountered violations. |
||
146 | * |
||
147 | * @param mixed $instance |
||
148 | * @param stdClass $schema |
||
149 | * @param Context $context |
||
150 | */ |
||
151 | 348 | public function applyConstraints($instance, stdClass $schema, Context $context) |
|
158 | |||
159 | /** |
||
160 | * Checks if given schema has been already visited. |
||
161 | * |
||
162 | * @param stdClass $schema |
||
163 | * @param array $stack |
||
164 | * |
||
165 | * @return bool |
||
166 | */ |
||
167 | 363 | private function isLooping(stdClass $schema, array &$stack) |
|
177 | |||
178 | /** |
||
179 | * Returns constraints for current schema version. |
||
180 | * |
||
181 | * @param stdClass $schema |
||
182 | * @param Context $context |
||
183 | * |
||
184 | * @return Constraint[] |
||
185 | */ |
||
186 | 357 | private function getConstraints(stdClass $schema, Context $context) |
|
194 | |||
195 | /** |
||
196 | * Returns constraints which should be applied to given instance. |
||
197 | * |
||
198 | * @param stdClass $schema |
||
199 | * @param Context $context |
||
200 | * @param mixed $instance |
||
201 | * |
||
202 | * @return Constraint[] |
||
203 | */ |
||
204 | 348 | private function getConstraintsForInstance(stdClass $schema, Context $context, $instance) |
|
241 | } |
||
242 |