|
15 | 15 | use function preg_match;
|
16 | 16 | use function preg_split;
|
17 | 17 | use function sprintf;
|
| 18 | +use function str_starts_with; |
18 | 19 | use function strlen;
|
19 |
| -use function strpos; |
20 | 20 | use function substr;
|
21 | 21 | use RuntimeException;
|
22 | 22 | use UnexpectedValueException;
|
@@ -52,8 +52,8 @@ public function assertValidUnifiedDiffFormat(string $diff): void
|
52 | 52 | $this->unifiedDiffAssertLinePrefix($lines[0], 'Line 1.');
|
53 | 53 | $this->unifiedDiffAssertLinePrefix($lines[1], 'Line 2.');
|
54 | 54 |
|
55 |
| - if ('---' === substr($lines[0], 0, 3)) { |
56 |
| - if ('+++' !== substr($lines[1], 0, 3)) { |
| 55 | + if (str_starts_with($lines[0], '---')) { |
| 56 | + if (!str_starts_with($lines[1], '+++')) { |
57 | 57 | throw new UnexpectedValueException(sprintf("Line 1 indicates a header, so line 2 must start with \"+++\".\nLine 1: \"%s\"\nLine 2: \"%s\".", $lines[0], $lines[1]));
|
58 | 58 | }
|
59 | 59 |
|
@@ -211,7 +211,7 @@ private function unifiedDiffAssertStrLength(string $line, int $min, string $mess
|
211 | 211 | */
|
212 | 212 | private function unifiedDiffAssertHeaderLine(string $line, string $start, string $message): void
|
213 | 213 | {
|
214 |
| - if (0 !== strpos($line, $start)) { |
| 214 | + if (!str_starts_with($line, $start)) { |
215 | 215 | throw new UnexpectedValueException(sprintf('Expected header line to start with "%s", got "%s". %s', $start . ' ', $line, $message));
|
216 | 216 | }
|
217 | 217 |
|
|
0 commit comments