|
13 | 13 | use const PREG_SPLIT_DELIM_CAPTURE;
|
14 | 14 | use const PREG_SPLIT_NO_EMPTY;
|
15 | 15 | use function array_filter;
|
| 16 | +use function assert; |
16 | 17 | use function file_put_contents;
|
17 | 18 | use function implode;
|
| 19 | +use function is_array; |
18 | 20 | use function is_string;
|
19 | 21 | use function preg_replace;
|
20 | 22 | use function preg_split;
|
@@ -43,6 +45,15 @@ final class UnifiedDiffOutputBuilderIntegrationTest extends TestCase
|
43 | 45 | private string $fileFrom;
|
44 | 46 | private string $filePatch;
|
45 | 47 |
|
| 48 | + /** |
| 49 | + * @return array{ |
| 50 | + * string?: array{ |
| 51 | + * 0: string, |
| 52 | + * 1: string, |
| 53 | + * 2: string, |
| 54 | + * }, |
| 55 | + * } |
| 56 | + */ |
46 | 57 | public static function provideDiffWithLineNumbers(): array
|
47 | 58 | {
|
48 | 59 | return array_filter(
|
@@ -70,15 +81,15 @@ protected function tearDown(): void
|
70 | 81 | }
|
71 | 82 |
|
72 | 83 | #[DataProvider('provideDiffWithLineNumbers')]
|
73 |
| - public function testDiffWithLineNumbersPath($expected, $from, $to): void |
| 84 | + public function testDiffWithLineNumbersPath(string $expected, string $from, string $to): void |
74 | 85 | {
|
75 | 86 | $this->doIntegrationTestPatch($expected, $from, $to);
|
76 | 87 | }
|
77 | 88 |
|
78 | 89 | #[DataProvider('provideDiffWithLineNumbers')]
|
79 |
| - public function testDiffWithLineNumbersGitApply($expected, $from, $to): void |
| 90 | + public function testDiffWithLineNumbersGitApply(string $expected, string $from): void |
80 | 91 | {
|
81 |
| - $this->doIntegrationTestGitApply($expected, $from, $to); |
| 92 | + $this->doIntegrationTestGitApply($expected, $from); |
82 | 93 | }
|
83 | 94 |
|
84 | 95 | private function doIntegrationTestPatch(string $diff, string $from, string $to): void
|
@@ -109,7 +120,7 @@ private function doIntegrationTestPatch(string $diff, string $from, string $to):
|
109 | 120 | );
|
110 | 121 | }
|
111 | 122 |
|
112 |
| - private function doIntegrationTestGitApply(string $diff, string $from, string $to): void |
| 123 | + private function doIntegrationTestGitApply(string $diff, string $from): void |
113 | 124 | {
|
114 | 125 | $this->assertNotSame('', $diff);
|
115 | 126 | $this->assertValidUnifiedDiffFormat($diff);
|
@@ -154,7 +165,9 @@ private function cleanUpTempFiles(): void
|
154 | 165 |
|
155 | 166 | private static function setDiffFileHeader(string $diff, string $file): string
|
156 | 167 | {
|
157 |
| - $diffLines = preg_split('/(.*\R)/', $diff, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 168 | + $diffLines = preg_split('/(.*\R)/', $diff, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 169 | + assert(is_array($diffLines)); |
| 170 | + |
158 | 171 | $diffLines[0] = preg_replace('#^\-\-\- .*#', '--- /' . $file, $diffLines[0], 1);
|
159 | 172 | $diffLines[1] = preg_replace('#^\+\+\+ .*#', '+++ /' . $file, $diffLines[1], 1);
|
160 | 173 |
|
|
0 commit comments