@@ -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 |
@@ -132,7 +132,9 @@ |
||
| 132 | 132 | $ref = new \stdClass(); |
| 133 | 133 | $ref = &$ref->{$key}; |
| 134 | 134 | } else { |
| 135 | - if ($flags & self::RECURSIVE_KEY_CREATION && $ref === null) $ref = array(); |
|
| 135 | + if ($flags & self::RECURSIVE_KEY_CREATION && $ref === null) { |
|
| 136 | + $ref = array(); |
|
| 137 | + } |
|
| 136 | 138 | if ('-' === $key) { |
| 137 | 139 | $ref = &$ref[count($ref)]; |
| 138 | 140 | } else { |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | $result = $isURIFragmentId ? '#' : ''; |
| 50 | 50 | foreach ($pathItems as $pathItem) { |
| 51 | - $result .= '/' . self::escapeSegment($pathItem, $isURIFragmentId); |
|
| 51 | + $result .= '/'.self::escapeSegment($pathItem, $isURIFragmentId); |
|
| 52 | 52 | } |
| 53 | 53 | return $result; |
| 54 | 54 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | return self::splitPathURIFragment($pathItems); |
| 67 | 67 | } else { |
| 68 | 68 | if ($first !== '') { |
| 69 | - throw new JsonPointerException('Path must start with "/": ' . $path); |
|
| 69 | + throw new JsonPointerException('Path must start with "/": '.$path); |
|
| 70 | 70 | } |
| 71 | 71 | return self::splitPathJsonString($pathItems); |
| 72 | 72 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $ref = &$ref->$key; |
| 114 | 114 | } else { |
| 115 | 115 | if (!isset($ref->$key) && count($pathItems)) { |
| 116 | - throw new JsonPointerException('Non-existent path item: ' . $key); |
|
| 116 | + throw new JsonPointerException('Non-existent path item: '.$key); |
|
| 117 | 117 | } else { |
| 118 | 118 | $ref = &$ref->$key; |
| 119 | 119 | } |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | } else { // null or array |
| 122 | 122 | $intKey = filter_var($key, FILTER_VALIDATE_INT); |
| 123 | 123 | if ($ref === null && (false === $intKey || $intKey !== 0)) { |
| 124 | - $key = (string)$key; |
|
| 124 | + $key = (string) $key; |
|
| 125 | 125 | if ($flags & self::RECURSIVE_KEY_CREATION) { |
| 126 | 126 | $ref = new \stdClass(); |
| 127 | 127 | $ref = &$ref->{$key}; |
| 128 | 128 | } else { |
| 129 | - throw new JsonPointerException('Non-existent path item: ' . $key); |
|
| 129 | + throw new JsonPointerException('Non-existent path item: '.$key); |
|
| 130 | 130 | } |
| 131 | 131 | } elseif ([] === $ref && 0 === ($flags & self::STRICT_MODE) && false === $intKey && '-' !== $key) { |
| 132 | 132 | $ref = new \stdClass(); |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | if (array_key_exists($key, $a)) { |
| 171 | 171 | return true; |
| 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 true; |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -181,9 +181,9 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | private static function arrayGet($key, array $a) |
| 183 | 183 | { |
| 184 | - $key = (string)$key; |
|
| 184 | + $key = (string) $key; |
|
| 185 | 185 | foreach ($a as $k => $v) { |
| 186 | - if ((string)$k === $key) { |
|
| 186 | + if ((string) $k === $key) { |
|
| 187 | 187 | return $v; |
| 188 | 188 | } |
| 189 | 189 | } |
@@ -207,26 +207,26 @@ discard block |
||
| 207 | 207 | Exception::EMPTY_PROPERTY_NAME_UNSUPPORTED); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - $vars = (array)$ref; |
|
| 210 | + $vars = (array) $ref; |
|
| 211 | 211 | if (self::arrayKeyExists($key, $vars)) { |
| 212 | 212 | $ref = self::arrayGet($key, $vars); |
| 213 | 213 | } else { |
| 214 | - throw new JsonPointerException('Key not found: ' . $key); |
|
| 214 | + throw new JsonPointerException('Key not found: '.$key); |
|
| 215 | 215 | } |
| 216 | 216 | } elseif (is_array($ref)) { |
| 217 | 217 | if (self::arrayKeyExists($key, $ref)) { |
| 218 | 218 | $ref = $ref[$key]; |
| 219 | 219 | } else { |
| 220 | - throw new JsonPointerException('Key not found: ' . $key); |
|
| 220 | + throw new JsonPointerException('Key not found: '.$key); |
|
| 221 | 221 | } |
| 222 | 222 | } elseif (is_object($ref)) { |
| 223 | 223 | if (isset($ref->$key)) { |
| 224 | 224 | $ref = $ref->$key; |
| 225 | 225 | } else { |
| 226 | - throw new JsonPointerException('Key not found: ' . $key); |
|
| 226 | + throw new JsonPointerException('Key not found: '.$key); |
|
| 227 | 227 | } |
| 228 | 228 | } else { |
| 229 | - throw new JsonPointerException('Key not found: ' . $key); |
|
| 229 | + throw new JsonPointerException('Key not found: '.$key); |
|
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | return $ref; |
@@ -260,19 +260,19 @@ discard block |
||
| 260 | 260 | if (property_exists($ref, $key)) { |
| 261 | 261 | $ref = &$ref->$key; |
| 262 | 262 | } else { |
| 263 | - throw new JsonPointerException('Key not found: ' . $key); |
|
| 263 | + throw new JsonPointerException('Key not found: '.$key); |
|
| 264 | 264 | } |
| 265 | 265 | } elseif (is_object($ref)) { |
| 266 | 266 | if (isset($ref->$key)) { |
| 267 | 267 | $ref = &$ref->$key; |
| 268 | 268 | } else { |
| 269 | - throw new JsonPointerException('Key not found: ' . $key); |
|
| 269 | + throw new JsonPointerException('Key not found: '.$key); |
|
| 270 | 270 | } |
| 271 | 271 | } else { |
| 272 | 272 | if (array_key_exists($key, $ref)) { |
| 273 | 273 | $ref = &$ref[$key]; |
| 274 | 274 | } else { |
| 275 | - throw new JsonPointerException('Key not found: ' . $key); |
|
| 275 | + throw new JsonPointerException('Key not found: '.$key); |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | unset($parent[$refKey]); |
| 296 | - if (!$isAssociative && (int)$refKey !== count($parent)) { |
|
| 296 | + if (!$isAssociative && (int) $refKey !== count($parent)) { |
|
| 297 | 297 | $parent = array_values($parent); |
| 298 | 298 | } |
| 299 | 299 | } |
@@ -256,11 +256,11 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | if ($this->options & self::TOLERATE_ASSOCIATIVE_ARRAYS) { |
| 258 | 258 | if (is_array($original) && !empty($original) && !array_key_exists(0, $original)) { |
| 259 | - $original = (object)$original; |
|
| 259 | + $original = (object) $original; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | if (is_array($new) && !empty($new) && !array_key_exists(0, $new)) { |
| 263 | - $new = (object)$new; |
|
| 263 | + $new = (object) $new; |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | JsonPointer::add($this->merge, $this->pathItems, $new); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - $isUriFragment = (bool)($this->options & self::JSON_URI_FRAGMENT_ID); |
|
| 319 | + $isUriFragment = (bool) ($this->options & self::JSON_URI_FRAGMENT_ID); |
|
| 320 | 320 | $diffCnt = $this->addedCnt + $this->modifiedCnt + $this->removedCnt; |
| 321 | 321 | foreach ($originalKeys as $key => $originalValue) { |
| 322 | 322 | if ($this->options & self::STOP_ON_DIFF) { |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | if ($isArray && is_int($actualKey)) { |
| 332 | 332 | $actualKey -= $removedOffset; |
| 333 | 333 | } |
| 334 | - $this->path .= '/' . JsonPointer::escapeSegment((string)$actualKey, $isUriFragment); |
|
| 334 | + $this->path .= '/'.JsonPointer::escapeSegment((string) $actualKey, $isUriFragment); |
|
| 335 | 335 | $this->pathItems[] = $actualKey; |
| 336 | 336 | |
| 337 | 337 | if (array_key_exists($key, $newArray)) { |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | return null; |
| 373 | 373 | } |
| 374 | 374 | $newOrdered[$key] = $value; |
| 375 | - $path = $this->path . '/' . JsonPointer::escapeSegment($key, $isUriFragment); |
|
| 375 | + $path = $this->path.'/'.JsonPointer::escapeSegment($key, $isUriFragment); |
|
| 376 | 376 | $pathItems = $this->pathItems; |
| 377 | 377 | $pathItems[] = $key; |
| 378 | 378 | JsonPointer::add($this->added, $pathItems, $value); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - return is_array($new) ? $newOrdered : (object)$newOrdered; |
|
| 391 | + return is_array($new) ? $newOrdered : (object) $newOrdered; |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | |
| 522 | 522 | $newRearranged[$j] = $new[$i]; |
| 523 | 523 | } else { |
| 524 | - $changedItems []= $new[$i]; |
|
| 524 | + $changedItems [] = $new[$i]; |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | $xorHash = ''; |
| 22 | 22 | |
| 23 | 23 | if (!$data instanceof \stdClass && !is_array($data)) { |
| 24 | - $s = $path . (string)$data; |
|
| 24 | + $s = $path.(string) $data; |
|
| 25 | 25 | if (strlen($xorHash) < strlen($s)) { |
| 26 | 26 | $xorHash = str_pad($xorHash, strlen($s)); |
| 27 | 27 | } |
@@ -32,15 +32,15 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | if ($this->options & JsonDiff::TOLERATE_ASSOCIATIVE_ARRAYS) { |
| 34 | 34 | if (is_array($data) && !empty($data) && !array_key_exists(0, $data)) { |
| 35 | - $data = (object)$data; |
|
| 35 | + $data = (object) $data; |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | if (is_array($data)) { |
| 40 | 40 | if ($this->options & JsonDiff::REARRANGE_ARRAYS) { |
| 41 | 41 | foreach ($data as $key => $item) { |
| 42 | - $itemPath = $path . '/' . $key; |
|
| 43 | - $itemHash = $path . $this->xorHash($item, $itemPath); |
|
| 42 | + $itemPath = $path.'/'.$key; |
|
| 43 | + $itemHash = $path.$this->xorHash($item, $itemPath); |
|
| 44 | 44 | if (strlen($xorHash) < strlen($itemHash)) { |
| 45 | 45 | $xorHash = str_pad($xorHash, strlen($itemHash)); |
| 46 | 46 | } |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | } else { |
| 50 | 50 | foreach ($data as $key => $item) { |
| 51 | - $itemPath = $path . '/' . $key; |
|
| 52 | - $itemHash = md5($itemPath . $this->xorHash($item, $itemPath), true); |
|
| 51 | + $itemPath = $path.'/'.$key; |
|
| 52 | + $itemHash = md5($itemPath.$this->xorHash($item, $itemPath), true); |
|
| 53 | 53 | if (strlen($xorHash) < strlen($itemHash)) { |
| 54 | 54 | $xorHash = str_pad($xorHash, strlen($itemHash)); |
| 55 | 55 | } |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $dataKeys = get_object_vars($data); |
| 64 | 64 | foreach ($dataKeys as $key => $value) { |
| 65 | - $propertyPath = $path . '/' . |
|
| 66 | - JsonPointer::escapeSegment($key, (bool)($this->options & JsonDiff::JSON_URI_FRAGMENT_ID)); |
|
| 67 | - $propertyHash = $propertyPath . md5($key, true) . $this->xorHash($value, $propertyPath); |
|
| 65 | + $propertyPath = $path.'/'. |
|
| 66 | + JsonPointer::escapeSegment($key, (bool) ($this->options & JsonDiff::JSON_URI_FRAGMENT_ID)); |
|
| 67 | + $propertyHash = $propertyPath.md5($key, true).$this->xorHash($value, $propertyPath); |
|
| 68 | 68 | if (strlen($xorHash) < strlen($propertyHash)) { |
| 69 | 69 | $xorHash = str_pad($xorHash, strlen($propertyHash)); |
| 70 | 70 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | ) |
| 23 | 23 | { |
| 24 | 24 | // @phpstan-ignore-next-line MissingFieldOperation will be thrown if op is not set |
| 25 | - parent::__construct('Unknown "op": ' . $operation->op, $code, $previous); |
|
| 25 | + parent::__construct('Unknown "op": '.$operation->op, $code, $previous); |
|
| 26 | 26 | $this->operation = $operation; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -25,8 +25,8 @@ |
||
| 25 | 25 | Throwable $previous = null |
| 26 | 26 | ) |
| 27 | 27 | { |
| 28 | - parent::__construct('Test operation ' . json_encode($operation, JSON_UNESCAPED_SLASHES) |
|
| 29 | - . ' failed: ' . json_encode($actualValue), $code, $previous); |
|
| 28 | + parent::__construct('Test operation '.json_encode($operation, JSON_UNESCAPED_SLASHES) |
|
| 29 | + . ' failed: '.json_encode($actualValue), $code, $previous); |
|
| 30 | 30 | $this->operation = $operation; |
| 31 | 31 | $this->actualValue = $actualValue; |
| 32 | 32 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | Throwable $previous = null |
| 25 | 25 | ) |
| 26 | 26 | { |
| 27 | - parent::__construct('Missing "' . $missingField . '" in operation data', $code, $previous); |
|
| 27 | + parent::__construct('Missing "'.$missingField.'" in operation data', $code, $previous); |
|
| 28 | 28 | $this->missingField = $missingField; |
| 29 | 29 | $this->operation = $operation; |
| 30 | 30 | } |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | ) |
| 32 | 32 | { |
| 33 | 33 | parent::__construct( |
| 34 | - 'Invalid field type - "' . $field . '" should be of type: ' . $expectedType, |
|
| 34 | + 'Invalid field type - "'.$field.'" should be of type: '.$expectedType, |
|
| 35 | 35 | $code, |
| 36 | 36 | $previous |
| 37 | 37 | ); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | foreach ($data as $operation) { |
| 58 | 58 | /** @var OpPath|OpPathValue|OpPathFrom|array $operation */ |
| 59 | 59 | if (is_array($operation)) { |
| 60 | - $operation = (object)$operation; |
|
| 60 | + $operation = (object) $operation; |
|
| 61 | 61 | } |
| 62 | 62 | if (!is_object($operation)) { |
| 63 | 63 | throw new Exception('Invalid patch operation - should be a JSON object'); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | { |
| 125 | 125 | $result = array(); |
| 126 | 126 | foreach ($patch->operations as $operation) { |
| 127 | - $result[] = (object)(array)$operation; |
|
| 127 | + $result[] = (object) (array) $operation; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | return $result; |