@@ -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 | } |
@@ -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 | } |
@@ -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) |