@@ -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 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $result = $isURIFragmentId ? '#' : ''; |
| 40 | 40 | foreach ($pathItems as $pathItem) { |
| 41 | - $result .= '/' . self::escapeSegment($pathItem, $isURIFragmentId); |
|
| 41 | + $result .= '/'.self::escapeSegment($pathItem, $isURIFragmentId); |
|
| 42 | 42 | } |
| 43 | 43 | return $result; |
| 44 | 44 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | return self::splitPathURIFragment($pathItems); |
| 57 | 57 | } else { |
| 58 | 58 | if ($first !== '') { |
| 59 | - throw new Exception('Path must start with "/": ' . $path); |
|
| 59 | + throw new Exception('Path must start with "/": '.$path); |
|
| 60 | 60 | } |
| 61 | 61 | return self::splitPathJsonString($pathItems); |
| 62 | 62 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $ref = &$ref->$key; |
| 104 | 104 | } else { |
| 105 | 105 | if (!isset($ref->$key) && count($pathItems)) { |
| 106 | - throw new Exception('Non-existent path item: ' . $key); |
|
| 106 | + throw new Exception('Non-existent path item: '.$key); |
|
| 107 | 107 | } else { |
| 108 | 108 | $ref = &$ref->$key; |
| 109 | 109 | } |
@@ -111,12 +111,12 @@ discard block |
||
| 111 | 111 | } else { // null or array |
| 112 | 112 | $intKey = filter_var($key, FILTER_VALIDATE_INT); |
| 113 | 113 | if ($ref === null && (false === $intKey || $intKey !== 0)) { |
| 114 | - $key = (string)$key; |
|
| 114 | + $key = (string) $key; |
|
| 115 | 115 | if ($flags & self::RECURSIVE_KEY_CREATION) { |
| 116 | 116 | $ref = new \stdClass(); |
| 117 | 117 | $ref = &$ref->{$key}; |
| 118 | 118 | } else { |
| 119 | - throw new Exception('Non-existent path item: ' . $key); |
|
| 119 | + throw new Exception('Non-existent path item: '.$key); |
|
| 120 | 120 | } |
| 121 | 121 | } elseif ([] === $ref && 0 === ($flags & self::STRICT_MODE) && false === $intKey && '-' !== $key) { |
| 122 | 122 | $ref = new \stdClass(); |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | if (array_key_exists($key, $a)) { |
| 152 | 152 | return true; |
| 153 | 153 | } |
| 154 | - $key = (string)$key; |
|
| 154 | + $key = (string) $key; |
|
| 155 | 155 | foreach ($a as $k => $v) { |
| 156 | - if ((string)$k === $key) { |
|
| 156 | + if ((string) $k === $key) { |
|
| 157 | 157 | return true; |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | private static function arrayGet($key, array $a) |
| 164 | 164 | { |
| 165 | - $key = (string)$key; |
|
| 165 | + $key = (string) $key; |
|
| 166 | 166 | foreach ($a as $k => $v) { |
| 167 | - if ((string)$k === $key) { |
|
| 167 | + if ((string) $k === $key) { |
|
| 168 | 168 | return $v; |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -188,20 +188,20 @@ discard block |
||
| 188 | 188 | Exception::EMPTY_PROPERTY_NAME_UNSUPPORTED); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - $vars = (array)$ref; |
|
| 191 | + $vars = (array) $ref; |
|
| 192 | 192 | if (self::arrayKeyExists($key, $vars)) { |
| 193 | 193 | $ref = self::arrayGet($key, $vars); |
| 194 | 194 | } else { |
| 195 | - throw new Exception('Key not found: ' . $key); |
|
| 195 | + throw new Exception('Key not found: '.$key); |
|
| 196 | 196 | } |
| 197 | 197 | } elseif (is_array($ref)) { |
| 198 | 198 | if (self::arrayKeyExists($key, $ref)) { |
| 199 | 199 | $ref = $ref[$key]; |
| 200 | 200 | } else { |
| 201 | - throw new Exception('Key not found: ' . $key); |
|
| 201 | + throw new Exception('Key not found: '.$key); |
|
| 202 | 202 | } |
| 203 | 203 | } else { |
| 204 | - throw new Exception('Key not found: ' . $key); |
|
| 204 | + throw new Exception('Key not found: '.$key); |
|
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | return $ref; |
@@ -234,13 +234,13 @@ discard block |
||
| 234 | 234 | if (property_exists($ref, $key)) { |
| 235 | 235 | $ref = &$ref->$key; |
| 236 | 236 | } else { |
| 237 | - throw new Exception('Key not found: ' . $key); |
|
| 237 | + throw new Exception('Key not found: '.$key); |
|
| 238 | 238 | } |
| 239 | 239 | } else { |
| 240 | 240 | if (array_key_exists($key, $ref)) { |
| 241 | 241 | $ref = &$ref[$key]; |
| 242 | 242 | } else { |
| 243 | - throw new Exception('Key not found: ' . $key); |
|
| 243 | + throw new Exception('Key not found: '.$key); |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | } |
@@ -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 { |