Exakat\Analyzer\Structures\UselessInstruction::analyze PHP Method

analyze() public method

public analyze ( )
    public function analyze()
    {
        // Structures that should be put somewhere, and never left alone
        $this->atomIs('Sequence')->hasNoIn('FINAL')->outIs('ELEMENT')->atomIs(array('Array', 'Addition', 'Multiplication', 'Property', 'Staticproperty', 'Boolean', 'Magicconstant', 'Staticconstant', 'Integer', 'Real', 'Sign', 'Nsname', 'Identifier', 'String', 'Instanceof', 'Bitshift', 'Comparison', 'Null', 'Logical', 'Heredoc', 'Power', 'Spaceship', 'Coalesce', 'New'))->noAtomInside(array('Functioncall', 'Staticmethodcall', 'Methodcall', 'Assignation'));
        $this->prepareQuery();
        // foreach($i = 0; $i < 10, $j < 20; $i++)
        $this->atomIs('For')->outIs('FINAL')->outWithoutLastRank()->atomIs(array('Array', 'Addition', 'Multiplication', 'Property', 'Staticproperty', 'Boolean', 'Magicconstant', 'Staticconstant', 'Integer', 'Real', 'Sign', 'Nsname', 'Identifier', 'String', 'Instanceof', 'Bitshift', 'Comparison', 'Null', 'Logical', 'Heredoc', 'Power', 'Spaceship', 'Coalesce', 'New'))->noAtomInside(array('Functioncall', 'Staticmethodcall', 'Methodcall', 'Assignation'));
        $this->prepareQuery();
        // -$x = 3
        $this->atomIs('Assignation')->outIs('LEFT')->atomIs('Sign');
        $this->prepareQuery();
        // closures that are not assigned to something (argument or variable)
        $this->atomIs('Sequence')->outIs('ELEMENT')->atomIs('Function')->isLambda();
        $this->prepareQuery();
        // return $a++;
        $this->atomIs('Return')->outIs('RETURN')->atomIs('Postplusplus')->back('first');
        $this->prepareQuery();
        // array_merge($a); one argument is useless.
        $this->atomIs('Functioncall')->hasNoIn('METHOD')->tokenIs(array('T_STRING', 'T_NS_SEPARATOR'))->fullnspathIs(array('\\array_merge', '\\array_merge_recursive', '\\array_replace'))->outIs('ARGUMENTS')->isLess('count', 2)->back('first');
        $this->prepareQuery();
        // foreach(@$a as $b);
        $this->atomIs('Foreach')->outIs('SOURCE')->atomIs('Noscream');
        $this->prepareQuery();
        // @$x = 3;
        $this->atomIs('Assignation')->outIs('LEFT')->atomIs('Noscream')->outIs('AT')->atomIs('Variable')->inIs('AT');
        $this->prepareQuery();
        // Closure with some operations
        $this->atomIs('Function')->inIs('LEFT')->atomIs(array('Addition', 'Multiplication', 'Power'))->back('first');
        $this->prepareQuery();
        // $x = 'a' . function ($a) {} (Concatenating a closure...)
        $this->atomIs('Function')->inIs('CONCAT')->atomIs('Concatenation')->back('first');
        $this->prepareQuery();
        // New in a instanceof (with/without parenthesis)
        $this->atomIs('New')->inIsIE(array('CODE', 'RIGHT'))->inIs('VARIABLE')->atomIs('Instanceof')->back('first');
        $this->prepareQuery();
        // Empty string in a concatenation
        $this->atomIs('Concatenation')->outIs('CONCAT')->outIsIE('CODE')->codeIs(array("''", '""'))->back('first');
        $this->prepareQuery();
    }
UselessInstruction