Skip to content

Commit

Permalink
Fix #428
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Oct 2, 2023
1 parent eac06e3 commit f50a89f
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/Utility/Reflection/DocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,28 @@ private static function sanitizeDocComment(string|false $doc): ?string
*/
private static function splitStringBy(string $string, string ...$cases): array
{
$result = [$string];

foreach ($cases as $case) {
foreach ($result as $value) {
$result = array_merge($result, explode($case, $value));
$result = [];
$pos = 0;
do {
$next = false;
$len = 0;
foreach ($cases as $case) {
$tentative = strpos($string, $case, $pos);
if ($tentative === false) {
continue;
}
if ($next === false || $tentative < $next) {
$len = strlen($case);
$next = $tentative;
}
}
}
if ($next === false) {
break;
}
$result []= substr($string, $pos, $next-$pos);
$pos = $next+$len;
} while (true);
$result []= substr($string, $pos);

return $result;
}
Expand Down

0 comments on commit f50a89f

Please sign in to comment.