Skip to content

Commit f71b049

Browse files
committed
Align type hints.
1 parent 9beca45 commit f71b049

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/Helper/RoutineLoaderHelper.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,43 @@ private function updateSourceTypeHints(): void
993993
}
994994
}
995995

996+
$blocks = [];
997+
$start = null;
998+
$length = 0;
999+
foreach ($this->routineSourceCodeLines as $index => $line)
1000+
{
1001+
$n = preg_match('/--\s+type:\s+.*$/', $line, $matches);
1002+
if ($n!==0)
1003+
{
1004+
if ($start===null)
1005+
{
1006+
$start = $index;
1007+
}
1008+
$length = max($length, mb_strlen($line) - mb_strlen($matches[0]) + 2);
1009+
}
1010+
else
1011+
{
1012+
if ($start!==null)
1013+
{
1014+
$blocks[] = ['first' => $start, 'last' => $index, 'length' => $length];
1015+
$start = null;
1016+
$length = 0;
1017+
}
1018+
}
1019+
}
1020+
1021+
foreach ($blocks as $block)
1022+
{
1023+
for ($index = $block['first']; $index<$block['last']; $index++)
1024+
{
1025+
preg_match('/\s+type:\s+.*$/', $this->routineSourceCodeLines[$index], $matches);
1026+
$leftPart = mb_substr($this->routineSourceCodeLines[$index], 0, -mb_strlen($matches[0]));
1027+
$leftPart = $leftPart.str_repeat(' ', $block['length'] - mb_strlen($leftPart) + 1);
1028+
1029+
$this->routineSourceCodeLines[$index] = $leftPart.ltrim($matches[0]);
1030+
}
1031+
}
1032+
9961033
$routineSourceCode = implode(PHP_EOL, $this->routineSourceCodeLines);
9971034
if ($this->routineSourceCode!==$routineSourceCode)
9981035
{

0 commit comments

Comments
 (0)