@@ -66,7 +66,7 @@ public static function splitPath($path)
66
66
return self ::splitPathURIFragment ($ pathItems );
67
67
} else {
68
68
if ($ first !== '' ) {
69
- throw new Exception ('Path must start with "/": ' . $ path );
69
+ throw new JsonPointerException ('Path must start with "/": ' . $ path );
70
70
}
71
71
return self ::splitPathJsonString ($ pathItems );
72
72
}
@@ -105,15 +105,15 @@ public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIV
105
105
while (null !== $ key = array_shift ($ pathItems )) {
106
106
if ($ ref instanceof \stdClass || is_object ($ ref )) {
107
107
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 ' ,
109
109
Exception::EMPTY_PROPERTY_NAME_UNSUPPORTED );
110
110
}
111
111
112
112
if ($ flags & self ::RECURSIVE_KEY_CREATION ) {
113
113
$ ref = &$ ref ->$ key ;
114
114
} else {
115
115
if (!isset ($ ref ->$ key ) && count ($ pathItems )) {
116
- throw new Exception ('Non-existent path item: ' . $ key );
116
+ throw new JsonPointerException ('Non-existent path item: ' . $ key );
117
117
} else {
118
118
$ ref = &$ ref ->$ key ;
119
119
}
@@ -126,7 +126,7 @@ public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIV
126
126
$ ref = new \stdClass ();
127
127
$ ref = &$ ref ->{$ key };
128
128
} else {
129
- throw new Exception ('Non-existent path item: ' . $ key );
129
+ throw new JsonPointerException ('Non-existent path item: ' . $ key );
130
130
}
131
131
} elseif ([] === $ ref && 0 === ($ flags & self ::STRICT_MODE ) && false === $ intKey && '- ' !== $ key ) {
132
132
$ ref = new \stdClass ();
@@ -138,7 +138,7 @@ public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIV
138
138
} else {
139
139
if (false === $ intKey ) {
140
140
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 ' );
142
142
}
143
143
$ ref = &$ ref [$ key ];
144
144
continue ;
@@ -148,9 +148,9 @@ public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIV
148
148
}
149
149
if (0 === ($ flags & self ::TOLERATE_ASSOCIATIVE_ARRAYS )) {
150
150
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 ' );
152
152
} elseif ($ intKey < 0 ) {
153
- throw new Exception ('Negative index ' );
153
+ throw new JsonPointerException ('Negative index ' );
154
154
}
155
155
}
156
156
@@ -203,30 +203,30 @@ public static function get($holder, $pathItems)
203
203
while (null !== $ key = array_shift ($ pathItems )) {
204
204
if ($ ref instanceof \stdClass) {
205
205
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 ' ,
207
207
Exception::EMPTY_PROPERTY_NAME_UNSUPPORTED );
208
208
}
209
209
210
210
$ vars = (array )$ ref ;
211
211
if (self ::arrayKeyExists ($ key , $ vars )) {
212
212
$ ref = self ::arrayGet ($ key , $ vars );
213
213
} else {
214
- throw new Exception ('Key not found: ' . $ key );
214
+ throw new JsonPointerException ('Key not found: ' . $ key );
215
215
}
216
216
} elseif (is_array ($ ref )) {
217
217
if (self ::arrayKeyExists ($ key , $ ref )) {
218
218
$ ref = $ ref [$ key ];
219
219
} else {
220
- throw new Exception ('Key not found: ' . $ key );
220
+ throw new JsonPointerException ('Key not found: ' . $ key );
221
221
}
222
222
} elseif (is_object ($ ref )) {
223
223
if (isset ($ ref ->$ key )) {
224
224
$ ref = $ ref ->$ key ;
225
225
} else {
226
- throw new Exception ('Key not found: ' . $ key );
226
+ throw new JsonPointerException ('Key not found: ' . $ key );
227
227
}
228
228
} else {
229
- throw new Exception ('Key not found: ' . $ key );
229
+ throw new JsonPointerException ('Key not found: ' . $ key );
230
230
}
231
231
}
232
232
return $ ref ;
@@ -260,19 +260,19 @@ public static function remove(&$holder, $pathItems, $flags = 0)
260
260
if (property_exists ($ ref , $ key )) {
261
261
$ ref = &$ ref ->$ key ;
262
262
} else {
263
- throw new Exception ('Key not found: ' . $ key );
263
+ throw new JsonPointerException ('Key not found: ' . $ key );
264
264
}
265
265
} elseif (is_object ($ ref )) {
266
266
if (isset ($ ref ->$ key )) {
267
267
$ ref = &$ ref ->$ key ;
268
268
} else {
269
- throw new Exception ('Key not found: ' . $ key );
269
+ throw new JsonPointerException ('Key not found: ' . $ key );
270
270
}
271
271
} else {
272
272
if (array_key_exists ($ key , $ ref )) {
273
273
$ ref = &$ ref [$ key ];
274
274
} else {
275
- throw new Exception ('Key not found: ' . $ key );
275
+ throw new JsonPointerException ('Key not found: ' . $ key );
276
276
}
277
277
}
278
278
}
0 commit comments