@@ -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) |
@@ -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); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | } else { // null or array |
63 | 63 | $intKey = filter_var($key, FILTER_VALIDATE_INT); |
64 | 64 | if ($ref === null && (false === $intKey || $intKey !== 0)) { |
65 | - $key = (string)$key; |
|
65 | + $key = (string) $key; |
|
66 | 66 | if ($recursively) { |
67 | 67 | $ref = new \stdClass(); |
68 | 68 | $ref = &$ref->{$key}; |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | if (array_key_exists($key, $a)) { |
100 | 100 | return true; |
101 | 101 | } |
102 | - $key = (string)$key; |
|
102 | + $key = (string) $key; |
|
103 | 103 | foreach ($a as $k => $v) { |
104 | - if ((string)$k === $key) { |
|
104 | + if ((string) $k === $key) { |
|
105 | 105 | return true; |
106 | 106 | } |
107 | 107 | } |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | |
111 | 111 | private static function arrayGet($key, array $a) |
112 | 112 | { |
113 | - $key = (string)$key; |
|
113 | + $key = (string) $key; |
|
114 | 114 | foreach ($a as $k => $v) { |
115 | - if ((string)$k === $key) { |
|
115 | + if ((string) $k === $key) { |
|
116 | 116 | return $v; |
117 | 117 | } |
118 | 118 | } |
@@ -131,20 +131,20 @@ discard block |
||
131 | 131 | $ref = $holder; |
132 | 132 | while (null !== $key = array_shift($pathItems)) { |
133 | 133 | if ($ref instanceof \stdClass) { |
134 | - $vars = (array)$ref; |
|
134 | + $vars = (array) $ref; |
|
135 | 135 | if (self::arrayKeyExists($key, $vars)) { |
136 | 136 | $ref = self::arrayGet($key, $vars); |
137 | 137 | } else { |
138 | - throw new Exception('Key not found: ' . $key); |
|
138 | + throw new Exception('Key not found: '.$key); |
|
139 | 139 | } |
140 | 140 | } elseif (is_array($ref)) { |
141 | 141 | if (self::arrayKeyExists($key, $ref)) { |
142 | 142 | $ref = $ref[$key]; |
143 | 143 | } else { |
144 | - throw new Exception('Key not found: ' . $key); |
|
144 | + throw new Exception('Key not found: '.$key); |
|
145 | 145 | } |
146 | 146 | } else { |
147 | - throw new Exception('Key not found: ' . $key); |
|
147 | + throw new Exception('Key not found: '.$key); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | return $ref; |
@@ -166,13 +166,13 @@ discard block |
||
166 | 166 | if (property_exists($ref, $key)) { |
167 | 167 | $ref = &$ref->$key; |
168 | 168 | } else { |
169 | - throw new Exception('Key not found: ' . $key); |
|
169 | + throw new Exception('Key not found: '.$key); |
|
170 | 170 | } |
171 | 171 | } else { |
172 | 172 | if (array_key_exists($key, $ref)) { |
173 | 173 | $ref = &$ref[$key]; |
174 | 174 | } else { |
175 | - throw new Exception('Key not found: ' . $key); |
|
175 | + throw new Exception('Key not found: '.$key); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
@@ -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 { |