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 array |
||
36 | */ |
||
37 | private $parsedSchemas = []; |
||
38 | |||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | private $resolvedSchemas = []; |
||
43 | |||
44 | /** |
||
45 | * @var Constraint[][] |
||
46 | */ |
||
47 | private $constraintsCache = []; |
||
48 | |||
49 | /** |
||
50 | * Constructor. |
||
51 | * |
||
52 | * @param Registry $registry |
||
53 | * @param Resolver $resolver |
||
54 | */ |
||
55 | 485 | public function __construct(Registry $registry, Resolver $resolver) |
|
60 | |||
61 | /** |
||
62 | * Recursively resolve JSON pointer references within a given schema. |
||
63 | * |
||
64 | * @param stdClass $schema The schema to resolve |
||
65 | * @param Uri $uri The URI of the schema |
||
66 | * |
||
67 | * @return stdClass |
||
68 | */ |
||
69 | 299 | public function resolveReferences(stdClass $schema, Uri $uri) |
|
75 | |||
76 | /** |
||
77 | * @param stdClass $schema |
||
78 | * @param Uri $uri |
||
79 | * |
||
80 | * @return stdClass |
||
81 | */ |
||
82 | 299 | private function doResolveReferences(stdClass $schema, Uri $uri) |
|
119 | |||
120 | /** |
||
121 | * Recursively normalizes a given schema and validates its syntax. |
||
122 | * |
||
123 | * @param stdClass $schema |
||
124 | * @param Context $context |
||
125 | * |
||
126 | * @return stdClass |
||
127 | */ |
||
128 | 357 | public function parseSchema(stdClass $schema, Context $context) |
|
148 | |||
149 | /** |
||
150 | * Validates an instance against a given schema, populating a context |
||
151 | * with encountered violations. |
||
152 | * |
||
153 | * @param mixed $instance |
||
154 | * @param stdClass $schema |
||
155 | * @param Context $context |
||
156 | */ |
||
157 | 348 | public function applyConstraints($instance, stdClass $schema, Context $context) |
|
177 | |||
178 | /** |
||
179 | * Checks if given schema has been already visited. |
||
180 | * |
||
181 | * @param stdClass $schema |
||
182 | * @param array $stack |
||
183 | * |
||
184 | * @return bool |
||
185 | */ |
||
186 | 363 | private function isLooping(stdClass $schema, array &$stack) |
|
196 | |||
197 | /** |
||
198 | * Filters constraints which should be triggered for given schema. |
||
199 | * |
||
200 | * @param Constraint[] $constraints |
||
201 | * @param stdClass $schema |
||
202 | * |
||
203 | * @return Constraint[] |
||
204 | */ |
||
205 | 357 | private function filterConstraintsForSchema(array $constraints, stdClass $schema) |
|
220 | } |
||
221 |