@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | private function validate($content, $flags, $file = null) |
110 | 110 | { |
111 | - $prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) { |
|
111 | + $prevErrorHandler = set_error_handler(function($level, $message, $file, $line) use (&$prevErrorHandler) { |
|
112 | 112 | if (\E_USER_DEPRECATED === $level) { |
113 | 113 | throw new ParseException($message, $this->getParser()->getRealCurrentLineNb() + 1); |
114 | 114 | } |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | |
147 | 147 | foreach ($filesInfo as $info) { |
148 | 148 | if ($info['valid'] && $this->displayCorrectFiles) { |
149 | - $io->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : '')); |
|
149 | + $io->comment('<info>OK</info>' . ($info['file'] ? sprintf(' in %s', $info['file']) : '')); |
|
150 | 150 | } elseif (!$info['valid']) { |
151 | 151 | ++$erroredFiles; |
152 | - $io->text('<error> ERROR </error>'.($info['file'] ? sprintf(' in %s', $info['file']) : '')); |
|
152 | + $io->text('<error> ERROR </error>' . ($info['file'] ? sprintf(' in %s', $info['file']) : '')); |
|
153 | 153 | $io->text(sprintf('<error> >> %s</error>', $info['message'])); |
154 | 154 | } |
155 | 155 | } |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | { |
168 | 168 | $errors = 0; |
169 | 169 | |
170 | - array_walk($filesInfo, function (&$v) use (&$errors) { |
|
171 | - $v['file'] = (string) $v['file']; |
|
170 | + array_walk($filesInfo, function(&$v) use (&$errors) { |
|
171 | + $v['file'] = (string)$v['file']; |
|
172 | 172 | if (!$v['valid']) { |
173 | 173 | ++$errors; |
174 | 174 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | private function getDirectoryIterator($directory) |
226 | 226 | { |
227 | - $default = function ($directory) { |
|
227 | + $default = function($directory) { |
|
228 | 228 | return new \RecursiveIteratorIterator( |
229 | 229 | new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS), |
230 | 230 | \RecursiveIteratorIterator::LEAVES_ONLY |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | private function isReadable($fileOrDirectory) |
242 | 242 | { |
243 | - $default = function ($fileOrDirectory) { |
|
243 | + $default = function($fileOrDirectory) { |
|
244 | 244 | return is_readable($fileOrDirectory); |
245 | 245 | }; |
246 | 246 |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | |
35 | 35 | $lines = \preg_split('/(.*\R)/', $diff, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
36 | 36 | $lineCount = \count($lines); |
37 | - $lineNumber = $diffLineFromNumber = $diffLineToNumber = 1; |
|
38 | - $fromStart = $fromTillOffset = $toStart = $toTillOffset = -1; |
|
37 | + $lineNumber = $diffLineFromNumber = $diffLineToNumber = 1; |
|
38 | + $fromStart = $fromTillOffset = $toStart = $toTillOffset = -1; |
|
39 | 39 | $expectHunkHeader = true; |
40 | 40 | |
41 | 41 | // check for header |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | return [ |
271 | - (int) $matches[1], |
|
272 | - empty($matches[2]) ? 1 : (int) \substr($matches[2], 1), |
|
273 | - (int) $matches[3], |
|
274 | - empty($matches[4]) ? 1 : (int) \substr($matches[4], 1), |
|
271 | + (int)$matches[1], |
|
272 | + empty($matches[2]) ? 1 : (int)\substr($matches[2], 1), |
|
273 | + (int)$matches[3], |
|
274 | + empty($matches[4]) ? 1 : (int)\substr($matches[4], 1), |
|
275 | 275 | ]; |
276 | 276 | } |
277 | 277 | } |
@@ -89,7 +89,7 @@ |
||
89 | 89 | $dir = \realpath(__DIR__ . '/../fixtures/UnifiedDiffAssertTraitIntegrationTest'); |
90 | 90 | $dirLength = \strlen($dir); |
91 | 91 | |
92 | - for ($i = 1;; ++$i) { |
|
92 | + for ($i = 1; ; ++$i) { |
|
93 | 93 | $fromFile = \sprintf('%s/%d_a.txt', $dir, $i); |
94 | 94 | $toFile = \sprintf('%s/%d_b.txt', $dir, $i); |
95 | 95 |
@@ -74,7 +74,7 @@ |
||
74 | 74 | { |
75 | 75 | return \array_filter( |
76 | 76 | UnifiedDiffOutputBuilderDataProvider::provideDiffWithLineNumbers(), |
77 | - static function ($key) { |
|
77 | + static function($key) { |
|
78 | 78 | return !\is_string($key) || false === \strpos($key, 'non_patch_compat'); |
79 | 79 | }, |
80 | 80 | ARRAY_FILTER_USE_KEY |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | foreach ($this->stress_sizes as $size) { |
108 | 108 | $from = \range(1, $size); |
109 | - $to = \range($size + 1, $size * 2); |
|
109 | + $to = \range($size + 1, $size*2); |
|
110 | 110 | $common = $this->implementation->calculate($from, $to); |
111 | 111 | $this->assertSame([], $common); |
112 | 112 | } |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | |
115 | 115 | public function testCommonSubsequence(): void |
116 | 116 | { |
117 | - $from = ['A', 'C', 'E', 'F', 'G']; |
|
118 | - $to = ['A', 'B', 'D', 'E', 'H']; |
|
119 | - $expected = ['A', 'E']; |
|
117 | + $from = ['A', 'C', 'E', 'F', 'G']; |
|
118 | + $to = ['A', 'B', 'D', 'E', 'H']; |
|
119 | + $expected = ['A', 'E']; |
|
120 | 120 | $common = $this->implementation->calculate($from, $to); |
121 | 121 | $this->assertSame($expected, $common); |
122 | 122 | |
123 | - $from = ['A', 'C', 'E', 'F', 'G']; |
|
124 | - $to = ['B', 'C', 'D', 'E', 'F', 'H']; |
|
125 | - $expected = ['C', 'E', 'F']; |
|
123 | + $from = ['A', 'C', 'E', 'F', 'G']; |
|
124 | + $to = ['B', 'C', 'D', 'E', 'F', 'H']; |
|
125 | + $expected = ['C', 'E', 'F']; |
|
126 | 126 | $common = $this->implementation->calculate($from, $to); |
127 | 127 | $this->assertSame($expected, $common); |
128 | 128 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | { |
152 | 152 | foreach ($this->stress_sizes as $size) { |
153 | 153 | $from = \range(1, $size); |
154 | - $to = \array_slice($from, (int) ($size / 2), 1); |
|
154 | + $to = \array_slice($from, (int)($size/2), 1); |
|
155 | 155 | $common = $this->implementation->calculate($from, $to); |
156 | 156 | |
157 | 157 | $this->assertSame($to, $common); |
@@ -72,10 +72,10 @@ |
||
72 | 72 | foreach ($lines as $line) { |
73 | 73 | if (\preg_match('/^@@\s+-(?P<start>\d+)(?:,\s*(?P<startrange>\d+))?\s+\+(?P<end>\d+)(?:,\s*(?P<endrange>\d+))?\s+@@/', $line, $match)) { |
74 | 74 | $chunk = new Chunk( |
75 | - (int) $match['start'], |
|
76 | - isset($match['startrange']) ? \max(1, (int) $match['startrange']) : 1, |
|
77 | - (int) $match['end'], |
|
78 | - isset($match['endrange']) ? \max(1, (int) $match['endrange']) : 1 |
|
75 | + (int)$match['start'], |
|
76 | + isset($match['startrange']) ? \max(1, (int)$match['startrange']) : 1, |
|
77 | + (int)$match['end'], |
|
78 | + isset($match['endrange']) ? \max(1, (int)$match['endrange']) : 1 |
|
79 | 79 | ); |
80 | 80 | |
81 | 81 | $chunks[] = $chunk; |
@@ -32,7 +32,7 @@ |
||
32 | 32 | return []; |
33 | 33 | } |
34 | 34 | |
35 | - $i = (int) ($cFrom / 2); |
|
35 | + $i = (int)($cFrom/2); |
|
36 | 36 | $fromStart = \array_slice($from, 0, $i); |
37 | 37 | $fromEnd = \array_slice($from, $i); |
38 | 38 | $llB = $this->length($fromStart, $to); |
@@ -22,8 +22,8 @@ |
||
22 | 22 | { |
23 | 23 | private static $default = [ |
24 | 24 | 'collapseRanges' => true, // ranges of length one are rendered with the trailing `,1` |
25 | - 'commonLineThreshold' => 6, // number of same lines before ending a new hunk and creating a new one (if needed) |
|
26 | - 'contextLines' => 3, // like `diff: -u, -U NUM, --unified[=NUM]`, for patch/git apply compatibility best to keep at least @ 3 |
|
25 | + 'commonLineThreshold' => 6, // number of same lines before ending a new hunk and creating a new one (if needed) |
|
26 | + 'contextLines' => 3, // like `diff: -u, -U NUM, --unified[=NUM]`, for patch/git apply compatibility best to keep at least @ 3 |
|
27 | 27 | 'fromFile' => null, |
28 | 28 | 'fromFileDate' => null, |
29 | 29 | 'toFile' => null, |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | private function normalizeDiffInput($input) |
167 | 167 | { |
168 | 168 | if (!\is_array($input) && !\is_string($input)) { |
169 | - return (string) $input; |
|
169 | + return (string)$input; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | return $input; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | // footprint will probably exceed this value. Note that the footprint |
197 | 197 | // calculation is only an estimation for the matrix and the LCS method |
198 | 198 | // will typically allocate a bit more memory than this. |
199 | - $memoryLimit = 100 * 1024 * 1024; |
|
199 | + $memoryLimit = 100*1024*1024; |
|
200 | 200 | |
201 | 201 | if ($this->calculateEstimatedFootprint($from, $to) > $memoryLimit) { |
202 | 202 | return new MemoryEfficientLongestCommonSubsequenceCalculator; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | { |
218 | 218 | $itemSize = PHP_INT_SIZE === 4 ? 76 : 144; |
219 | 219 | |
220 | - return $itemSize * \min(\count($from), \count($to)) ** 2; |
|
220 | + return $itemSize*\min(\count($from), \count($to)) ** 2; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |