public function testLeaveFunctionsAloneOutsideClassesWithOopWordInFunctionName()
    {
        $fixer = new VisibilityFixer();
        $file = new \SplFileInfo(__FILE__);
        $expected = <<<'EOF'
<?php

comment_class();

if (!function_exists('foo')) {
    function foo($arg)
    {
        return $arg;
    }
}
EOF;
        $this->assertEquals($expected, $fixer->fix($file, $expected));
    }
    public function testLeaveFunctionsAlone()
    {
        $fixer = new VisibilityFixer();
        $file = new \SplFileInfo(__FILE__);
        $expected = <<<'EOF'
function foo() {
    static $foo;
}
EOF;
        $input = <<<'EOF'
function foo() {
    static $foo;
}
EOF;
        $this->assertEquals($expected, $fixer->fix($file, $input));
    }
Exemplo n.º 3
0
    public function testDontGetTrickedIntoParsingFunctionsWithOoKeywordVariables()
    {
        $fixer = new VisibilityFixer();
        $file = new \SplFileInfo(__FILE__);
        $expected = <<<'EOF'
function foo($class) {
    static $foo;
}
EOF;
        $input = <<<'EOF'
function foo($class) {
    static $foo;
}
EOF;
        $this->assertEquals($expected, $fixer->fix($file, $input));
    }
    public function testLeaveFunctionsAloneWithVariablesMatchingOopWords()
    {
        $fixer = new VisibilityFixer();
        $file = new \SplFileInfo(__FILE__);
        $expected = <<<'EOF'
function foo() {
    static $class;
    $interface = 'foo';
    $trait = 'bar;
}
EOF;
        $this->assertEquals($expected, $fixer->fix($file, $expected));
    }