File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -993,6 +993,43 @@ private function updateSourceTypeHints(): void
993
993
}
994
994
}
995
995
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
+
996
1033
$ routineSourceCode = implode (PHP_EOL , $ this ->routineSourceCodeLines );
997
1034
if ($ this ->routineSourceCode !==$ routineSourceCode )
998
1035
{
You can’t perform that action at this time.
0 commit comments