@@ -66,7 +66,7 @@ public static function splitPath($path)
6666 return self ::splitPathURIFragment ($ pathItems );
6767 } else {
6868 if ($ first !== '' ) {
69- throw new Exception ('Path must start with "/": ' . $ path );
69+ throw new JsonPointerException ('Path must start with "/": ' . $ path );
7070 }
7171 return self ::splitPathJsonString ($ pathItems );
7272 }
@@ -105,15 +105,15 @@ public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIV
105105 while (null !== $ key = array_shift ($ pathItems )) {
106106 if ($ ref instanceof \stdClass || is_object ($ ref )) {
107107 if (PHP_VERSION_ID < 70100 && '' === $ key ) {
108- throw new Exception ('Empty property name is not supported by PHP <7.1 ' ,
108+ throw new JsonPointerException ('Empty property name is not supported by PHP <7.1 ' ,
109109 Exception::EMPTY_PROPERTY_NAME_UNSUPPORTED );
110110 }
111111
112112 if ($ flags & self ::RECURSIVE_KEY_CREATION ) {
113113 $ ref = &$ ref ->$ key ;
114114 } else {
115115 if (!isset ($ ref ->$ key ) && count ($ pathItems )) {
116- throw new Exception ('Non-existent path item: ' . $ key );
116+ throw new JsonPointerException ('Non-existent path item: ' . $ key );
117117 } else {
118118 $ ref = &$ ref ->$ key ;
119119 }
@@ -126,7 +126,7 @@ public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIV
126126 $ ref = new \stdClass ();
127127 $ ref = &$ ref ->{$ key };
128128 } else {
129- throw new Exception ('Non-existent path item: ' . $ key );
129+ throw new JsonPointerException ('Non-existent path item: ' . $ key );
130130 }
131131 } elseif ([] === $ ref && 0 === ($ flags & self ::STRICT_MODE ) && false === $ intKey && '- ' !== $ key ) {
132132 $ ref = new \stdClass ();
@@ -138,7 +138,7 @@ public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIV
138138 } else {
139139 if (false === $ intKey ) {
140140 if (0 === ($ flags & self ::TOLERATE_ASSOCIATIVE_ARRAYS )) {
141- throw new Exception ('Invalid key for array operation ' );
141+ throw new JsonPointerException ('Invalid key for array operation ' );
142142 }
143143 $ ref = &$ ref [$ key ];
144144 continue ;
@@ -148,9 +148,9 @@ public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIV
148148 }
149149 if (0 === ($ flags & self ::TOLERATE_ASSOCIATIVE_ARRAYS )) {
150150 if ($ intKey > count ($ ref ) && 0 === ($ flags & self ::RECURSIVE_KEY_CREATION )) {
151- throw new Exception ('Index is greater than number of items in array ' );
151+ throw new JsonPointerException ('Index is greater than number of items in array ' );
152152 } elseif ($ intKey < 0 ) {
153- throw new Exception ('Negative index ' );
153+ throw new JsonPointerException ('Negative index ' );
154154 }
155155 }
156156
@@ -203,30 +203,30 @@ public static function get($holder, $pathItems)
203203 while (null !== $ key = array_shift ($ pathItems )) {
204204 if ($ ref instanceof \stdClass) {
205205 if (PHP_VERSION_ID < 70100 && '' === $ key ) {
206- throw new Exception ('Empty property name is not supported by PHP <7.1 ' ,
206+ throw new JsonPointerException ('Empty property name is not supported by PHP <7.1 ' ,
207207 Exception::EMPTY_PROPERTY_NAME_UNSUPPORTED );
208208 }
209209
210210 $ vars = (array )$ ref ;
211211 if (self ::arrayKeyExists ($ key , $ vars )) {
212212 $ ref = self ::arrayGet ($ key , $ vars );
213213 } else {
214- throw new Exception ('Key not found: ' . $ key );
214+ throw new JsonPointerException ('Key not found: ' . $ key );
215215 }
216216 } elseif (is_array ($ ref )) {
217217 if (self ::arrayKeyExists ($ key , $ ref )) {
218218 $ ref = $ ref [$ key ];
219219 } else {
220- throw new Exception ('Key not found: ' . $ key );
220+ throw new JsonPointerException ('Key not found: ' . $ key );
221221 }
222222 } elseif (is_object ($ ref )) {
223223 if (isset ($ ref ->$ key )) {
224224 $ ref = $ ref ->$ key ;
225225 } else {
226- throw new Exception ('Key not found: ' . $ key );
226+ throw new JsonPointerException ('Key not found: ' . $ key );
227227 }
228228 } else {
229- throw new Exception ('Key not found: ' . $ key );
229+ throw new JsonPointerException ('Key not found: ' . $ key );
230230 }
231231 }
232232 return $ ref ;
@@ -260,19 +260,19 @@ public static function remove(&$holder, $pathItems, $flags = 0)
260260 if (property_exists ($ ref , $ key )) {
261261 $ ref = &$ ref ->$ key ;
262262 } else {
263- throw new Exception ('Key not found: ' . $ key );
263+ throw new JsonPointerException ('Key not found: ' . $ key );
264264 }
265265 } elseif (is_object ($ ref )) {
266266 if (isset ($ ref ->$ key )) {
267267 $ ref = &$ ref ->$ key ;
268268 } else {
269- throw new Exception ('Key not found: ' . $ key );
269+ throw new JsonPointerException ('Key not found: ' . $ key );
270270 }
271271 } else {
272272 if (array_key_exists ($ key , $ ref )) {
273273 $ ref = &$ ref [$ key ];
274274 } else {
275- throw new Exception ('Key not found: ' . $ key );
275+ throw new JsonPointerException ('Key not found: ' . $ key );
276276 }
277277 }
278278 }
0 commit comments