Chris@13: setPass(new UseStatementPass()); Chris@13: } Chris@13: Chris@13: /** Chris@13: * @dataProvider useStatements Chris@13: */ Chris@13: public function testProcess($from, $to) Chris@13: { Chris@13: $this->assertProcessesAs($from, $to); Chris@13: } Chris@13: Chris@13: public function useStatements() Chris@13: { Chris@13: return [ Chris@13: [ Chris@13: "use StdClass as NotSoStd;\n\$std = new NotSoStd();", Chris@13: '$std = new \\StdClass();', Chris@13: ], Chris@13: [ Chris@13: "namespace Foo;\n\nuse StdClass as S;\n\$std = new S();", Chris@13: "namespace Foo;\n\n\$std = new \\StdClass();", Chris@13: ], Chris@13: [ Chris@13: "namespace Foo;\n\nuse \\StdClass as S;\n\$std = new S();", Chris@13: "namespace Foo;\n\n\$std = new \\StdClass();", Chris@13: ], Chris@13: [ Chris@13: "use Foo\\Bar as fb;\n\$baz = new fb\\Baz();", Chris@13: '$baz = new \\Foo\\Bar\\Baz();', Chris@13: ], Chris@13: [ Chris@13: "use Foo\\Bar;\n\$baz = new Bar\\Baz();", Chris@13: '$baz = new \\Foo\\Bar\\Baz();', Chris@13: ], Chris@13: [ Chris@13: "namespace Foo;\nuse Bar;\n\$baz = new Bar\\Baz();", Chris@13: "namespace Foo;\n\n\$baz = new \\Bar\\Baz();", Chris@13: ], Chris@16: [ Chris@16: "namespace Foo;\n\nuse \\StdClass as S;\n\$std = new S();\nnamespace Foo;\n\n\$std = new S();", Chris@16: "namespace Foo;\n\n\$std = new \\StdClass();\nnamespace Foo;\n\n\$std = new \\StdClass();", Chris@16: ], Chris@16: [ Chris@16: "namespace Foo;\n\nuse \\StdClass as S;\n\$std = new S();\nnamespace Bar;\n\n\$std = new S();", Chris@16: "namespace Foo;\n\n\$std = new \\StdClass();\nnamespace Bar;\n\n\$std = new S();", Chris@16: ], Chris@16: [ Chris@16: "use Foo\\Bar as fb, Qux as Q;\n\$baz = new fb\\Baz();\n\$qux = new Q();", Chris@16: "\$baz = new \\Foo\\Bar\\Baz();\n\$qux = new \\Qux();", Chris@16: ], Chris@16: ]; Chris@16: } Chris@16: Chris@16: /** Chris@16: * @dataProvider groupUseStatements Chris@16: */ Chris@16: public function testGroupUseProcess($from, $to) Chris@16: { Chris@16: $this->assertProcessesAs($from, $to); Chris@16: } Chris@16: Chris@16: public function groupUseStatements() Chris@16: { Chris@17: if (\version_compare(PHP_VERSION, '7.0', '<')) { Chris@16: $this->markTestSkipped(); Chris@16: } Chris@16: Chris@16: return [ Chris@16: [ Chris@16: "use Foo\\{Bar, Baz, Qux as Q};\n\$bar = new Bar();\n\$baz = new Baz();\n\$qux = new Q();", Chris@16: "\$bar = new \\Foo\\Bar();\n\$baz = new \\Foo\\Baz();\n\$qux = new \\Foo\\Qux();", Chris@16: ], Chris@16: [ Chris@16: "use X\\{Foo, Bar as B};\n\$foo = new Foo();\n\$baz = new B\\Baz();", Chris@16: "\$foo = new \\X\\Foo();\n\$baz = new \\X\\Bar\\Baz();", Chris@16: ], Chris@16: [ Chris@16: "use X\\{Foo, Bar as B};\n\$foo = new Foo();\n\$bar = new Bar();\n\$baz = new B\\Baz();", Chris@16: "\$foo = new \\X\\Foo();\n\$bar = new Bar();\n\$baz = new \\X\\Bar\\Baz();", Chris@16: ], Chris@13: ]; Chris@13: } Chris@13: }