diff --git a/src/Class/Method/Method.php b/src/Class/Method/Method.php index 1b68b3f96..92a4c40c7 100644 --- a/src/Class/Method/Method.php +++ b/src/Class/Method/Method.php @@ -1847,7 +1847,8 @@ public function compile(CompilationContext $compilationContext): void */ if ( 'return' !== $lastType && - 'throw' !== $lastType && !$this->hasChildReturnStatementType($statement) && + 'throw' !== $lastType && + !$this->hasChildReturnStatementType($statement) && $this->hasReturnTypes() ) { throw new CompilerException(