Completed
Push — master ( d6a494...e1144e )
by Дмитрий
11s
created

tests/PHPSA/Compiler/Statement/ElseIfTest.php (1 issue)

Upgrade to new PHP Analysis Engine

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
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertTrue() instead of testIfElseIfCreatesVar()). Are you sure this is correct? If so, you might want to change this to $this->assertTrue().

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:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
37
    }
38
}
39