@@ -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 | } |
@@ -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); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | if ($ref instanceof \stdClass) { |
61 | 61 | $ref = &$ref->$key; |
62 | 62 | } elseif ($ref === null && false === filter_var($key, FILTER_VALIDATE_INT)) { |
63 | - $key = (string)$key; |
|
63 | + $key = (string) $key; |
|
64 | 64 | if ($recursively) { |
65 | 65 | $ref = new \stdClass(); |
66 | 66 | $ref = &$ref->{$key}; |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | if (array_key_exists($key, $a)) { |
88 | 88 | return true; |
89 | 89 | } |
90 | - $key = (string)$key; |
|
90 | + $key = (string) $key; |
|
91 | 91 | foreach ($a as $k => $v) { |
92 | - if ((string)$k === $key) { |
|
92 | + if ((string) $k === $key) { |
|
93 | 93 | return true; |
94 | 94 | } |
95 | 95 | } |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | |
99 | 99 | private static function arrayGet($key, array $a) |
100 | 100 | { |
101 | - $key = (string)$key; |
|
101 | + $key = (string) $key; |
|
102 | 102 | foreach ($a as $k => $v) { |
103 | - if ((string)$k === $key) { |
|
103 | + if ((string) $k === $key) { |
|
104 | 104 | return $v; |
105 | 105 | } |
106 | 106 | } |
@@ -119,20 +119,20 @@ discard block |
||
119 | 119 | $ref = $holder; |
120 | 120 | while (null !== $key = array_shift($pathItems)) { |
121 | 121 | if ($ref instanceof \stdClass) { |
122 | - $vars = (array)$ref; |
|
122 | + $vars = (array) $ref; |
|
123 | 123 | if (self::arrayKeyExists($key, $vars)) { |
124 | 124 | $ref = self::arrayGet($key, $vars); |
125 | 125 | } else { |
126 | - throw new Exception('Key not found: ' . $key); |
|
126 | + throw new Exception('Key not found: '.$key); |
|
127 | 127 | } |
128 | 128 | } elseif (is_array($ref)) { |
129 | 129 | if (self::arrayKeyExists($key, $ref)) { |
130 | 130 | $ref = $ref[$key]; |
131 | 131 | } else { |
132 | - throw new Exception('Key not found: ' . $key); |
|
132 | + throw new Exception('Key not found: '.$key); |
|
133 | 133 | } |
134 | 134 | } else { |
135 | - throw new Exception('Key not found: ' . $key); |
|
135 | + throw new Exception('Key not found: '.$key); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | return $ref; |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | if (property_exists($ref, $key)) { |
155 | 155 | $ref = &$ref->$key; |
156 | 156 | } else { |
157 | - throw new Exception('Key not found: ' . $key); |
|
157 | + throw new Exception('Key not found: '.$key); |
|
158 | 158 | } |
159 | 159 | } else { |
160 | 160 | if (array_key_exists($key, $ref)) { |
161 | 161 | $ref = &$ref[$key]; |
162 | 162 | } else { |
163 | - throw new Exception('Key not found: ' . $key); |
|
163 | + throw new Exception('Key not found: '.$key); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | } |
@@ -68,7 +68,9 @@ |
||
68 | 68 | throw new Exception('Non-existent path'); |
69 | 69 | } |
70 | 70 | } else { |
71 | - if ($recursively && $ref === null) $ref = array(); |
|
71 | + if ($recursively && $ref === null) { |
|
72 | + $ref = array(); |
|
73 | + } |
|
72 | 74 | if ('-' === $key) { |
73 | 75 | $ref = &$ref[]; |
74 | 76 | } else { |