| Conditions | 5 |
| Paths | 5 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | public function pass(ClassMethod $func, Context $context) |
||
| 25 | { |
||
| 26 | $stmts = $func->getStmts(); |
||
| 27 | if ($stmts === null) { |
||
| 28 | return false; |
||
| 29 | } |
||
| 30 | |||
| 31 | $yieldExists = \PHPSA\generatorHasValue($this->findNode($stmts, Node\Expr\Yield_::class)); |
||
| 32 | if (!$yieldExists) { |
||
| 33 | // YieldFrom is another expression |
||
| 34 | $yieldExists = \PHPSA\generatorHasValue($this->findNode($stmts, Node\Expr\YieldFrom::class)); |
||
| 35 | } |
||
| 36 | |||
| 37 | if ($yieldExists && \PHPSA\generatorHasValue($this->findNode($stmts, Node\Stmt\Return_::class))) { |
||
| 38 | $context->notice('return_and_yield_in_one_method', 'Do not use return and yield in a one method', $func); |
||
| 39 | return true; |
||
| 40 | } |
||
| 41 | |||
| 42 | return false; |
||
| 43 | } |
||
| 44 | |||
| 55 |