diff --git a/specs/class-const/global-scope-single-level-with-single-level-use-statement-and-alias.php b/specs/class-const/global-scope-single-level-with-single-level-use-statement-and-alias.php index 42676893..ccaf545d 100644 --- a/specs/class-const/global-scope-single-level-with-single-level-use-statement-and-alias.php +++ b/specs/class-const/global-scope-single-level-with-single-level-use-statement-and-alias.php @@ -43,7 +43,7 @@ class Foo { } use Humbug\Foo as X; -\Humbug\Foo::MAIN_CONST; +X::MAIN_CONST; PHP ], @@ -88,7 +88,7 @@ class X namespace Humbug; use Reflector as X; -\Reflector::MAIN_CONST; +X::MAIN_CONST; PHP ], diff --git a/specs/class-const/global-scope-single-level-with-single-level-use-statement.php b/specs/class-const/global-scope-single-level-with-single-level-use-statement.php index ecd8c7a6..7ba87a54 100644 --- a/specs/class-const/global-scope-single-level-with-single-level-use-statement.php +++ b/specs/class-const/global-scope-single-level-with-single-level-use-statement.php @@ -43,7 +43,7 @@ class Command { } use Humbug\Command; -\Humbug\Command::MAIN_CONST; +Command::MAIN_CONST; PHP ], @@ -84,7 +84,7 @@ class Command namespace Humbug; use Reflector; -\Reflector::MAIN_CONST; +Reflector::MAIN_CONST; PHP ], diff --git a/specs/class-const/global-scope-two-level-with-single-level-use-and-alias.php b/specs/class-const/global-scope-two-level-with-single-level-use-and-alias.php index 5a84033f..5bbeb096 100644 --- a/specs/class-const/global-scope-two-level-with-single-level-use-and-alias.php +++ b/specs/class-const/global-scope-two-level-with-single-level-use-and-alias.php @@ -58,7 +58,7 @@ class Bar namespace Humbug; use Humbug\Foo as X; -\Humbug\Foo\Bar::MAIN_CONST; +X\Bar::MAIN_CONST; PHP ], @@ -87,7 +87,7 @@ class Bar namespace Humbug; use Humbug\Foo\Bar as X; -\Humbug\Foo\Bar::MAIN_CONST; +X::MAIN_CONST; PHP ], @@ -168,7 +168,7 @@ class Bar namespace Humbug; use Humbug\Foo as X; -\Humbug\Foo\Bar::MAIN_CONST; +X\Bar::MAIN_CONST; PHP ], diff --git a/specs/class-const/global-scope-two-level-with-single-level-use.php b/specs/class-const/global-scope-two-level-with-single-level-use.php index 864fe24e..3bd1a23f 100644 --- a/specs/class-const/global-scope-two-level-with-single-level-use.php +++ b/specs/class-const/global-scope-two-level-with-single-level-use.php @@ -58,7 +58,7 @@ class Bar namespace Humbug; use Humbug\Foo; -\Humbug\Foo\Bar::MAIN_CONST; +Foo\Bar::MAIN_CONST; PHP ], @@ -96,7 +96,7 @@ class X namespace Humbug; use Humbug\Foo\Bar; -\Humbug\Foo\Bar\X::MAIN_CONST; +Bar\X::MAIN_CONST; PHP ], @@ -177,7 +177,7 @@ class Bar namespace Humbug; use Humbug\Foo; -\Humbug\Foo\Bar::MAIN_CONST; +Foo\Bar::MAIN_CONST; PHP ], diff --git a/specs/class-const/namespace-scope-single-level-with-single-level-use-statement-and-alias.php b/specs/class-const/namespace-scope-single-level-with-single-level-use-statement-and-alias.php index 33b01a67..b547ddaa 100644 --- a/specs/class-const/namespace-scope-single-level-with-single-level-use-statement-and-alias.php +++ b/specs/class-const/namespace-scope-single-level-with-single-level-use-statement-and-alias.php @@ -49,7 +49,7 @@ class Foo namespace Humbug\A; use Humbug\Foo as X; -\Humbug\Foo::MAIN_CONST; +X::MAIN_CONST; PHP ], @@ -102,7 +102,7 @@ class X namespace Humbug\A; use Reflector as X; -\Reflector::MAIN_CONST; +X::MAIN_CONST; PHP ], diff --git a/specs/class-const/namespace-scope-single-level.php b/specs/class-const/namespace-scope-single-level.php index 95ea189d..34218347 100644 --- a/specs/class-const/namespace-scope-single-level.php +++ b/specs/class-const/namespace-scope-single-level.php @@ -88,7 +88,7 @@ class Command namespace Humbug\X; use Reflector; -\Reflector::MAIN_CONST; +Reflector::MAIN_CONST; PHP ], diff --git a/specs/class-const/namespace-scope-two-level-with-single-level-use-and-alias.php b/specs/class-const/namespace-scope-two-level-with-single-level-use-and-alias.php index ad9f38d0..e38d9e15 100644 --- a/specs/class-const/namespace-scope-two-level-with-single-level-use-and-alias.php +++ b/specs/class-const/namespace-scope-two-level-with-single-level-use-and-alias.php @@ -58,7 +58,7 @@ class Bar namespace Humbug\A; use Humbug\Foo as X; -\Humbug\Foo\Bar::MAIN_CONST; +X\Bar::MAIN_CONST; PHP ], @@ -87,7 +87,7 @@ class Bar namespace Humbug\A; use Humbug\Foo\Bar as X; -\Humbug\Foo\Bar::MAIN_CONST; +X::MAIN_CONST; PHP ], @@ -168,7 +168,7 @@ class Bar namespace Humbug\A; use Humbug\Foo as X; -\Humbug\Foo\Bar::MAIN_CONST; +X\Bar::MAIN_CONST; PHP ], diff --git a/specs/class-const/namespace-scope-two-level-with-single-level-use.php b/specs/class-const/namespace-scope-two-level-with-single-level-use.php index 39e7c747..6e5f7d67 100644 --- a/specs/class-const/namespace-scope-two-level-with-single-level-use.php +++ b/specs/class-const/namespace-scope-two-level-with-single-level-use.php @@ -58,7 +58,7 @@ class Bar namespace Humbug\X; use Humbug\Foo; -\Humbug\Foo\Bar::MAIN_CONST; +Foo\Bar::MAIN_CONST; PHP ], @@ -96,7 +96,7 @@ class X namespace Humbug\X; use Humbug\Foo\Bar; -\Humbug\Foo\Bar\X::MAIN_CONST; +Bar\X::MAIN_CONST; PHP ], @@ -177,7 +177,7 @@ class Bar namespace Humbug\X; use Humbug\Foo; -\Humbug\Foo\Bar::MAIN_CONST; +Foo\Bar::MAIN_CONST; PHP ], diff --git a/specs/class-const/namespace-single-part-with-single-level-use-statement.php b/specs/class-const/namespace-single-part-with-single-level-use-statement.php index 82738b39..b2b7be4c 100644 --- a/specs/class-const/namespace-single-part-with-single-level-use-statement.php +++ b/specs/class-const/namespace-single-part-with-single-level-use-statement.php @@ -49,7 +49,7 @@ class Foo namespace Humbug\X; use Humbug\Foo; -\Humbug\Foo::MAIN_CONST; +Foo::MAIN_CONST; PHP ], @@ -98,7 +98,7 @@ class Command namespace Humbug\X; use Reflector; -\Reflector::MAIN_CONST; +Reflector::MAIN_CONST; PHP ], diff --git a/specs/class-static-prop/global-scope-single-level-with-single-level-use-statement-and-alias.php b/specs/class-static-prop/global-scope-single-level-with-single-level-use-statement-and-alias.php index e91f3e46..a1a6d196 100644 --- a/specs/class-static-prop/global-scope-single-level-with-single-level-use-statement-and-alias.php +++ b/specs/class-static-prop/global-scope-single-level-with-single-level-use-statement-and-alias.php @@ -42,7 +42,7 @@ class Foo { } use Humbug\Foo as X; -\Humbug\Foo::$mainStaticProp; +X::$mainStaticProp; PHP , @@ -85,7 +85,7 @@ class X namespace Humbug; use Reflector as X; -\Reflector::$mainStaticProp; +X::$mainStaticProp; PHP , diff --git a/specs/class-static-prop/global-scope-single-level-with-single-level-use-statement.php b/specs/class-static-prop/global-scope-single-level-with-single-level-use-statement.php index 26ab6f0a..a1e4ed73 100644 --- a/specs/class-static-prop/global-scope-single-level-with-single-level-use-statement.php +++ b/specs/class-static-prop/global-scope-single-level-with-single-level-use-statement.php @@ -42,7 +42,7 @@ class Command { } use Humbug\Command; -\Humbug\Command::$mainStaticProp; +Command::$mainStaticProp; PHP , @@ -81,7 +81,7 @@ class Command namespace Humbug; use Reflector; -\Reflector::$mainStaticProp; +Reflector::$mainStaticProp; PHP , diff --git a/specs/class-static-prop/global-scope-two-level-with-single-level-use-and-alias.php b/specs/class-static-prop/global-scope-two-level-with-single-level-use-and-alias.php index 8979bb1d..3073fc82 100644 --- a/specs/class-static-prop/global-scope-two-level-with-single-level-use-and-alias.php +++ b/specs/class-static-prop/global-scope-two-level-with-single-level-use-and-alias.php @@ -57,7 +57,7 @@ class Bar namespace Humbug; use Humbug\Foo as X; -\Humbug\Foo\Bar::$mainStaticProp; +X\Bar::$mainStaticProp; PHP , @@ -85,7 +85,7 @@ class Bar namespace Humbug; use Humbug\Foo\Bar as X; -\Humbug\Foo\Bar::$mainStaticProp; +X::$mainStaticProp; PHP , @@ -165,7 +165,7 @@ class Bar namespace Humbug; use Humbug\Foo as X; -\Humbug\Foo\Bar::$mainStaticProp; +X\Bar::$mainStaticProp; PHP ], diff --git a/specs/class-static-prop/global-scope-two-level-with-single-level-use.php b/specs/class-static-prop/global-scope-two-level-with-single-level-use.php index d8d665ff..8bc364aa 100644 --- a/specs/class-static-prop/global-scope-two-level-with-single-level-use.php +++ b/specs/class-static-prop/global-scope-two-level-with-single-level-use.php @@ -57,7 +57,7 @@ class Bar namespace Humbug; use Humbug\Foo; -\Humbug\Foo\Bar::$mainStaticProp; +Foo\Bar::$mainStaticProp; PHP , @@ -94,7 +94,7 @@ class X namespace Humbug; use Humbug\Foo\Bar; -\Humbug\Foo\Bar\X::$mainStaticProp; +Bar\X::$mainStaticProp; PHP , @@ -174,7 +174,7 @@ class Bar namespace Humbug; use Humbug\Foo; -\Humbug\Foo\Bar::$mainStaticProp; +Foo\Bar::$mainStaticProp; PHP ], diff --git a/specs/class-static-prop/namespace-scope-single-level-with-single-level-use-statement-and-alias.php b/specs/class-static-prop/namespace-scope-single-level-with-single-level-use-statement-and-alias.php index aa4e9a01..39d177ec 100644 --- a/specs/class-static-prop/namespace-scope-single-level-with-single-level-use-statement-and-alias.php +++ b/specs/class-static-prop/namespace-scope-single-level-with-single-level-use-statement-and-alias.php @@ -48,7 +48,7 @@ class Foo namespace Humbug\A; use Humbug\Foo as X; -\Humbug\Foo::$mainStaticProp; +X::$mainStaticProp; PHP , @@ -99,7 +99,7 @@ class X namespace Humbug\A; use Reflector as X; -\Reflector::$mainStaticProp; +X::$mainStaticProp; PHP , diff --git a/specs/class-static-prop/namespace-scope-single-level.php b/specs/class-static-prop/namespace-scope-single-level.php index a017037e..de378eca 100644 --- a/specs/class-static-prop/namespace-scope-single-level.php +++ b/specs/class-static-prop/namespace-scope-single-level.php @@ -85,7 +85,7 @@ class Command namespace Humbug\X; use Reflector; -\Reflector::$mainStaticProp; +Reflector::$mainStaticProp; PHP , diff --git a/specs/class-static-prop/namespace-scope-two-level-with-single-level-use-and-alias.php b/specs/class-static-prop/namespace-scope-two-level-with-single-level-use-and-alias.php index 61ec22d6..ac419822 100644 --- a/specs/class-static-prop/namespace-scope-two-level-with-single-level-use-and-alias.php +++ b/specs/class-static-prop/namespace-scope-two-level-with-single-level-use-and-alias.php @@ -57,7 +57,7 @@ class Bar namespace Humbug\A; use Humbug\Foo as X; -\Humbug\Foo\Bar::$mainStaticProp; +X\Bar::$mainStaticProp; PHP , @@ -85,7 +85,7 @@ class Bar namespace Humbug\A; use Humbug\Foo\Bar as X; -\Humbug\Foo\Bar::$mainStaticProp; +X::$mainStaticProp; PHP , @@ -165,7 +165,7 @@ class Bar namespace Humbug\A; use Humbug\Foo as X; -\Humbug\Foo\Bar::$mainStaticProp; +X\Bar::$mainStaticProp; PHP ], diff --git a/specs/class-static-prop/namespace-scope-two-level-with-single-level-use.php b/specs/class-static-prop/namespace-scope-two-level-with-single-level-use.php index b39a93b6..954c1eb2 100644 --- a/specs/class-static-prop/namespace-scope-two-level-with-single-level-use.php +++ b/specs/class-static-prop/namespace-scope-two-level-with-single-level-use.php @@ -57,7 +57,7 @@ class Bar namespace Humbug\X; use Humbug\Foo; -\Humbug\Foo\Bar::$mainStaticProp; +Foo\Bar::$mainStaticProp; PHP , @@ -94,7 +94,7 @@ class X namespace Humbug\X; use Humbug\Foo\Bar; -\Humbug\Foo\Bar\X::$mainStaticProp; +Bar\X::$mainStaticProp; PHP , @@ -174,7 +174,7 @@ class Bar namespace Humbug\X; use Humbug\Foo; -\Humbug\Foo\Bar::$mainStaticProp; +Foo\Bar::$mainStaticProp; PHP ], diff --git a/specs/class-static-prop/namespace-single-part-with-single-level-use-statement.php b/specs/class-static-prop/namespace-single-part-with-single-level-use-statement.php index 5a39f961..55270981 100644 --- a/specs/class-static-prop/namespace-single-part-with-single-level-use-statement.php +++ b/specs/class-static-prop/namespace-single-part-with-single-level-use-statement.php @@ -48,7 +48,7 @@ class Foo namespace Humbug\X; use Humbug\Foo; -\Humbug\Foo::$mainStaticProp; +Foo::$mainStaticProp; PHP , @@ -95,7 +95,7 @@ class Command namespace Humbug\X; use Reflector; -\Reflector::$mainStaticProp; +Reflector::$mainStaticProp; PHP , diff --git a/specs/class/anonymous.php b/specs/class/anonymous.php index 188a9f4c..cda3b739 100644 --- a/specs/class/anonymous.php +++ b/specs/class/anonymous.php @@ -449,7 +449,7 @@ public function test() { } }; -new class extends \Humbug\A implements \Humbug\Foo\B, \Humbug\Foo\C, \Iterator +new class extends A implements \Humbug\Foo\B, \Humbug\Foo\C, \Iterator { }; namespace Humbug\Bar; @@ -459,7 +459,7 @@ public function test() { public $foo; }; -new class($a, $b) extends \Humbug\A +new class($a, $b) extends A { use T; }; diff --git a/specs/class/interface.php b/specs/class/interface.php index 561e5d31..16e4833c 100644 --- a/specs/class/interface.php +++ b/specs/class/interface.php @@ -117,7 +117,7 @@ class C class D { } -interface A extends \Humbug\Foo\C, \Humbug\Foo\D, \Iterator +interface A extends \Humbug\Foo\C, \Humbug\Foo\D, Iterator { public function a(); } @@ -153,7 +153,7 @@ class C class D { } -interface A extends \Humbug\Foo\C, \Humbug\Foo\D, \Iterator +interface A extends \Humbug\Foo\C, \Humbug\Foo\D, Iterator { public function a(); } @@ -192,7 +192,7 @@ class C class D { } -interface A extends \Humbug\Foo\C, \Humbug\Foo\D, \Iterator +interface A extends \Humbug\Foo\C, \Humbug\Foo\D, Iterator { public function a(); } diff --git a/specs/class/regular-extend.php b/specs/class/regular-extend.php index e69c8662..3710770b 100644 --- a/specs/class/regular-extend.php +++ b/specs/class/regular-extend.php @@ -77,7 +77,7 @@ public function a() { } } -class B extends \Humbug\Foo\A implements \Iterator +class B extends \Humbug\Foo\A implements Iterator { } @@ -148,7 +148,7 @@ public function a() namespace Humbug\Bar; use Humbug\Foo\A; -class B extends \Humbug\Foo\A +class B extends A { } diff --git a/specs/class/typed-properties.php b/specs/class/typed-properties.php index 8437de07..cb437c1e 100644 --- a/specs/class/typed-properties.php +++ b/specs/class/typed-properties.php @@ -210,8 +210,8 @@ class A { public string $name; public ?\Humbug\Foo\B $foo; - public ?\Humbug\Bar\C $foo; - public ?\DateTimeImmutable $bar; + public ?C $foo; + public ?DateTimeImmutable $bar; public ?\Humbug\Foo\Closure $baz; public function a() { diff --git a/specs/const/global-scope-global-with-single-level-use-statement-and-alias.php b/specs/const/global-scope-global-with-single-level-use-statement-and-alias.php index 2dffaaaf..8f971b6a 100644 --- a/specs/const/global-scope-global-with-single-level-use-statement-and-alias.php +++ b/specs/const/global-scope-global-with-single-level-use-statement-and-alias.php @@ -37,7 +37,7 @@ namespace Humbug; use const Humbug\DUMMY_CONST as FOO; -\Humbug\DUMMY_CONST; +FOO; PHP , diff --git a/specs/const/global-scope-global-with-single-level-use-statement.php b/specs/const/global-scope-global-with-single-level-use-statement.php index 6020ff04..d6b64dc1 100644 --- a/specs/const/global-scope-global-with-single-level-use-statement.php +++ b/specs/const/global-scope-global-with-single-level-use-statement.php @@ -37,7 +37,7 @@ namespace Humbug; use const Humbug\DUMMY_CONST; -\Humbug\DUMMY_CONST; +DUMMY_CONST; PHP , diff --git a/specs/const/global-scope-single-part-namespaced-with-single-level-use-alias.php b/specs/const/global-scope-single-part-namespaced-with-single-level-use-alias.php index 85615ee4..daa79d33 100644 --- a/specs/const/global-scope-single-part-namespaced-with-single-level-use-alias.php +++ b/specs/const/global-scope-single-part-namespaced-with-single-level-use-alias.php @@ -55,7 +55,7 @@ class Foo namespace Humbug; use Humbug\Foo as A; -\Humbug\Foo\DUMMY_CONST; +A\DUMMY_CONST; PHP , diff --git a/specs/const/global-scope-single-part-namespaced-with-single-level-use.php b/specs/const/global-scope-single-part-namespaced-with-single-level-use.php index 01d0d7d4..0b1825ac 100644 --- a/specs/const/global-scope-single-part-namespaced-with-single-level-use.php +++ b/specs/const/global-scope-single-part-namespaced-with-single-level-use.php @@ -42,7 +42,7 @@ class Foo { } use Humbug\Foo; -\Humbug\Foo\DUMMY_CONST; +Foo\DUMMY_CONST; PHP , diff --git a/specs/const/global-scope-two-parts-namespaced-with-single-level-use-and-alias.php b/specs/const/global-scope-two-parts-namespaced-with-single-level-use-and-alias.php index dbc9add0..4e1f1a4a 100644 --- a/specs/const/global-scope-two-parts-namespaced-with-single-level-use-and-alias.php +++ b/specs/const/global-scope-two-parts-namespaced-with-single-level-use-and-alias.php @@ -42,7 +42,7 @@ class Foo { } use Humbug\Foo as A; -\Humbug\Foo\Bar\DUMMY_CONST; +A\Bar\DUMMY_CONST; PHP , diff --git a/specs/const/global-scope-two-parts-namespaced-with-single-level-use.php b/specs/const/global-scope-two-parts-namespaced-with-single-level-use.php index a27e7092..a0ad09b7 100644 --- a/specs/const/global-scope-two-parts-namespaced-with-single-level-use.php +++ b/specs/const/global-scope-two-parts-namespaced-with-single-level-use.php @@ -42,7 +42,7 @@ class Foo { } use Humbug\Foo; -\Humbug\Foo\Bar\DUMMY_CONST; +Foo\Bar\DUMMY_CONST; PHP , diff --git a/specs/const/namespace-global-with-single-level-use-statement-and-alias.php b/specs/const/namespace-global-with-single-level-use-statement-and-alias.php index 7b609835..2187d52c 100644 --- a/specs/const/namespace-global-with-single-level-use-statement-and-alias.php +++ b/specs/const/namespace-global-with-single-level-use-statement-and-alias.php @@ -39,7 +39,7 @@ namespace Humbug\A; use const Humbug\DUMMY_CONST as FOO; -\Humbug\DUMMY_CONST; +FOO; PHP , diff --git a/specs/const/namespace-global-with-single-level-use-statement.php b/specs/const/namespace-global-with-single-level-use-statement.php index 2fea5c35..9e70e7be 100644 --- a/specs/const/namespace-global-with-single-level-use-statement.php +++ b/specs/const/namespace-global-with-single-level-use-statement.php @@ -39,7 +39,7 @@ namespace Humbug\A; use const Humbug\DUMMY_CONST; -\Humbug\DUMMY_CONST; +DUMMY_CONST; PHP , diff --git a/specs/const/native-const-with-global-whitelisting.php b/specs/const/native-const-with-global-whitelisting.php index 7a6d9f47..281c097d 100644 --- a/specs/const/native-const-with-global-whitelisting.php +++ b/specs/const/native-const-with-global-whitelisting.php @@ -57,7 +57,7 @@ namespace Humbug\Acme; use const Humbug\Acme\DIRECTORY_SEPARATOR; -$x = \Humbug\Acme\DIRECTORY_SEPARATOR; +$x = DIRECTORY_SEPARATOR; PHP , diff --git a/specs/const/native-const.php b/specs/const/native-const.php index 69248052..3cd59bac 100644 --- a/specs/const/native-const.php +++ b/specs/const/native-const.php @@ -68,7 +68,7 @@ namespace Humbug\Acme; use const Humbug\Acme\DIRECTORY_SEPARATOR; -$x = \Humbug\Acme\DIRECTORY_SEPARATOR; +$x = DIRECTORY_SEPARATOR; if (!\defined('PATH_SEPARATOR')) { \define('PATH_SEPARATOR', "\n"); } diff --git a/specs/exp/catch.php b/specs/exp/catch.php index 50e7eebb..7108f1dc 100644 --- a/specs/exp/catch.php +++ b/specs/exp/catch.php @@ -220,7 +220,7 @@ use Humbug\X\FooException; try { echo "foo"; -} catch (\Humbug\X\FooException $t) { +} catch (FooException $t) { } PHP @@ -245,7 +245,7 @@ use Humbug\X\FooException; try { echo "foo"; -} catch (\Humbug\X\FooException|\Throwable $t) { +} catch (FooException|\Throwable $t) { } PHP diff --git a/specs/exp/coalescing-assignment.php b/specs/exp/coalescing-assignment.php index b541a01c..0c7ed4d8 100644 --- a/specs/exp/coalescing-assignment.php +++ b/specs/exp/coalescing-assignment.php @@ -55,7 +55,7 @@ namespace Humbug\Acme; use stdClass; -$x ??= new \stdClass(); +$x ??= new stdClass(); PHP , diff --git a/specs/exp/instanceof.php b/specs/exp/instanceof.php index 62fdfc97..5343e171 100644 --- a/specs/exp/instanceof.php +++ b/specs/exp/instanceof.php @@ -57,8 +57,8 @@ namespace Humbug\Acme; use stdClass; -$x = new \stdClass(); -$x instanceof \stdClass; +$x = new stdClass(); +$x instanceof stdClass; PHP , diff --git a/specs/func-arrow/namespace-arrow-func-with-use-stmt.php b/specs/func-arrow/namespace-arrow-func-with-use-stmt.php index c92f7397..d71b7bd6 100644 --- a/specs/func-arrow/namespace-arrow-func-with-use-stmt.php +++ b/specs/func-arrow/namespace-arrow-func-with-use-stmt.php @@ -53,8 +53,8 @@ fn($x) => $x; fn(int $x) => $x; fn(int $x): int => $x; -fn(\Humbug\X\Foo $x): \Humbug\X\Bar => $x; -fn(\DateTimeImmutable $x): \Closure => $x; +fn(Foo $x): Bar => $x; +fn(DateTimeImmutable $x): Closure => $x; PHP , @@ -89,8 +89,8 @@ fn($x) => $x; fn(int $x) => $x; fn(int $x): int => $x; -fn(\Humbug\X\Foo $x): \Humbug\X\Bar => $x; -fn(\DateTimeImmutable $x): \Closure => $x; +fn(Foo $x): Bar => $x; +fn(DateTimeImmutable $x): Closure => $x; PHP ], @@ -127,8 +127,8 @@ fn($x) => $x; fn(int $x) => $x; fn(int $x): int => $x; -fn(\Humbug\X\Foo $x): \Humbug\X\Bar => $x; -fn(\DateTimeImmutable $x): \Closure => $x; +fn(Foo $x): Bar => $x; +fn(DateTimeImmutable $x): Closure => $x; PHP ], diff --git a/specs/func-declaration/global.php b/specs/func-declaration/global.php index 88e5b758..a3f815e0 100644 --- a/specs/func-declaration/global.php +++ b/specs/func-declaration/global.php @@ -266,7 +266,7 @@ class Y use Humbug\Foo; use ArrayIterator; -function foo(string $arg0, ?string $arg1, ?string $arg2 = null, \Humbug\Foo $arg3, ?\Humbug\Foo $arg4, \Humbug\Foo $arg5 = null, \Humbug\Foo $arg6, ?\Humbug\Foo $arg7, \Humbug\Foo $arg8 = null, \Humbug\Foo\Bar $arg9, ?\Humbug\Foo\Bar $arg10, \Humbug\Foo\Bar $arg11 = null, \Humbug\Foo\Bar $arg7, ?\Humbug\Foo\Bar $arg12, \Humbug\Foo\Bar $arg13 = null, \ArrayIterator $arg14, ?\ArrayIterator $arg15, ?\ArrayIterator $arg16 = null, \ArrayIterator $arg17, ?\ArrayIterator $arg18, \ArrayIterator $arg19 = null, \Humbug\X\Y $arg20, \Humbug\X\Y $arg21) +function foo(string $arg0, ?string $arg1, ?string $arg2 = null, Foo $arg3, ?Foo $arg4, Foo $arg5 = null, \Humbug\Foo $arg6, ?\Humbug\Foo $arg7, \Humbug\Foo $arg8 = null, Foo\Bar $arg9, ?Foo\Bar $arg10, Foo\Bar $arg11 = null, \Humbug\Foo\Bar $arg7, ?\Humbug\Foo\Bar $arg12, \Humbug\Foo\Bar $arg13 = null, ArrayIterator $arg14, ?ArrayIterator $arg15, ?ArrayIterator $arg16 = null, \ArrayIterator $arg17, ?\ArrayIterator $arg18, \ArrayIterator $arg19 = null, \Humbug\X\Y $arg20, \Humbug\X\Y $arg21) { } @@ -406,25 +406,25 @@ function foo() : callable function foo() : ?callable { } -function foo() : \Humbug\Foo +function foo() : Foo { } function foo() : \Humbug\Foo { } -function foo() : ?\Humbug\Foo +function foo() : ?Foo { } function foo() : ?\Humbug\Foo { } -function foo() : \ArrayIterator +function foo() : ArrayIterator { } function foo() : \ArrayIterator { } -function foo() : ?\ArrayIterator +function foo() : ?ArrayIterator { } function foo() : ?\ArrayIterator diff --git a/specs/func-declaration/method.php b/specs/func-declaration/method.php index 6f49d379..2ec91413 100644 --- a/specs/func-declaration/method.php +++ b/specs/func-declaration/method.php @@ -251,25 +251,25 @@ function foo() : callable function foo() : ?callable { } - function foo() : \Humbug\Foo + function foo() : Foo { } function foo() : \Humbug\Foo { } - function foo() : ?\Humbug\Foo + function foo() : ?Foo { } function foo() : ?\Humbug\Foo { } - function foo() : \ArrayIterator + function foo() : ArrayIterator { } function foo() : \ArrayIterator { } - function foo() : ?\ArrayIterator + function foo() : ?ArrayIterator { } function foo() : ?\ArrayIterator diff --git a/specs/func-declaration/namespace.php b/specs/func-declaration/namespace.php index e4a0a224..c69b1ece 100644 --- a/specs/func-declaration/namespace.php +++ b/specs/func-declaration/namespace.php @@ -314,7 +314,7 @@ class Y use Humbug\Foo\Bar; use ArrayIterator; use Humbug\X\Y; -function foo(\Humbug\Foo $arg0, \Humbug\Foo $arg1, \Humbug\Foo\Bar $arg2, \Humbug\Foo\Bar $arg3, \ArrayIterator $arg4, \ArrayIterator $arg5, \Humbug\Pi\X\Y $arg6, \Humbug\X\Y $arg7) +function foo(Foo $arg0, \Humbug\Foo $arg1, Foo\Bar $arg2, \Humbug\Foo\Bar $arg3, ArrayIterator $arg4, \ArrayIterator $arg5, \Humbug\Pi\X\Y $arg6, \Humbug\X\Y $arg7) { } @@ -534,25 +534,25 @@ function foo() : callable function foo() : ?callable { } -function foo() : \Humbug\Foo +function foo() : Foo { } function foo() : \Humbug\Foo { } -function foo() : ?\Humbug\Foo +function foo() : ?Foo { } function foo() : ?\Humbug\Foo { } -function foo() : \ArrayIterator +function foo() : ArrayIterator { } function foo() : \ArrayIterator { } -function foo() : ?\ArrayIterator +function foo() : ?ArrayIterator { } function foo() : ?\ArrayIterator diff --git a/specs/function/global-scope-global-func-with-single-level-use-statement-and-alias.php b/specs/function/global-scope-global-func-with-single-level-use-statement-and-alias.php index 5dd25fc1..65f718e0 100644 --- a/specs/function/global-scope-global-func-with-single-level-use-statement-and-alias.php +++ b/specs/function/global-scope-global-func-with-single-level-use-statement-and-alias.php @@ -37,7 +37,7 @@ namespace Humbug; use function Humbug\main as foo; -\Humbug\main(); +foo(); PHP , @@ -59,7 +59,7 @@ namespace Humbug; use function Humbug\main as foo; -\Humbug\main(); +foo(); PHP ], diff --git a/specs/function/global-scope-global-func-with-single-level-use-statement.php b/specs/function/global-scope-global-func-with-single-level-use-statement.php index 7b7735cd..5b002f17 100644 --- a/specs/function/global-scope-global-func-with-single-level-use-statement.php +++ b/specs/function/global-scope-global-func-with-single-level-use-statement.php @@ -37,7 +37,7 @@ namespace Humbug; use function Humbug\main; -\Humbug\main(); +main(); PHP , @@ -54,7 +54,7 @@ namespace Humbug; use function Humbug\main; -\Humbug\main(); +MAIN(); PHP , @@ -76,7 +76,7 @@ namespace Humbug; use function Humbug\main; -\Humbug\main(); +main(); PHP ], diff --git a/specs/function/global-scope-single-part-namespaced-func-with-single-level-use-and-alias.php b/specs/function/global-scope-single-part-namespaced-func-with-single-level-use-and-alias.php index d4ab3b7e..de7aaad2 100644 --- a/specs/function/global-scope-single-part-namespaced-func-with-single-level-use-and-alias.php +++ b/specs/function/global-scope-single-part-namespaced-func-with-single-level-use-and-alias.php @@ -57,7 +57,7 @@ function main() namespace Humbug; use Humbug\Foo as X; -\Humbug\Foo\main(); +X\main(); PHP , @@ -136,7 +136,7 @@ function main() namespace Humbug; use Humbug\Foo as X; -\Humbug\Foo\main(); +X\main(); PHP ], diff --git a/specs/function/global-scope-single-part-namespaced-func-with-single-level-use.php b/specs/function/global-scope-single-part-namespaced-func-with-single-level-use.php index 22a3c19f..339ebb7f 100644 --- a/specs/function/global-scope-single-part-namespaced-func-with-single-level-use.php +++ b/specs/function/global-scope-single-part-namespaced-func-with-single-level-use.php @@ -42,7 +42,7 @@ class Foo { } use Humbug\Foo; -\Humbug\Foo\main(); +Foo\main(); PHP , @@ -106,7 +106,7 @@ function main() namespace Humbug; use Humbug\Foo; -\Humbug\Foo\main(); +Foo\main(); PHP ], diff --git a/specs/function/namespace-global-func-with-single-level-use-statement-and-alias.php b/specs/function/namespace-global-func-with-single-level-use-statement-and-alias.php index b5e57b84..e0c19075 100644 --- a/specs/function/namespace-global-func-with-single-level-use-statement-and-alias.php +++ b/specs/function/namespace-global-func-with-single-level-use-statement-and-alias.php @@ -39,7 +39,7 @@ namespace Humbug\X; use function Humbug\main as foo; -\Humbug\main(); +foo(); PHP , diff --git a/specs/function/namespace-global-func-with-single-level-use-statement.php b/specs/function/namespace-global-func-with-single-level-use-statement.php index 6264b25d..9bb4a3cc 100644 --- a/specs/function/namespace-global-func-with-single-level-use-statement.php +++ b/specs/function/namespace-global-func-with-single-level-use-statement.php @@ -39,7 +39,7 @@ namespace Humbug\A; use function Humbug\main; -\Humbug\main(); +main(); PHP , diff --git a/specs/function/native-func.php b/specs/function/native-func.php index 0c4e1950..14dd998f 100644 --- a/specs/function/native-func.php +++ b/specs/function/native-func.php @@ -57,7 +57,7 @@ namespace Humbug\Acme; use function Humbug\Acme\is_array; -$x = \Humbug\Acme\is_array([]); +$x = is_array([]); PHP , diff --git a/specs/misc/class-FQ.php b/specs/misc/class-FQ.php index 6af6ee75..3dd852f1 100644 --- a/specs/misc/class-FQ.php +++ b/specs/misc/class-FQ.php @@ -93,13 +93,13 @@ class Poz use Humbug\Foo\Bar as Y; use Humbug\Foo\Bar\Poz as Z; \Humbug\Foo::MAIN_CONST; -\Humbug\Foo::MAIN_CONST; -\Humbug\Foo\Bar::MAIN_CONST; -\Humbug\Foo\Bar::MAIN_CONST; +X::MAIN_CONST; +Y::MAIN_CONST; +X\Bar::MAIN_CONST; \Humbug\Foo\Bar::MAIN_CONST; -\Humbug\Foo\Bar\Poz::MAIN_CONST; -\Humbug\Foo\Bar\Poz::MAIN_CONST; -\Humbug\Foo\Bar\Poz::MAIN_CONST; +Z::MAIN_CONST; +Y\Poz::MAIN_CONST; +X\Bar\Poz::MAIN_CONST; \Humbug\Foo\Bar\Poz::MAIN_CONST; PHP @@ -164,13 +164,13 @@ class Poz use Humbug\Foo\Bar as Y; use Humbug\Foo\Bar\Poz as Z; \Humbug\Foo::MAIN_CONST; -\Humbug\Foo::MAIN_CONST; -\Humbug\Foo\Bar::MAIN_CONST; -\Humbug\Foo\Bar::MAIN_CONST; +X::MAIN_CONST; +Y::MAIN_CONST; +X\Bar::MAIN_CONST; \Humbug\Foo\Bar::MAIN_CONST; -\Humbug\Foo\Bar\Poz::MAIN_CONST; -\Humbug\Foo\Bar\Poz::MAIN_CONST; -\Humbug\Foo\Bar\Poz::MAIN_CONST; +Z::MAIN_CONST; +Y\Poz::MAIN_CONST; +X\Bar\Poz::MAIN_CONST; \Humbug\Foo\Bar\Poz::MAIN_CONST; PHP @@ -327,13 +327,13 @@ class Poz \Humbug\A\Aoo\Aoz::MAIN_CONST; \Humbug\A\Aoo\Aoz\Poz::MAIN_CONST; \Humbug\A\Foo::MAIN_CONST; -\Humbug\Foo::MAIN_CONST; -\Humbug\Foo\Bar::MAIN_CONST; -\Humbug\Foo\Bar::MAIN_CONST; +X::MAIN_CONST; +Y::MAIN_CONST; +X\Bar::MAIN_CONST; \Humbug\A\Foo\Bar::MAIN_CONST; -\Humbug\Foo\Bar\Poz::MAIN_CONST; -\Humbug\Foo\Bar\Poz::MAIN_CONST; -\Humbug\Foo\Bar\Poz::MAIN_CONST; +Z::MAIN_CONST; +Y\Poz::MAIN_CONST; +X\Bar\Poz::MAIN_CONST; \Humbug\A\Foo\Bar\Poz::MAIN_CONST; PHP diff --git a/specs/misc/date.php b/specs/misc/date.php index faf18a70..010ba990 100644 --- a/specs/misc/date.php +++ b/specs/misc/date.php @@ -98,16 +98,16 @@ use DateTimeImmutable; const ISO8601_BASIC = 'Humbug\\Ymd\\THis\\Z'; new \Humbug\Acme\Foo('Humbug\\d\\H\\Z'); -new \DateTime('d\\H\\Z'); -new \DateTimeImmutable('d\\H\\Z'); +new DateTime('d\\H\\Z'); +new DateTimeImmutable('d\\H\\Z'); \date_create('d\\H\\Z'); \date('d\\H\\Z'); \gmdate('d\\H\\Z'); -\DateTime::createFromFormat('d\\H\\Z', '15\\Feb\\2009'); -\DateTimeImmutable::createFromFormat('d\\H\\Z', '15\\Feb\\2009'); +DateTime::createFromFormat('d\\H\\Z', '15\\Feb\\2009'); +DateTimeImmutable::createFromFormat('d\\H\\Z', '15\\Feb\\2009'); \date_create_from_format('d\\H\\Z', '15\\Feb\\2009'); -(new \DateTime('now'))->format('Humbug\\d\\H\\Z'); -\date_format(new \DateTime('now'), 'Humbug\\d\\H\\Z'); +(new DateTime('now'))->format('Humbug\\d\\H\\Z'); +\date_format(new DateTime('now'), 'Humbug\\d\\H\\Z'); PHP , diff --git a/specs/misc/internal-symbols.php b/specs/misc/internal-symbols.php index 37bf609f..3cc5bec3 100644 --- a/specs/misc/internal-symbols.php +++ b/specs/misc/internal-symbols.php @@ -464,22 +464,22 @@ \uv_fs_poll_stop(); \uv_stop(); \uv_signal_stop(); -\parallel\bootstrap(); -\parallel\run(); -\pcov\collect(); -\pcov\start(); -\pcov\stop(); -\pcov\clear(); -\pcov\waiting(); -\pcov\memory(); +bootstrap(); +run(); +collect(); +start(); +stop(); +clear(); +waiting(); +memory(); \mb_str_split(); \password_algos(); echo \STDIN; echo \STDOUT; echo \STDERR; -echo \pcov\all; -echo \pcov\inclusive; -echo \pcov\exclusive; +echo all; +echo inclusive; +echo exclusive; PHP , diff --git a/specs/misc/match.php b/specs/misc/match.php index 04646708..7cc30fb4 100644 --- a/specs/misc/match.php +++ b/specs/misc/match.php @@ -45,7 +45,7 @@ interface Match {} namespace Humbug\Acme; use Humbug\Acme\Foo\Match; -class Foo implements \Humbug\Acme\Foo\Match +class Foo implements Match { } namespace Humbug\Acme\Foo; diff --git a/specs/misc/misc.php b/specs/misc/misc.php index b0467fd8..5ce09dd7 100644 --- a/specs/misc/misc.php +++ b/specs/misc/misc.php @@ -77,8 +77,8 @@ class StdClasS use Humbug\FOO\x as Y; use Humbug\Foo\stdClass; -\var_dump(new \Humbug\FOO\x()); -\var_dump(new \Humbug\Foo\stdClass()); +\var_dump(new y()); +\var_dump(new STDCLASS()); PHP , diff --git a/specs/misc/whitelist-case-sensitiveness.php b/specs/misc/whitelist-case-sensitiveness.php index bf4e2879..d2e06e9f 100644 --- a/specs/misc/whitelist-case-sensitiveness.php +++ b/specs/misc/whitelist-case-sensitiveness.php @@ -142,11 +142,11 @@ public function foo() use Acme\Foo; use const Acme\FOO; use const Acme\BAR; -new \Acme\Foo(); +new Foo(); new \acmE\Foo(); -\Acme\FOO; +FOO; \acmE\FOO; -\Acme\BAR; +BAR; \acmE\BAR; PHP diff --git a/specs/new/global-scope-single-part-with-single-level-use-statement-and-alias.php b/specs/new/global-scope-single-part-with-single-level-use-statement-and-alias.php index 50e6c285..18fb0d47 100644 --- a/specs/new/global-scope-single-part-with-single-level-use-statement-and-alias.php +++ b/specs/new/global-scope-single-part-with-single-level-use-statement-and-alias.php @@ -49,7 +49,7 @@ class Foo namespace Humbug; use Humbug\Foo as X; -new \Humbug\Foo(); +new X(); PHP ], @@ -162,7 +162,7 @@ class X namespace Humbug; use ArrayIterator as X; -new \ArrayIterator([]); +new X([]); PHP ], diff --git a/specs/new/global-scope-single-part-with-single-level-use-statement.php b/specs/new/global-scope-single-part-with-single-level-use-statement.php index 1656b8d7..c3cb517a 100644 --- a/specs/new/global-scope-single-part-with-single-level-use-statement.php +++ b/specs/new/global-scope-single-part-with-single-level-use-statement.php @@ -49,7 +49,7 @@ class Foo namespace Humbug; use Humbug\Foo; -new \Humbug\Foo(); +new Foo(); PHP ], @@ -96,7 +96,7 @@ class Foo namespace Humbug; use ArrayIterator; -new \ArrayIterator([]); +new ArrayIterator([]); PHP ], diff --git a/specs/new/global-scope-two-parts-with-single-level-use-and-alias.php b/specs/new/global-scope-two-parts-with-single-level-use-and-alias.php index c97312c7..7fd03287 100644 --- a/specs/new/global-scope-two-parts-with-single-level-use-and-alias.php +++ b/specs/new/global-scope-two-parts-with-single-level-use-and-alias.php @@ -58,7 +58,7 @@ class Bar namespace Humbug; use Humbug\Foo as A; -new \Humbug\Foo\Bar(); +new A\Bar(); PHP ], @@ -96,7 +96,7 @@ class Bar namespace Humbug; use Humbug\Foo\Bar as A; -new \Humbug\Foo\Bar(); +new A(); PHP ], @@ -215,7 +215,7 @@ class Bar namespace Humbug; use Humbug\Foo as A; -new \Humbug\Foo\Bar(); +new A\Bar(); PHP ], @@ -249,7 +249,7 @@ class Bar namespace Humbug; use Humbug\Foo\Bar as A; -new \Humbug\Foo\Bar(); +new A(); PHP ], diff --git a/specs/new/global-scope-two-parts-with-single-level-use.php b/specs/new/global-scope-two-parts-with-single-level-use.php index 56f7b4e5..847e2ef9 100644 --- a/specs/new/global-scope-two-parts-with-single-level-use.php +++ b/specs/new/global-scope-two-parts-with-single-level-use.php @@ -58,7 +58,7 @@ class Bar namespace Humbug; use Humbug\Foo; -new \Humbug\Foo\Bar(); +new Foo\Bar(); PHP ], @@ -101,7 +101,7 @@ class Bar namespace Humbug; use Humbug\Foo; -new \Humbug\Foo\Bar(); +new Foo\Bar(); PHP ], @@ -220,7 +220,7 @@ class Bar namespace Humbug; use Humbug\Foo\Bar; -new \Humbug\Foo\Bar(); +new Bar(); PHP ], @@ -263,7 +263,7 @@ class Bar namespace Humbug; use Humbug\Foo\Bar; -new \Humbug\Foo\Bar(); +new Bar(); PHP ], diff --git a/specs/new/namespace-single-part-with-single-level-use-statement.php b/specs/new/namespace-single-part-with-single-level-use-statement.php index 52b74990..07bfa780 100644 --- a/specs/new/namespace-single-part-with-single-level-use-statement.php +++ b/specs/new/namespace-single-part-with-single-level-use-statement.php @@ -50,7 +50,7 @@ class Foo namespace Humbug\A; use Humbug\Foo; -new \Humbug\Foo(); +new Foo(); PHP ], diff --git a/specs/new/namespace-two-parts-with-single-level-use.php b/specs/new/namespace-two-parts-with-single-level-use.php index d0ef96bf..3f1b2363 100644 --- a/specs/new/namespace-two-parts-with-single-level-use.php +++ b/specs/new/namespace-two-parts-with-single-level-use.php @@ -49,7 +49,7 @@ class Foo namespace Humbug\A; use Humbug\Foo; -new \Humbug\Foo(); +new Foo(); PHP ], diff --git a/specs/new/namespace-two-parts-with-two-level-use.php b/specs/new/namespace-two-parts-with-two-level-use.php index dcece728..cfc5342f 100644 --- a/specs/new/namespace-two-parts-with-two-level-use.php +++ b/specs/new/namespace-two-parts-with-two-level-use.php @@ -58,7 +58,7 @@ class Bar namespace Humbug\A; use Humbug\X\Foo; -new \Humbug\X\Foo\Bar(); +new Foo\Bar(); PHP ], @@ -139,7 +139,7 @@ class Bar namespace Humbug\A; use Humbug\X\Foo; -new \Humbug\X\Foo\Bar(); +new Foo\Bar(); PHP ], diff --git a/specs/special-keywords/self-parent-return-type.php b/specs/special-keywords/self-parent-return-type.php index 1da0ed63..bba30636 100644 --- a/specs/special-keywords/self-parent-return-type.php +++ b/specs/special-keywords/self-parent-return-type.php @@ -168,7 +168,7 @@ public function normalize() : parent namespace Humbug; use Humbug\Foo\B; -echo (new \Humbug\Foo\B('yo'))->normalize()->getName() . \PHP_EOL; +echo (new B('yo'))->normalize()->getName() . \PHP_EOL; PHP , diff --git a/specs/special-keywords/self-static-parent-const.php b/specs/special-keywords/self-static-parent-const.php index 2cfa1bae..1b957be2 100644 --- a/specs/special-keywords/self-static-parent-const.php +++ b/specs/special-keywords/self-static-parent-const.php @@ -176,8 +176,8 @@ public function __construct(string $name) namespace Humbug; use Humbug\Foo\B; -\Humbug\Foo\B::test(); -echo (new \Humbug\Foo\B('yo'))->getName() . \PHP_EOL; +B::test(); +echo (new B('yo'))->getName() . \PHP_EOL; PHP , diff --git a/specs/special-keywords/self-static-parent-method.php b/specs/special-keywords/self-static-parent-method.php index 9fddc508..05ce3ade 100644 --- a/specs/special-keywords/self-static-parent-method.php +++ b/specs/special-keywords/self-static-parent-method.php @@ -228,8 +228,8 @@ public static function who() namespace Humbug; use Humbug\Foo\B; -\Humbug\Foo\B::test(); -echo (new \Humbug\Foo\B('yo'))->getName() . \PHP_EOL; +B::test(); +echo (new B('yo'))->getName() . \PHP_EOL; PHP , diff --git a/specs/special-keywords/self-static-parent-static-var.php b/specs/special-keywords/self-static-parent-static-var.php index 4e24fa47..c277e71d 100644 --- a/specs/special-keywords/self-static-parent-static-var.php +++ b/specs/special-keywords/self-static-parent-static-var.php @@ -176,8 +176,8 @@ public function __construct(string $name) namespace Humbug; use Humbug\Foo\B; -\Humbug\Foo\B::test(); -echo (new \Humbug\Foo\B('yo'))->getName() . \PHP_EOL; +B::test(); +echo (new B('yo'))->getName() . \PHP_EOL; PHP , diff --git a/specs/static-method/global-scope-single-part-with-single-level-use-statement-and-alias.php b/specs/static-method/global-scope-single-part-with-single-level-use-statement-and-alias.php index fe4d4c28..fafca497 100644 --- a/specs/static-method/global-scope-single-part-with-single-level-use-statement-and-alias.php +++ b/specs/static-method/global-scope-single-part-with-single-level-use-statement-and-alias.php @@ -42,7 +42,7 @@ class Foo { } use Humbug\Foo as X; -\Humbug\Foo::main(); +X::main(); PHP , @@ -85,7 +85,7 @@ class X namespace Humbug; use Closure as X; -\Closure::bind(); +X::bind(); PHP , diff --git a/specs/static-method/global-scope-single-part-with-single-level-use-statement.php b/specs/static-method/global-scope-single-part-with-single-level-use-statement.php index 86e7296e..563d23d3 100644 --- a/specs/static-method/global-scope-single-part-with-single-level-use-statement.php +++ b/specs/static-method/global-scope-single-part-with-single-level-use-statement.php @@ -42,7 +42,7 @@ class Foo { } use Humbug\Foo; -\Humbug\Foo::main(); +Foo::main(); PHP , @@ -81,7 +81,7 @@ class Foo namespace Humbug; use Closure; -\Closure::bind(); +Closure::bind(); PHP , diff --git a/specs/static-method/global-scope-two-parts-with-single-level-use-and-alias.php b/specs/static-method/global-scope-two-parts-with-single-level-use-and-alias.php index 6864dba2..214444ff 100644 --- a/specs/static-method/global-scope-two-parts-with-single-level-use-and-alias.php +++ b/specs/static-method/global-scope-two-parts-with-single-level-use-and-alias.php @@ -57,7 +57,7 @@ class Bar namespace Humbug; use Humbug\Foo as A; -\Humbug\Foo\Bar::main(); +A\Bar::main(); PHP , @@ -85,7 +85,7 @@ class Bar namespace Humbug; use Humbug\Foo\Bar as A; -\Humbug\Foo\Bar::main(); +A::main(); PHP , @@ -198,7 +198,7 @@ class Bar namespace Humbug; use Humbug\Foo as A; -\Humbug\Foo\Bar::main(); +A\Bar::main(); PHP ], @@ -232,7 +232,7 @@ class Bar namespace Humbug; use Humbug\Foo\Bar as A; -\Humbug\Foo\Bar::main(); +A::main(); PHP ], diff --git a/specs/static-method/global-scope-two-parts-with-single-level-use.php b/specs/static-method/global-scope-two-parts-with-single-level-use.php index 817fe544..0f3c1996 100644 --- a/specs/static-method/global-scope-two-parts-with-single-level-use.php +++ b/specs/static-method/global-scope-two-parts-with-single-level-use.php @@ -57,7 +57,7 @@ class Bar namespace Humbug; use Humbug\Foo; -\Humbug\Foo\Bar::main(); +Foo\Bar::main(); PHP , @@ -85,7 +85,7 @@ class Bar namespace Humbug; use Humbug\Foo\Bar; -\Humbug\Foo\Bar::main(); +Bar::main(); PHP , @@ -198,12 +198,12 @@ class Bar namespace Humbug; use Humbug\Foo; -\Humbug\Foo\Bar::main(); +Foo\Bar::main(); PHP ], - 'Static method call statement of a whitelisted namespaced class imported with a use statement' => [ + 'SStatic method call statement of a whitelisted namespaced class partially imported with a use statementtatic method call statement of a whitelisted namespaced class imported with a use statement' => [ 'whitelist' => ['Foo\Bar'], 'registered-classes' => [ ['Foo\Bar', 'Humbug\Foo\Bar'], @@ -232,7 +232,7 @@ class Bar namespace Humbug; use Humbug\Foo\Bar; -\Humbug\Foo\Bar::main(); +Bar::main(); PHP ], diff --git a/specs/static-method/namespace-single-part-with-single-level-use-statement.php b/specs/static-method/namespace-single-part-with-single-level-use-statement.php index cc7e42f7..1e104caf 100644 --- a/specs/static-method/namespace-single-part-with-single-level-use-statement.php +++ b/specs/static-method/namespace-single-part-with-single-level-use-statement.php @@ -49,7 +49,7 @@ class Foo namespace Humbug\A; use Humbug\Foo; -\Humbug\Foo::main(); +Foo::main(); PHP , @@ -96,7 +96,7 @@ class Foo namespace Humbug\A; use Closure; -\Closure::bind(); +Closure::bind(); PHP , diff --git a/specs/static-method/namespace-two-parts-with-single-level-use.php b/specs/static-method/namespace-two-parts-with-single-level-use.php index 623a9dab..7fb431ef 100644 --- a/specs/static-method/namespace-two-parts-with-single-level-use.php +++ b/specs/static-method/namespace-two-parts-with-single-level-use.php @@ -48,7 +48,7 @@ class Foo namespace Humbug\A; use Humbug\Foo; -\Humbug\Foo::main(); +Foo::main(); PHP , @@ -95,7 +95,7 @@ class Foo namespace Humbug\A; use Closure; -\Closure::bind(); +Closure::bind(); PHP , diff --git a/specs/static-method/namespace-two-parts-with-two-level-use.php b/specs/static-method/namespace-two-parts-with-two-level-use.php index 0a92f5ec..42b3fc67 100644 --- a/specs/static-method/namespace-two-parts-with-two-level-use.php +++ b/specs/static-method/namespace-two-parts-with-two-level-use.php @@ -57,7 +57,7 @@ class Bar namespace Humbug\A; use Humbug\X\Foo; -\Humbug\X\Foo\Bar::main(); +Foo\Bar::main(); PHP , @@ -137,7 +137,7 @@ class Bar namespace Humbug\A; use Humbug\X\Foo; -\Humbug\X\Foo\Bar::main(); +Foo\Bar::main(); PHP ], diff --git a/specs/use/use-class-group.php b/specs/use/use-class-group.php index 0cde2f59..eed0fdc5 100644 --- a/specs/use/use-class-group.php +++ b/specs/use/use-class-group.php @@ -48,11 +48,11 @@ use Humbug\A\D; use Humbug\A\B\C\D as ABCD; use Humbug\A\B\E; -\Humbug\A\B::class; -\Humbug\A\B\C::class; -\Humbug\A\D::class; -\Humbug\A\B\C\D::class; -\Humbug\A\B\E::class; +B::class; +C::class; +D::class; +ABCD::class; +E::class; PHP , @@ -106,11 +106,11 @@ use Humbug\A\D; use Humbug\A\B\C\G; use Humbug\A\B\E; -\Humbug\A\B::class; -\Humbug\A\B\C::class; -\Humbug\A\D::class; -\Humbug\A\B\C\G::class; -\Humbug\A\B\E::class; +B::class; +C::class; +D::class; +G::class; +E::class; PHP ], diff --git a/specs/use/use-const-group.php b/specs/use/use-const-group.php index af8275f9..2d25bfcd 100644 --- a/specs/use/use-const-group.php +++ b/specs/use/use-const-group.php @@ -48,11 +48,11 @@ use const Humbug\A\D; use const Humbug\A\B\C\D as ABCD; use const Humbug\A\B\E; -\Humbug\A\B; -\Humbug\A\B\C; -\Humbug\A\D; -\Humbug\A\B\C\D; -\Humbug\A\B\E; +B; +C; +D; +ABCD; +E; PHP , diff --git a/specs/use/use-func-group.php b/specs/use/use-func-group.php index 961f5c75..43f0459a 100644 --- a/specs/use/use-func-group.php +++ b/specs/use/use-func-group.php @@ -48,11 +48,11 @@ use function Humbug\A\d; use function Humbug\A\B\C\g; use function Humbug\A\B\e; -\Humbug\A\b(); -\Humbug\A\B\c(); -\Humbug\A\d(); -\Humbug\A\B\C\g(); -\Humbug\A\B\e(); +b(); +c(); +d(); +g(); +e(); PHP , diff --git a/specs/use/use-mix-group.php b/specs/use/use-mix-group.php index 51f84166..1564646d 100644 --- a/specs/use/use-mix-group.php +++ b/specs/use/use-mix-group.php @@ -42,9 +42,9 @@ use Humbug\A\B\C\D; use function Humbug\A\B\b\c; use const Humbug\A\B\D; -\Humbug\A\B\C\D::class; -\Humbug\A\B\b\c(); -\Humbug\A\B\D; +D::class; +c(); +D; PHP , diff --git a/src/PhpParser/NodeVisitor/NameStmtPrefixer.php b/src/PhpParser/NodeVisitor/NameStmtPrefixer.php index ae26530d..178ce198 100644 --- a/src/PhpParser/NodeVisitor/NameStmtPrefixer.php +++ b/src/PhpParser/NodeVisitor/NameStmtPrefixer.php @@ -15,7 +15,9 @@ namespace Humbug\PhpScoper\PhpParser\NodeVisitor; use Humbug\PhpScoper\PhpParser\Node\FullyQualifiedFactory; +use Humbug\PhpScoper\PhpParser\NodeVisitor\NamespaceStmt\NamespaceStmtCollection; use Humbug\PhpScoper\PhpParser\NodeVisitor\Resolver\FullyQualifiedNameResolver; +use Humbug\PhpScoper\PhpParser\NodeVisitor\UseStmt\UseStmtCollection; use Humbug\PhpScoper\Reflector; use Humbug\PhpScoper\Whitelist; use PhpParser\Node; @@ -38,6 +40,7 @@ use PhpParser\Node\Stmt\Interface_; use PhpParser\Node\Stmt\Property; use PhpParser\NodeVisitorAbstract; +use function count; use function in_array; /** @@ -65,17 +68,23 @@ final class NameStmtPrefixer extends NodeVisitorAbstract private $prefix; private $whitelist; + private $namespaceStatements; + private $useStatements; private $nameResolver; private $reflector; public function __construct( string $prefix, Whitelist $whitelist, + NamespaceStmtCollection $namespaceStatements, + UseStmtCollection $useStatements, FullyQualifiedNameResolver $nameResolver, Reflector $reflector ) { $this->prefix = $prefix; $this->whitelist = $whitelist; + $this->namespaceStatements = $namespaceStatements; + $this->useStatements = $useStatements; $this->nameResolver = $nameResolver; $this->reflector = $reflector; } @@ -146,6 +155,30 @@ private function prefixName(Name $name): Node $resolvedName = $this->nameResolver->resolveName($name)->getName(); + // Do not prefix if there is a matching use statement. + $useStatement = $this->useStatements->findStatementForNode($this->namespaceStatements->findNamespaceForNode($name), $name); + + if ( + $useStatement !== null + && !($name instanceof FullyQualified) + && self::array_starts_with($resolvedName->parts, $useStatement->parts) + && !( + $parentNode instanceof ConstFetch + && ( + $this->whitelist->isGlobalWhitelistedConstant($resolvedName->toString()) + || $this->whitelist->isSymbolWhitelisted($resolvedName->toString(), true) + ) + ) + && !( + $useStatement->getAttribute('parent') + && $useStatement->getAttribute('parent')->alias !== null + && $this->whitelist->isSymbolWhitelisted($useStatement->toString()) + ) + && $resolvedName->parts !== ['Isolated', 'Symfony', 'Component', 'Finder', 'Finder'] + ) { + return $name; + } + if ($this->prefix === $resolvedName->getFirst() // Skip if is already prefixed || $this->whitelist->belongsToWhitelistedNamespace((string) $resolvedName) // Skip if the namespace node is whitelisted ) { @@ -204,4 +237,15 @@ private function prefixName(Name $name): Node $resolvedName->getAttributes() ); } + + private static function array_starts_with($arr, $prefix): bool + { + $prefixLength = count($prefix); + for ($i = 0; $i < $prefixLength; ++$i) { + if ($arr[$i] !== $prefix[$i]) { + return false; + } + } + return true; + } } diff --git a/src/PhpParser/NodeVisitor/StringScalarPrefixer.php b/src/PhpParser/NodeVisitor/StringScalarPrefixer.php index 8b6a9507..5cd81f94 100644 --- a/src/PhpParser/NodeVisitor/StringScalarPrefixer.php +++ b/src/PhpParser/NodeVisitor/StringScalarPrefixer.php @@ -174,7 +174,7 @@ private function prefixNewStringArg(String_ $string, New_ $newNode): String_ { $class = $newNode->class; - if (false === ($class instanceof FullyQualified)) { + if (false === ($class instanceof Name)) { return $this->createPrefixedStringIfDoesNotBelongToGlobalNamespace($string); } @@ -236,7 +236,7 @@ private function prefixStaticCallStringArg(String_ $string, StaticCall $callNode { $class = $callNode->class; - if (false === ($class instanceof FullyQualified)) { + if (false === ($class instanceof Name)) { return $this->createPrefixedStringIfDoesNotBelongToGlobalNamespace($string); } diff --git a/src/PhpParser/TraverserFactory.php b/src/PhpParser/TraverserFactory.php index 948aca07..03de5ab2 100644 --- a/src/PhpParser/TraverserFactory.php +++ b/src/PhpParser/TraverserFactory.php @@ -52,7 +52,7 @@ public function create(PhpScoper $scoper, string $prefix, Whitelist $whitelist): $traverser->addVisitor(new NodeVisitor\NamespaceStmt\FunctionIdentifierRecorder($prefix, $nameResolver, $whitelist, $this->reflector)); $traverser->addVisitor(new NodeVisitor\ClassIdentifierRecorder($prefix, $nameResolver, $whitelist)); - $traverser->addVisitor(new NodeVisitor\NameStmtPrefixer($prefix, $whitelist, $nameResolver, $this->reflector)); + $traverser->addVisitor(new NodeVisitor\NameStmtPrefixer($prefix, $whitelist, $namespaceStatements, $useStatements, $nameResolver, $this->reflector)); $traverser->addVisitor(new NodeVisitor\StringScalarPrefixer($prefix, $whitelist, $this->reflector)); $traverser->addVisitor(new NodeVisitor\NewdocPrefixer($scoper, $prefix, $whitelist)); $traverser->addVisitor(new NodeVisitor\EvalPrefixer($scoper, $prefix, $whitelist));