Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
21 | 34 | public function compile($stmt, Context $context) |
|
22 | { |
||
23 | 34 | $compiledExpression = $context->getExpressionCompiler()->compile($stmt->expr); |
|
|
|||
24 | |||
25 | 34 | if ($context->scopePointer) { |
|
26 | /** |
||
27 | * If it is a Class's method we need to work on return types, return possible values |
||
28 | */ |
||
29 | 34 | if ($context->scopePointer->isClassMethod()) { |
|
30 | /** @var ClassMethod $classMethod */ |
||
31 | 34 | $classMethod = $context->scopePointer->getObject(); |
|
32 | 34 | $classMethod->addNewType($compiledExpression->getType()); |
|
33 | |||
34 | 34 | if ($compiledExpression->isCorrectValue()) { |
|
35 | 34 | $classMethod->addReturnPossibleValue($compiledExpression->getValue()); |
|
36 | 34 | } |
|
37 | 34 | } |
|
38 | 34 | } |
|
39 | 34 | } |
|
40 | } |
||
41 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: