|
55 | 55 | $indentation = $noIndentation ? "" : "\t"; |
56 | 56 |
|
57 | 57 | \sort($missingIdentifiers, \SORT_NATURAL); |
58 | | -$missingIdentifiers = \array_map( |
59 | | - static fn($identifier) => "{$indentation}\t<item name=\"{$identifier}\"/>", |
60 | | - $missingIdentifiers |
61 | | -); |
62 | 58 |
|
63 | 59 | if ($hasDeleteBlock) { |
64 | 60 | // Find the position of {$indentation}<delete> and {$indentation}</delete> |
|
67 | 63 | $endTag = "\n{$indentation}</delete>\n"; |
68 | 64 | $end = \mb_strpos($data, $endTag); |
69 | 65 |
|
| 66 | + if ($start === false && $end === false) { |
| 67 | + if ($indentation === "") { |
| 68 | + $indentation = "\t"; |
| 69 | + } |
| 70 | + |
| 71 | + $startTag = "\n{$indentation}<delete>\n"; |
| 72 | + $start = \mb_strpos($data, $startTag); |
| 73 | + $endTag = "\n{$indentation}</delete>\n"; |
| 74 | + $end = \mb_strpos($data, $endTag); |
| 75 | + } |
| 76 | + |
70 | 77 | if ($start === false || $end === false) { |
71 | | - echo "Could not find the start and end positions.\n"; |
| 78 | + echo "Could not find the start (" . \get_debug_type($start) . ") and end (" . \get_debug_type($end) . ") positions.\n"; |
72 | 79 | exit(1); |
73 | 80 | } |
74 | 81 |
|
| 82 | + $missingIdentifiers = \array_map( |
| 83 | + static fn($identifier) => "{$indentation}\t<item name=\"{$identifier}\"/>", |
| 84 | + $missingIdentifiers |
| 85 | + ); |
| 86 | + |
75 | 87 | $before = \mb_substr($data, 0, $start + \mb_strlen($startTag)); |
76 | 88 | $after = \mb_substr($data, $end); |
77 | 89 |
|
|
86 | 98 | exit(1); |
87 | 99 | } |
88 | 100 |
|
| 101 | + $missingIdentifiers = \array_map( |
| 102 | + static fn($identifier) => "{$indentation}\t<item name=\"{$identifier}\"/>", |
| 103 | + $missingIdentifiers |
| 104 | + ); |
| 105 | + |
89 | 106 | $before = \mb_substr($data, 0, $end + \mb_strlen($endTag)); |
90 | 107 | $after = \mb_substr($data, $end + \mb_strlen($endTag)); |
91 | 108 |
|
|
0 commit comments