fixNamespaceDeclarations() public static method

Adds brackets around each namespace if it's not already the case.
public static fixNamespaceDeclarations ( string $source ) : string
$source string Namespace string
return string Namespaces with brackets
    public function testFixNamespaceDeclarations()
    {
        $source = <<<EOF
<?php

namespace Foo;
class Foo {}
namespace   Bar ;
class Foo {}
namespace Foo\\Bar;
class Foo {}
namespace Foo\\Bar\\Bar
{
    class Foo {}
}
namespace
{
    class Foo {}
}
EOF;
        $expected = <<<EOF
<?php

namespace Foo
{
class Foo {}
}
namespace   Bar 
{
class Foo {}
}
namespace Foo\\Bar
{
class Foo {}
}
namespace Foo\\Bar\\Bar
{
    class Foo {}
}
namespace
{
    class Foo {}
}
EOF;
        $this->assertEquals($expected, ClassCollectionLoader::fixNamespaceDeclarations($source));
    }
示例#2
0
 /**
  * @dataProvider getFixNamespaceDeclarationsDataWithoutTokenizer
  */
 public function testFixNamespaceDeclarationsWithoutTokenizer($source, $expected)
 {
     ClassCollectionLoader::enableTokenizer(false);
     $this->assertEquals('<?php ' . $expected, ClassCollectionLoader::fixNamespaceDeclarations('<?php ' . $source));
     ClassCollectionLoader::enableTokenizer(true);
 }