Skip to content

Commit c915bac

Browse files
committed
Replace return with yield when docComments shows return value is a Generator
1 parent e13e5eb commit c915bac

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/AspectMock/Intercept/BeforeMockTransformer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ public function transform(StreamMetaData $metadata)
8080
$beforeDefinition = $method->isStatic()
8181
? $this->beforeStatic
8282
: $this->before;
83+
// replace return with yield when doccomment shows it returns a Generator
84+
if(stripos($method->getDocComment(), '@return \Generator') !== false) {
85+
$beforeDefinition = str_replace('return', 'yield', $beforeDefinition);
86+
}
8387
$reflectedParams = $method->getParameters();
8488

8589
$params = [];

0 commit comments

Comments
 (0)