@@ -61,6 +61,7 @@ public function __construct(
6161 private readonly DynamicThrowTypeExtensionProvider $ dynamicThrowTypeExtensionProvider ,
6262 private readonly NullsafeShortCircuitingHelper $ nullsafeShortCircuitingHelper ,
6363 private readonly MethodCallHelper $ methodCallHelper ,
64+ private readonly VoidTypeHelper $ voidTypeHelper ,
6465 #[AutowiredParameter(ref: '%exceptions.implicitThrows% ' )]
6566 private readonly bool $ implicitThrows ,
6667 )
@@ -262,9 +263,10 @@ public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, Expre
262263 }
263264
264265 return new ExprAnalysisResult (
265- $ methodReturnType ,
266- $ nativeMethodReturnType ,
267- $ scope ,
266+ $ this ->voidTypeHelper ->transformVoidToNull ($ methodReturnType ),
267+ $ this ->voidTypeHelper ->transformVoidToNull ($ nativeMethodReturnType ),
268+ keepVoidType: $ methodReturnType ,
269+ scope: $ scope ,
268270 hasYield: $ hasYield || $ argsResult ->hasYield ,
269271 isAlwaysTerminating: ($ methodReturnType instanceof NeverType && $ methodReturnType ->isExplicit ()) || $ argsResult ->isAlwaysTerminating ,
270272 throwPoints: array_merge ($ throwPoints , $ argsResult ->throwPoints ),
@@ -392,9 +394,10 @@ private function processClassExpr(Stmt $stmt, StaticCall $expr, Expr $class, Gen
392394 $ scope = $ argsResult ->scope ;
393395
394396 return new ExprAnalysisResult (
395- $ methodReturnType ,
396- $ nativeMethodReturnType ,
397- $ scope ,
397+ $ this ->voidTypeHelper ->transformVoidToNull ($ methodReturnType ),
398+ $ this ->voidTypeHelper ->transformVoidToNull ($ nativeMethodReturnType ),
399+ keepVoidType: $ methodReturnType ,
400+ scope: $ scope ,
398401 hasYield: $ hasYield || $ argsResult ->hasYield ,
399402 isAlwaysTerminating: $ isAlwaysTerminating || $ argsResult ->isAlwaysTerminating ,
400403 throwPoints: array_merge ($ throwPoints , $ argsResult ->throwPoints ),
0 commit comments