|
7 | 7 | use PHPUnit\Framework\Assert; |
8 | 8 | use Spatie\Snapshots\Driver; |
9 | 9 |
|
| 10 | +use function assert; |
| 11 | +use function is_string; |
10 | 12 | use function preg_replace; |
11 | 13 |
|
12 | 14 | /** |
|
15 | 17 | */ |
16 | 18 | class WindowsSafeTextDriver implements Driver |
17 | 19 | { |
18 | | - /** |
19 | | - * @param string $data |
20 | | - * |
21 | | - * @inheritDoc |
22 | | - */ |
23 | | - public function serialize($data): string |
| 20 | + public function serialize(mixed $data): string |
24 | 21 | { |
25 | | - // Save snapshot only with lf line endings. |
26 | | - $data = (string) preg_replace('/\r\n/', "\n", $data); |
| 22 | + assert(is_string($data)); |
27 | 23 |
|
28 | | - return $data; |
| 24 | + // Save snapshot only with lf line endings. |
| 25 | + return (string) preg_replace('/\R/', "\n", $data); |
29 | 26 | } |
30 | 27 |
|
31 | 28 | public function extension(): string |
32 | 29 | { |
33 | 30 | return 'txt'; |
34 | 31 | } |
35 | 32 |
|
36 | | - /** |
37 | | - * @param string $expected |
38 | | - * @param string $actual |
39 | | - * |
40 | | - * @inheritDoc |
41 | | - */ |
42 | | - public function match($expected, $actual): void |
| 33 | + public function match(mixed $expected, mixed $actual): void |
43 | 34 | { |
| 35 | + assert(is_string($expected)); |
| 36 | + |
44 | 37 | // Make sure the expected string has lf line endings, so we can |
45 | 38 | // compare accurately. |
46 | | - $expected = (string) preg_replace('/\r\n/', "\n", $expected); |
| 39 | + $expected = (string) preg_replace('/\R/', "\n", $expected); |
47 | 40 |
|
48 | 41 | Assert::assertEquals($expected, $this->serialize($actual)); |
49 | 42 | } |
|
0 commit comments