@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | } else { |
| 38 | 38 | if ($first !== '') { |
| 39 | - throw new Exception('Path must start with "/": ' . $path); |
|
| 39 | + throw new Exception('Path must start with "/": '.$path); |
|
| 40 | 40 | } |
| 41 | 41 | foreach ($pathItems as $key) { |
| 42 | 42 | $key = str_replace(array('~1', '~0'), array('/', '~'), $key); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | && !is_int($key) |
| 65 | 65 | && false === filter_var($key, FILTER_VALIDATE_INT) |
| 66 | 66 | ) { |
| 67 | - $key = (string)$key; |
|
| 67 | + $key = (string) $key; |
|
| 68 | 68 | if ($recursively) { |
| 69 | 69 | $ref = new \stdClass(); |
| 70 | 70 | $ref = &$ref->{$key}; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | if ('-' === $key) { |
| 80 | 80 | $ref = &$ref[]; |
| 81 | 81 | } else { |
| 82 | - $key = (int)$key; |
|
| 82 | + $key = (int) $key; |
|
| 83 | 83 | if (is_array($ref) && array_key_exists($key, $ref) && !$pathItems) { |
| 84 | 84 | array_splice($ref, $key, 0, array($value)); |
| 85 | 85 | } |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | if (array_key_exists($key, $a)) { |
| 96 | 96 | return true; |
| 97 | 97 | } |
| 98 | - $key = (string)$key; |
|
| 98 | + $key = (string) $key; |
|
| 99 | 99 | foreach ($a as $k => $v) { |
| 100 | - if ((string)$k === $key) { |
|
| 100 | + if ((string) $k === $key) { |
|
| 101 | 101 | return true; |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | private static function arrayGet($key, array $a) |
| 108 | 108 | { |
| 109 | - $key = (string)$key; |
|
| 109 | + $key = (string) $key; |
|
| 110 | 110 | foreach ($a as $k => $v) { |
| 111 | - if ((string)$k === $key) { |
|
| 111 | + if ((string) $k === $key) { |
|
| 112 | 112 | return $v; |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -127,20 +127,20 @@ discard block |
||
| 127 | 127 | $ref = $holder; |
| 128 | 128 | while (null !== $key = array_shift($pathItems)) { |
| 129 | 129 | if ($ref instanceof \stdClass) { |
| 130 | - $vars = (array)$ref; |
|
| 130 | + $vars = (array) $ref; |
|
| 131 | 131 | if (self::arrayKeyExists($key, $vars)) { |
| 132 | 132 | $ref = self::arrayGet($key, $vars); |
| 133 | 133 | } else { |
| 134 | - throw new Exception('Key not found: ' . $key); |
|
| 134 | + throw new Exception('Key not found: '.$key); |
|
| 135 | 135 | } |
| 136 | 136 | } elseif (is_array($ref)) { |
| 137 | 137 | if (self::arrayKeyExists($key, $ref)) { |
| 138 | 138 | $ref = $ref[$key]; |
| 139 | 139 | } else { |
| 140 | - throw new Exception('Key not found: ' . $key); |
|
| 140 | + throw new Exception('Key not found: '.$key); |
|
| 141 | 141 | } |
| 142 | 142 | } else { |
| 143 | - throw new Exception('Key not found: ' . $key); |
|
| 143 | + throw new Exception('Key not found: '.$key); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | return $ref; |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | if (property_exists($ref, $key)) { |
| 163 | 163 | $ref = &$ref->$key; |
| 164 | 164 | } else { |
| 165 | - throw new Exception('Key not found: ' . $key); |
|
| 165 | + throw new Exception('Key not found: '.$key); |
|
| 166 | 166 | } |
| 167 | 167 | } else { |
| 168 | 168 | if (array_key_exists($key, $ref)) { |
| 169 | 169 | $ref = &$ref[$key]; |
| 170 | 170 | } else { |
| 171 | - throw new Exception('Key not found: ' . $key); |
|
| 171 | + throw new Exception('Key not found: '.$key); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -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 | } |