| Conditions | 5 |
| Paths | 5 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 5.0144 |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | 8 | public function pass(Node\FunctionLike $func, Context $context) |
|
| 26 | { |
||
| 27 | 8 | $stmts = $func->getStmts(); |
|
| 28 | 8 | if ($stmts === null) { |
|
| 29 | return false; |
||
| 30 | } |
||
| 31 | 8 | $yieldExists = \PHPSA\generatorHasValue($this->findYieldExpression($stmts)); |
|
| 32 | 8 | if (!$yieldExists) { |
|
| 33 | // YieldFrom is another expression |
||
| 34 | 8 | $yieldExists = \PHPSA\generatorHasValue($this->findNode($stmts, Expr\YieldFrom::class)); |
|
| 35 | 8 | } |
|
| 36 | |||
| 37 | 8 | if ($yieldExists && \PHPSA\generatorHasValue($this->findReturnStatement($stmts))) { |
|
| 38 | 1 | $context->notice('return_and_yield_in_one_method', 'Do not use return and yield in a one method', $func); |
|
|
|
|||
| 39 | 1 | return true; |
|
| 40 | } |
||
| 41 | |||
| 42 | 8 | return false; |
|
| 43 | } |
||
| 44 | |||
| 55 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: