1 | <?php |
||
11 | final class Reference implements \JsonSerializable, \IteratorAggregate |
||
12 | { |
||
13 | /** |
||
14 | * @var \League\JsonReference\DereferencerInterface|null |
||
15 | */ |
||
16 | private static $dereferencer; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $ref; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $scope; |
||
27 | |||
28 | /** |
||
29 | * @var object|null |
||
30 | */ |
||
31 | private $schema; |
||
32 | |||
33 | /** |
||
34 | * @var mixed |
||
35 | */ |
||
36 | private $resolved; |
||
37 | |||
38 | /** |
||
39 | * @param string $ref |
||
40 | * @param string $scope |
||
41 | * @param null $schema |
||
42 | */ |
||
43 | 62 | public function __construct($ref, $scope = '', $schema = null) |
|
49 | |||
50 | /** |
||
51 | * Specify data which should be serialized to JSON. |
||
52 | * Because a reference can be circular, references are always |
||
53 | * re-serialized as the reference property instead of attempting |
||
54 | * to inline the data. |
||
55 | * |
||
56 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
57 | * |
||
58 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
59 | * which is a value of any type other than a resource. |
||
60 | */ |
||
61 | 16 | public function jsonSerialize() |
|
65 | |||
66 | /** |
||
67 | * Resolve the reference and return the data. |
||
68 | * |
||
69 | * @return mixed |
||
70 | */ |
||
71 | 50 | public function resolve() |
|
84 | |||
85 | /** |
||
86 | * Proxies property access to the underlying schema. |
||
87 | * |
||
88 | * @param string $property |
||
89 | * |
||
90 | * @return mixed |
||
91 | * |
||
92 | * @throws \InvalidArgumentException |
||
93 | */ |
||
94 | 18 | public function __get($property) |
|
104 | |||
105 | /** |
||
106 | * @param string $property |
||
107 | * |
||
108 | * @return mixed |
||
109 | * |
||
110 | * @throws \InvalidArgumentException |
||
111 | */ |
||
112 | public function get($property) |
||
121 | |||
122 | /** |
||
123 | * @param string $property |
||
124 | * |
||
125 | * @return bool |
||
126 | */ |
||
127 | public function has($property) |
||
132 | |||
133 | /** |
||
134 | * @return string |
||
135 | */ |
||
136 | 10 | public function getRef() |
|
140 | |||
141 | /** |
||
142 | * @return string |
||
143 | */ |
||
144 | public function getScope() |
||
148 | |||
149 | /** |
||
150 | * @return object|null |
||
151 | */ |
||
152 | public function getSchema() |
||
156 | |||
157 | /** |
||
158 | * Retrieve an external iterator |
||
159 | * @link http://php.net/manual/en/iteratoraggregate.getiterator.php |
||
160 | * @return \Traversable An instance of an object implementing <b>Iterator</b> or |
||
161 | * <b>Traversable</b> |
||
162 | * @since 5.0.0 |
||
163 | */ |
||
164 | 12 | public function getIterator() |
|
181 | |||
182 | /** |
||
183 | * @param \League\JsonReference\DereferencerInterface|null $dereferencer |
||
184 | */ |
||
185 | 54 | public static function setDereferencerInstance(DereferencerInterface $dereferencer = null) |
|
189 | |||
190 | /** |
||
191 | * @return \League\JsonReference\DereferencerInterface |
||
192 | * |
||
193 | * @throws \RuntimeException |
||
194 | */ |
||
195 | 30 | private function dereferencer() |
|
205 | } |
||
206 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.