These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Tests\PHPSA\Compiler\Statement; |
||
4 | |||
5 | use PhpParser\Node; |
||
6 | use PHPSA\Variable; |
||
7 | |||
8 | class ElseIfTest extends \Tests\PHPSA\TestCase |
||
9 | { |
||
10 | /** |
||
11 | * Tests if (1 == 2) { } elseif( 1 == 1) { $stmtTest = 2; } creates the variable |
||
12 | */ |
||
13 | public function testIfElseIfCreatesVar() |
||
14 | { |
||
15 | $context = $this->getContext(); |
||
16 | |||
17 | $statement = new Node\Stmt\If_( |
||
18 | new Node\Expr\BinaryOp\Equal($this->newScalarExpr(1), $this->newScalarExpr(2)), |
||
19 | ["elseifs" => |
||
20 | [new Node\Stmt\ElseIf_( |
||
21 | new Node\Expr\BinaryOp\Equal($this->newScalarExpr(1), $this->newScalarExpr(1)), |
||
22 | [new Node\Expr\Assign( |
||
23 | new Node\Expr\Variable( |
||
24 | new Node\Name("stmtTest") |
||
25 | ), |
||
26 | $this->newScalarExpr(2) |
||
27 | )] |
||
28 | )] |
||
29 | ] |
||
30 | ); |
||
31 | |||
32 | \PHPSA\nodeVisitorFactory($statement, $context); |
||
33 | |||
34 | $variable = $context->getSymbol("stmtTest"); |
||
35 | |||
36 | parent::assertTrue($variable instanceof Variable); |
||
0 ignored issues
–
show
|
|||
37 | } |
||
38 | } |
||
39 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.