Skip to content

Commit f525e7a

Browse files
Merge branch '5.4' into 6.2
* 5.4: Fix some phpdoc [ErrorHandler] Do not patch return statements in closures [DI] keep `proxy` tag on original definition when decorating
2 parents d2d39fa + 1471b16 commit f525e7a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

DebugClassLoader.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,20 @@ private function fixReturnStatements(\ReflectionMethod $method, string $returnTy
11291129
}
11301130

11311131
$end = $method->isGenerator() ? $i : $method->getEndLine();
1132+
$inClosure = false;
1133+
$braces = 0;
11321134
for (; $i < $end; ++$i) {
1135+
if (!$inClosure) {
1136+
$inClosure = str_contains($code[$i], 'function (');
1137+
}
1138+
1139+
if ($inClosure) {
1140+
$braces += substr_count($code[$i], '{') - substr_count($code[$i], '}');
1141+
$inClosure = $braces > 0;
1142+
1143+
continue;
1144+
}
1145+
11331146
if ('void' === $returnType) {
11341147
$fixedCode[$i] = str_replace(' return null;', ' return;', $code[$i]);
11351148
} elseif ('mixed' === $returnType || '?' === $returnType[0]) {

0 commit comments

Comments
 (0)