@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $path = $this->path; |
46 | 46 | $pathItems = $this->pathItems; |
47 | 47 | $actualKey = $key; |
48 | - $this->path .= '/' . JsonPointer::escapeSegment($actualKey); |
|
48 | + $this->path .= '/'.JsonPointer::escapeSegment($actualKey); |
|
49 | 49 | $this->pathItems[] = $actualKey; |
50 | 50 | |
51 | 51 | $result[$key] = $this->process($originalValue); |
@@ -54,6 +54,6 @@ discard block |
||
54 | 54 | $this->pathItems = $pathItems; |
55 | 55 | } |
56 | 56 | |
57 | - return $data instanceof \stdClass ? (object)$result : $result; |
|
57 | + return $data instanceof \stdClass ? (object) $result : $result; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | foreach ($data as $operation) { |
34 | 34 | /** @var OpPath|OpPathValue|OpPathFrom $operation */ |
35 | 35 | if (is_array($operation)) { |
36 | - $operation = (object)$operation; |
|
36 | + $operation = (object) $operation; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | if (!isset($operation->op)) { |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | $op = new Test(); |
65 | 65 | break; |
66 | 66 | default: |
67 | - throw new Exception('Unknown "op": ' . $operation->op); |
|
67 | + throw new Exception('Unknown "op": '.$operation->op); |
|
68 | 68 | } |
69 | 69 | $op->path = $operation->path; |
70 | 70 | if ($op instanceof OpPathValue) { |
71 | - if (!array_key_exists('value', (array)$operation)) { |
|
71 | + if (!array_key_exists('value', (array) $operation)) { |
|
72 | 72 | throw new Exception('Missing "value" in operation data'); |
73 | 73 | } |
74 | 74 | $op->value = $operation->value; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | { |
88 | 88 | $result = array(); |
89 | 89 | foreach ($patch->operations as $operation) { |
90 | - $result[] = (object)(array)$operation; |
|
90 | + $result[] = (object) (array) $operation; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | return $result; |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | $diff = new JsonDiff($operation->value, $value, |
145 | 145 | JsonDiff::STOP_ON_DIFF); |
146 | 146 | if ($diff->getDiffCnt() !== 0) { |
147 | - throw new Exception('Test operation ' . json_encode($operation, JSON_UNESCAPED_SLASHES) |
|
148 | - . ' failed: ' . json_encode($value)); |
|
147 | + throw new Exception('Test operation '.json_encode($operation, JSON_UNESCAPED_SLASHES) |
|
148 | + . ' failed: '.json_encode($value)); |
|
149 | 149 | } |
150 | 150 | break; |
151 | 151 | } |
@@ -122,7 +122,9 @@ |
||
122 | 122 | $ref = new \stdClass(); |
123 | 123 | $ref = &$ref->{$key}; |
124 | 124 | } else { |
125 | - if ($flags & self::RECURSIVE_KEY_CREATION && $ref === null) $ref = array(); |
|
125 | + if ($flags & self::RECURSIVE_KEY_CREATION && $ref === null) { |
|
126 | + $ref = array(); |
|
127 | + } |
|
126 | 128 | if ('-' === $key) { |
127 | 129 | $ref = &$ref[]; |
128 | 130 | } else { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | { |
44 | 44 | $result = $isURIFragmentId ? '#' : ''; |
45 | 45 | foreach ($pathItems as $pathItem) { |
46 | - $result .= '/' . self::escapeSegment($pathItem, $isURIFragmentId); |
|
46 | + $result .= '/'.self::escapeSegment($pathItem, $isURIFragmentId); |
|
47 | 47 | } |
48 | 48 | return $result; |
49 | 49 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | return self::splitPathURIFragment($pathItems); |
62 | 62 | } else { |
63 | 63 | if ($first !== '') { |
64 | - throw new Exception('Path must start with "/": ' . $path); |
|
64 | + throw new Exception('Path must start with "/": '.$path); |
|
65 | 65 | } |
66 | 66 | return self::splitPathJsonString($pathItems); |
67 | 67 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $ref = &$ref->$key; |
109 | 109 | } else { |
110 | 110 | if (!isset($ref->$key) && count($pathItems)) { |
111 | - throw new Exception('Non-existent path item: ' . $key); |
|
111 | + throw new Exception('Non-existent path item: '.$key); |
|
112 | 112 | } else { |
113 | 113 | $ref = &$ref->$key; |
114 | 114 | } |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | } else { // null or array |
117 | 117 | $intKey = filter_var($key, FILTER_VALIDATE_INT); |
118 | 118 | if ($ref === null && (false === $intKey || $intKey !== 0)) { |
119 | - $key = (string)$key; |
|
119 | + $key = (string) $key; |
|
120 | 120 | if ($flags & self::RECURSIVE_KEY_CREATION) { |
121 | 121 | $ref = new \stdClass(); |
122 | 122 | $ref = &$ref->{$key}; |
123 | 123 | } else { |
124 | - throw new Exception('Non-existent path item: ' . $key); |
|
124 | + throw new Exception('Non-existent path item: '.$key); |
|
125 | 125 | } |
126 | 126 | } elseif ([] === $ref && 0 === ($flags & self::STRICT_MODE) && false === $intKey && '-' !== $key) { |
127 | 127 | $ref = new \stdClass(); |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | if (array_key_exists($key, $a)) { |
160 | 160 | return true; |
161 | 161 | } |
162 | - $key = (string)$key; |
|
162 | + $key = (string) $key; |
|
163 | 163 | foreach ($a as $k => $v) { |
164 | - if ((string)$k === $key) { |
|
164 | + if ((string) $k === $key) { |
|
165 | 165 | return true; |
166 | 166 | } |
167 | 167 | } |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | |
171 | 171 | private static function arrayGet($key, array $a) |
172 | 172 | { |
173 | - $key = (string)$key; |
|
173 | + $key = (string) $key; |
|
174 | 174 | foreach ($a as $k => $v) { |
175 | - if ((string)$k === $key) { |
|
175 | + if ((string) $k === $key) { |
|
176 | 176 | return $v; |
177 | 177 | } |
178 | 178 | } |
@@ -196,26 +196,26 @@ discard block |
||
196 | 196 | Exception::EMPTY_PROPERTY_NAME_UNSUPPORTED); |
197 | 197 | } |
198 | 198 | |
199 | - $vars = (array)$ref; |
|
199 | + $vars = (array) $ref; |
|
200 | 200 | if (self::arrayKeyExists($key, $vars)) { |
201 | 201 | $ref = self::arrayGet($key, $vars); |
202 | 202 | } else { |
203 | - throw new Exception('Key not found: ' . $key); |
|
203 | + throw new Exception('Key not found: '.$key); |
|
204 | 204 | } |
205 | 205 | } elseif (is_array($ref)) { |
206 | 206 | if (self::arrayKeyExists($key, $ref)) { |
207 | 207 | $ref = $ref[$key]; |
208 | 208 | } else { |
209 | - throw new Exception('Key not found: ' . $key); |
|
209 | + throw new Exception('Key not found: '.$key); |
|
210 | 210 | } |
211 | 211 | } elseif (is_object($ref)) { |
212 | 212 | if (isset($ref->$key)) { |
213 | 213 | $ref = $ref->$key; |
214 | 214 | } else { |
215 | - throw new Exception('Key not found: ' . $key); |
|
215 | + throw new Exception('Key not found: '.$key); |
|
216 | 216 | } |
217 | 217 | } else { |
218 | - throw new Exception('Key not found: ' . $key); |
|
218 | + throw new Exception('Key not found: '.$key); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | return $ref; |
@@ -248,19 +248,19 @@ discard block |
||
248 | 248 | if (property_exists($ref, $key)) { |
249 | 249 | $ref = &$ref->$key; |
250 | 250 | } else { |
251 | - throw new Exception('Key not found: ' . $key); |
|
251 | + throw new Exception('Key not found: '.$key); |
|
252 | 252 | } |
253 | 253 | } elseif (is_object($ref)) { |
254 | 254 | if (isset($ref->$key)) { |
255 | 255 | $ref = &$ref->$key; |
256 | 256 | } else { |
257 | - throw new Exception('Key not found: ' . $key); |
|
257 | + throw new Exception('Key not found: '.$key); |
|
258 | 258 | } |
259 | 259 | } else { |
260 | 260 | if (array_key_exists($key, $ref)) { |
261 | 261 | $ref = &$ref[$key]; |
262 | 262 | } else { |
263 | - throw new Exception('Key not found: ' . $key); |
|
263 | + throw new Exception('Key not found: '.$key); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | } |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | if ($merge && is_array($new) && !is_array($original)) { |
280 | 280 | $merge = false; |
281 | 281 | JsonPointer::add($this->merge, $this->pathItems, $new); |
282 | - } elseif ($merge && $new instanceof \stdClass && !$original instanceof \stdClass) { |
|
282 | + } elseif ($merge && $new instanceof \stdClass && !$original instanceof \stdClass) { |
|
283 | 283 | $merge = false; |
284 | 284 | JsonPointer::add($this->merge, $this->pathItems, $new); |
285 | 285 | } |
286 | 286 | |
287 | - $isUriFragment = (bool)($this->options & self::JSON_URI_FRAGMENT_ID); |
|
287 | + $isUriFragment = (bool) ($this->options & self::JSON_URI_FRAGMENT_ID); |
|
288 | 288 | foreach ($originalKeys as $key => $originalValue) { |
289 | 289 | if ($this->options & self::STOP_ON_DIFF) { |
290 | 290 | if ($this->modifiedCnt || $this->addedCnt || $this->removedCnt) { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | if ($isArray && is_int($actualKey)) { |
299 | 299 | $actualKey -= $removedOffset; |
300 | 300 | } |
301 | - $this->path .= '/' . JsonPointer::escapeSegment((string)$actualKey, $isUriFragment); |
|
301 | + $this->path .= '/'.JsonPointer::escapeSegment((string) $actualKey, $isUriFragment); |
|
302 | 302 | $this->pathItems[] = $actualKey; |
303 | 303 | |
304 | 304 | if (array_key_exists($key, $newArray)) { |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | return null; |
336 | 336 | } |
337 | 337 | $newOrdered[$key] = $value; |
338 | - $path = $this->path . '/' . JsonPointer::escapeSegment($key, $isUriFragment); |
|
338 | + $path = $this->path.'/'.JsonPointer::escapeSegment($key, $isUriFragment); |
|
339 | 339 | $pathItems = $this->pathItems; |
340 | 340 | $pathItems[] = $key; |
341 | 341 | JsonPointer::add($this->added, $pathItems, $value); |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | |
352 | 352 | } |
353 | 353 | |
354 | - return is_array($new) ? $newOrdered : (object)$newOrdered; |
|
354 | + return is_array($new) ? $newOrdered : (object) $newOrdered; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | private function rearrangeArray(array $original, array $new) |