@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | if ($isArray) { |
248 | 248 | $actualKey -= $removedOffset; |
249 | 249 | } |
250 | - $this->path .= '/' . JsonPointer::escapeSegment($actualKey, $this->options & self::JSON_URI_FRAGMENT_ID); |
|
250 | + $this->path .= '/'.JsonPointer::escapeSegment($actualKey, $this->options & self::JSON_URI_FRAGMENT_ID); |
|
251 | 251 | $this->pathItems[] = $actualKey; |
252 | 252 | |
253 | 253 | if (array_key_exists($key, $newArray)) { |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | return null; |
279 | 279 | } |
280 | 280 | $newOrdered[$key] = $value; |
281 | - $path = $this->path . '/' . JsonPointer::escapeSegment($key, $this->options & self::JSON_URI_FRAGMENT_ID); |
|
281 | + $path = $this->path.'/'.JsonPointer::escapeSegment($key, $this->options & self::JSON_URI_FRAGMENT_ID); |
|
282 | 282 | $pathItems = $this->pathItems; |
283 | 283 | $pathItems[] = $key; |
284 | 284 | JsonPointer::add($this->added, $pathItems, $value); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | |
289 | 289 | } |
290 | 290 | |
291 | - return is_array($new) ? $newOrdered : (object)$newOrdered; |
|
291 | + return is_array($new) ? $newOrdered : (object) $newOrdered; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | private function rearrangeArray(array $original, array $new) |
@@ -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 | } |
@@ -87,7 +87,9 @@ |
||
87 | 87 | throw new Exception('Non-existent path item: ' . $key); |
88 | 88 | } |
89 | 89 | } else { |
90 | - if ($recursively && $ref === null) $ref = array(); |
|
90 | + if ($recursively && $ref === null) { |
|
91 | + $ref = array(); |
|
92 | + } |
|
91 | 93 | if ('-' === $key) { |
92 | 94 | $ref = &$ref[]; |
93 | 95 | } else { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | return self::splitPathURIFragment($pathItems); |
33 | 33 | } else { |
34 | 34 | if ($first !== '') { |
35 | - throw new Exception('Path must start with "/": ' . $path); |
|
35 | + throw new Exception('Path must start with "/": '.$path); |
|
36 | 36 | } |
37 | 37 | return self::splitPathJsonString($pathItems); |
38 | 38 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $ref = &$ref->$key; |
80 | 80 | } else { |
81 | 81 | if (!isset($ref->$key) && count($pathItems)) { |
82 | - throw new Exception('Non-existent path item: ' . $key); |
|
82 | + throw new Exception('Non-existent path item: '.$key); |
|
83 | 83 | } else { |
84 | 84 | $ref = &$ref->$key; |
85 | 85 | } |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | } else { // null or array |
88 | 88 | $intKey = filter_var($key, FILTER_VALIDATE_INT); |
89 | 89 | if ($ref === null && (false === $intKey || $intKey !== 0)) { |
90 | - $key = (string)$key; |
|
90 | + $key = (string) $key; |
|
91 | 91 | if ($recursively) { |
92 | 92 | $ref = new \stdClass(); |
93 | 93 | $ref = &$ref->{$key}; |
94 | 94 | } else { |
95 | - throw new Exception('Non-existent path item: ' . $key); |
|
95 | + throw new Exception('Non-existent path item: '.$key); |
|
96 | 96 | } |
97 | 97 | } else { |
98 | 98 | if ($recursively && $ref === null) $ref = array(); |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | if (array_key_exists($key, $a)) { |
125 | 125 | return true; |
126 | 126 | } |
127 | - $key = (string)$key; |
|
127 | + $key = (string) $key; |
|
128 | 128 | foreach ($a as $k => $v) { |
129 | - if ((string)$k === $key) { |
|
129 | + if ((string) $k === $key) { |
|
130 | 130 | return true; |
131 | 131 | } |
132 | 132 | } |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | |
136 | 136 | private static function arrayGet($key, array $a) |
137 | 137 | { |
138 | - $key = (string)$key; |
|
138 | + $key = (string) $key; |
|
139 | 139 | foreach ($a as $k => $v) { |
140 | - if ((string)$k === $key) { |
|
140 | + if ((string) $k === $key) { |
|
141 | 141 | return $v; |
142 | 142 | } |
143 | 143 | } |
@@ -161,20 +161,20 @@ discard block |
||
161 | 161 | Exception::EMPTY_PROPERTY_NAME_UNSUPPORTED); |
162 | 162 | } |
163 | 163 | |
164 | - $vars = (array)$ref; |
|
164 | + $vars = (array) $ref; |
|
165 | 165 | if (self::arrayKeyExists($key, $vars)) { |
166 | 166 | $ref = self::arrayGet($key, $vars); |
167 | 167 | } else { |
168 | - throw new Exception('Key not found: ' . $key); |
|
168 | + throw new Exception('Key not found: '.$key); |
|
169 | 169 | } |
170 | 170 | } elseif (is_array($ref)) { |
171 | 171 | if (self::arrayKeyExists($key, $ref)) { |
172 | 172 | $ref = $ref[$key]; |
173 | 173 | } else { |
174 | - throw new Exception('Key not found: ' . $key); |
|
174 | + throw new Exception('Key not found: '.$key); |
|
175 | 175 | } |
176 | 176 | } else { |
177 | - throw new Exception('Key not found: ' . $key); |
|
177 | + throw new Exception('Key not found: '.$key); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | return $ref; |
@@ -207,13 +207,13 @@ discard block |
||
207 | 207 | if (property_exists($ref, $key)) { |
208 | 208 | $ref = &$ref->$key; |
209 | 209 | } else { |
210 | - throw new Exception('Key not found: ' . $key); |
|
210 | + throw new Exception('Key not found: '.$key); |
|
211 | 211 | } |
212 | 212 | } else { |
213 | 213 | if (array_key_exists($key, $ref)) { |
214 | 214 | $ref = &$ref[$key]; |
215 | 215 | } else { |
216 | - throw new Exception('Key not found: ' . $key); |
|
216 | + throw new Exception('Key not found: '.$key); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | } |