@@ -54,13 +54,13 @@ |
||
54 | 54 | { |
55 | 55 | $originalJson = file_get_contents($this->originalPath); |
56 | 56 | if (!$originalJson) { |
57 | - $this->response->error('Unable to read ' . $this->originalPath); |
|
57 | + $this->response->error('Unable to read '.$this->originalPath); |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | 61 | $newJson = file_get_contents($this->newPath); |
62 | 62 | if (!$newJson) { |
63 | - $this->response->error('Unable to read ' . $this->newPath); |
|
63 | + $this->response->error('Unable to read '.$this->newPath); |
|
64 | 64 | return; |
65 | 65 | } |
66 | 66 |
@@ -35,13 +35,13 @@ |
||
35 | 35 | { |
36 | 36 | $patchJson = file_get_contents($this->patchPath); |
37 | 37 | if (!$patchJson) { |
38 | - $this->response->error('Unable to read ' . $this->patchPath); |
|
38 | + $this->response->error('Unable to read '.$this->patchPath); |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | 42 | $baseJson = file_get_contents($this->basePath); |
43 | 43 | if (!$baseJson) { |
44 | - $this->response->error('Unable to read ' . $this->basePath); |
|
44 | + $this->response->error('Unable to read '.$this->basePath); |
|
45 | 45 | return; |
46 | 46 | } |
47 | 47 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | foreach ($data as $operation) { |
37 | 37 | /** @var OpPath|OpPathValue|OpPathFrom $operation */ |
38 | 38 | if (is_array($operation)) { |
39 | - $operation = (object)$operation; |
|
39 | + $operation = (object) $operation; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | if (!isset($operation->op)) { |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | $op = new Test(); |
68 | 68 | break; |
69 | 69 | default: |
70 | - throw new Exception('Unknown "op": ' . $operation->op); |
|
70 | + throw new Exception('Unknown "op": '.$operation->op); |
|
71 | 71 | } |
72 | 72 | $op->path = $operation->path; |
73 | 73 | if ($op instanceof OpPathValue) { |
74 | - if (!array_key_exists('value', (array)$operation)) { |
|
74 | + if (!array_key_exists('value', (array) $operation)) { |
|
75 | 75 | throw new Exception('Missing "value" in operation data'); |
76 | 76 | } |
77 | 77 | $op->value = $operation->value; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | { |
91 | 91 | $result = array(); |
92 | 92 | foreach ($patch->operations as $operation) { |
93 | - $result[] = (object)(array)$operation; |
|
93 | + $result[] = (object) (array) $operation; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | return $result; |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | $diff = new JsonDiff($operation->value, $value, |
144 | 144 | JsonDiff::STOP_ON_DIFF); |
145 | 145 | if ($diff->getDiffCnt() !== 0) { |
146 | - throw new Exception('Test operation ' . json_encode($operation, JSON_UNESCAPED_SLASHES) |
|
147 | - . ' failed: ' . json_encode($value)); |
|
146 | + throw new Exception('Test operation '.json_encode($operation, JSON_UNESCAPED_SLASHES) |
|
147 | + . ' failed: '.json_encode($value)); |
|
148 | 148 | } |
149 | 149 | break; |
150 | 150 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | $path = $this->path; |
243 | 243 | $pathItems = $this->pathItems; |
244 | - $this->path .= '/' . JsonPointer::escapeSegment($key, $this->options & self::JSON_URI_FRAGMENT_ID); |
|
244 | + $this->path .= '/'.JsonPointer::escapeSegment($key, $this->options & self::JSON_URI_FRAGMENT_ID); |
|
245 | 245 | $this->pathItems[] = $key; |
246 | 246 | |
247 | 247 | if (array_key_exists($key, $newArray)) { |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | return null; |
270 | 270 | } |
271 | 271 | $newOrdered[$key] = $value; |
272 | - $path = $this->path . '/' . JsonPointer::escapeSegment($key, $this->options & self::JSON_URI_FRAGMENT_ID); |
|
272 | + $path = $this->path.'/'.JsonPointer::escapeSegment($key, $this->options & self::JSON_URI_FRAGMENT_ID); |
|
273 | 273 | $pathItems = $this->pathItems; |
274 | 274 | $pathItems[] = $key; |
275 | 275 | JsonPointer::add($this->added, $pathItems, $value); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | |
280 | 280 | } |
281 | 281 | |
282 | - return is_array($new) ? $newOrdered : (object)$newOrdered; |
|
282 | + return is_array($new) ? $newOrdered : (object) $newOrdered; |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | private function rearrangeArray(array $original, array $new) |
@@ -70,7 +70,9 @@ |
||
70 | 70 | throw new Exception('Non-existent path'); |
71 | 71 | } |
72 | 72 | } else { |
73 | - if ($recursively && $ref === null) $ref = array(); |
|
73 | + if ($recursively && $ref === null) { |
|
74 | + $ref = array(); |
|
75 | + } |
|
74 | 76 | if ('-' === $key) { |
75 | 77 | $ref = &$ref[]; |
76 | 78 | } 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 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } else { // null or array |
78 | 78 | $intKey = filter_var($key, FILTER_VALIDATE_INT); |
79 | 79 | if ($ref === null && (false === $intKey || $intKey !== 0)) { |
80 | - $key = (string)$key; |
|
80 | + $key = (string) $key; |
|
81 | 81 | if ($recursively) { |
82 | 82 | $ref = new \stdClass(); |
83 | 83 | $ref = &$ref->{$key}; |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | if (array_key_exists($key, $a)) { |
115 | 115 | return true; |
116 | 116 | } |
117 | - $key = (string)$key; |
|
117 | + $key = (string) $key; |
|
118 | 118 | foreach ($a as $k => $v) { |
119 | - if ((string)$k === $key) { |
|
119 | + if ((string) $k === $key) { |
|
120 | 120 | return true; |
121 | 121 | } |
122 | 122 | } |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | |
126 | 126 | private static function arrayGet($key, array $a) |
127 | 127 | { |
128 | - $key = (string)$key; |
|
128 | + $key = (string) $key; |
|
129 | 129 | foreach ($a as $k => $v) { |
130 | - if ((string)$k === $key) { |
|
130 | + if ((string) $k === $key) { |
|
131 | 131 | return $v; |
132 | 132 | } |
133 | 133 | } |
@@ -151,20 +151,20 @@ discard block |
||
151 | 151 | Exception::EMPTY_PROPERTY_NAME_UNSUPPORTED); |
152 | 152 | } |
153 | 153 | |
154 | - $vars = (array)$ref; |
|
154 | + $vars = (array) $ref; |
|
155 | 155 | if (self::arrayKeyExists($key, $vars)) { |
156 | 156 | $ref = self::arrayGet($key, $vars); |
157 | 157 | } else { |
158 | - throw new Exception('Key not found: ' . $key); |
|
158 | + throw new Exception('Key not found: '.$key); |
|
159 | 159 | } |
160 | 160 | } elseif (is_array($ref)) { |
161 | 161 | if (self::arrayKeyExists($key, $ref)) { |
162 | 162 | $ref = $ref[$key]; |
163 | 163 | } else { |
164 | - throw new Exception('Key not found: ' . $key); |
|
164 | + throw new Exception('Key not found: '.$key); |
|
165 | 165 | } |
166 | 166 | } else { |
167 | - throw new Exception('Key not found: ' . $key); |
|
167 | + throw new Exception('Key not found: '.$key); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | return $ref; |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | if (property_exists($ref, $key)) { |
187 | 187 | $ref = &$ref->$key; |
188 | 188 | } else { |
189 | - throw new Exception('Key not found: ' . $key); |
|
189 | + throw new Exception('Key not found: '.$key); |
|
190 | 190 | } |
191 | 191 | } else { |
192 | 192 | if (array_key_exists($key, $ref)) { |
193 | 193 | $ref = &$ref[$key]; |
194 | 194 | } else { |
195 | - throw new Exception('Key not found: ' . $key); |
|
195 | + throw new Exception('Key not found: '.$key); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |