From e865ba8ddccca517cd6204c835f7ff57e3d11cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Mon, 23 Jul 2018 08:56:08 +0200 Subject: [PATCH 1/3] WIP --- specs/binary/simple.php | 2 + specs/class-FQ.php | 2 + ...h-single-level-use-statement-and-alias.php | 2 + ...-level-with-single-level-use-statement.php | 2 + .../class-const/global-scope-single-level.php | 2 + ...-level-with-single-level-use-and-alias.php | 2 + ...-scope-two-level-with-single-level-use.php | 2 + specs/class-const/global-scope-two-level.php | 2 + ...h-single-level-use-statement-and-alias.php | 2 + .../namespace-scope-single-level.php | 2 + ...-level-with-single-level-use-and-alias.php | 2 + ...-scope-two-level-with-single-level-use.php | 2 + .../class-const/namespace-scope-two-level.php | 2 + ...e-part-with-single-level-use-statement.php | 2 + ...h-single-level-use-statement-and-alias.php | 2 + ...-level-with-single-level-use-statement.php | 2 + .../global-scope-single-level.php | 2 + ...-level-with-single-level-use-and-alias.php | 2 + ...-scope-two-level-with-single-level-use.php | 2 + .../global-scope-two-level.php | 2 + ...h-single-level-use-statement-and-alias.php | 2 + .../namespace-scope-single-level.php | 2 + ...-level-with-single-level-use-and-alias.php | 2 + ...-scope-two-level-with-single-level-use.php | 2 + .../namespace-scope-two-level.php | 2 + ...e-part-with-single-level-use-statement.php | 2 + specs/class/abstract.php | 2 + specs/class/anonymous.php | 2 + specs/class/conditional.php | 2 + specs/class/final.php | 2 + specs/class/interface.php | 2 + specs/class/regular-extend.php | 2 + specs/class/regular.php | 2 + specs/class/trait.php | 2 + ...t-declaration-with-global-whitelisting.php | 2 + specs/const/const-declaration.php | 2 + ...-scope-global-with-global-whitelisting.php | 2 + ...h-single-level-use-statement-and-alias.php | 2 + ...use-statement-with-global-whitelisting.php | 2 + ...global-with-single-level-use-statement.php | 2 + specs/const/global-scope-global.php | 2 + ...namespaced-with-single-level-use-alias.php | 2 + ...-part-namespaced-with-single-level-use.php | 2 + .../global-scope-single-part-namespaced.php | 2 + ...spaced-with-single-level-use-and-alias.php | 2 + ...parts-namespaced-with-single-level-use.php | 2 + .../global-scope-two-parts-namespaced.php | 2 + ...espace-global-with-global-whitelisting.php | 2 + ...h-single-level-use-statement-and-alias.php | 2 + ...global-with-single-level-use-statement.php | 2 + specs/const/namespace-global.php | 2 + .../namespace-single-part-namespaced.php | 2 + .../native-const-with-global-whitelisting.php | 2 + specs/const/native-const.php | 2 + specs/exp/cast.php | 2 + specs/exp/catch.php | 2 + specs/exp/instanceof.php | 2 + specs/func-declaration/global.php | 16 +- specs/func-declaration/method.php | 2 + specs/func-declaration/namespace.php | 2 + ...h-single-level-use-statement-and-alias.php | 4 +- ...l-func-with-single-level-use-statement.php | 2 + specs/function/global-scope-global-func.php | 2 + ...d-func-with-single-level-use-and-alias.php | 5 + ...-namespaced-func-with-single-level-use.php | 2 + ...obal-scope-single-part-namespaced-func.php | 2 + ...h-single-level-use-statement-and-alias.php | 4 +- ...l-func-with-single-level-use-statement.php | 4 +- specs/function/namespace-global-func.php | 2 + .../function/namespace-global-scope-func.php | 2 + .../namespace-single-part-namespaced-func.php | 2 + specs/function/native-func.php | 2 + specs/misc.php | 2 + specs/namespace/after-hashbang.php | 2 + specs/namespace/braces.php | 2 + specs/namespace/creation-for-whitelist.php | 2 + specs/namespace/no-braces.php | 2 + specs/namespace/outside-statements.php | 2 + ...th-single-level-use-statement-an-alias.php | 2 + ...e-part-with-single-level-use-statement.php | 2 + specs/new/global-scope-single-part.php | 4 +- ...-parts-with-single-level-use-and-alias.php | 2 + ...-scope-two-parts-with-single-level-use.php | 2 + specs/new/global-scope-two-parts.php | 2 + ...e-part-with-single-level-use-statement.php | 2 + specs/new/namespace-single-part.php | 2 + ...espace-two-parts-with-single-level-use.php | 2 + ...namespace-two-parts-with-two-level-use.php | 2 + specs/new/namespace-two-parts.php | 2 + .../self-static-parent-const.php | 2 + .../self-static-parent-method.php | 2 + .../self-static-parent-static-var.php | 2 + ...h-single-level-use-statement-and-alias.php | 2 + ...e-part-with-single-level-use-statement.php | 2 + .../global-scope-single-part.php | 2 + ...-parts-with-single-level-use-and-alias.php | 2 + ...-scope-two-parts-with-single-level-use.php | 2 + .../static-method/global-scope-two-parts.php | 2 + ...e-part-with-single-level-use-statement.php | 2 + specs/static-method/namespace-single-part.php | 2 + ...espace-two-parts-with-single-level-use.php | 2 + ...namespace-two-parts-with-two-level-use.php | 2 + specs/static-method/namespace-two-parts.php | 2 + specs/string-literal/array-var.php | 2 + specs/string-literal/class-const-array.php | 2 + specs/string-literal/class-const.php | 2 + specs/string-literal/class-prop.php | 2 + specs/string-literal/class-var.php | 2 + specs/string-literal/const.php | 2 + specs/string-literal/define-value.php | 2 + specs/string-literal/func-arg.php | 2 + specs/string-literal/method-arg.php | 2 + specs/string-literal/misc.php | 2 + specs/string-literal/new.php | 2 + specs/string-literal/var.php | 2 + specs/use/use-class-alias.php | 2 + specs/use/use-class-group.php | 2 + specs/use/use-class.php | 2 + specs/use/use-const-alias.php | 2 + specs/use/use-const-group.php | 2 + specs/use/use-const.php | 2 + specs/use/use-func-alias.php | 2 + specs/use/use-func-group.php | 2 + specs/use/use-func.php | 2 + specs/use/use-mix-group.php | 2 + specs/whitelist-case-sensitiveness.php | 2 + src/Autoload/ScoperAutoloadGenerator.php | 2 +- src/Whitelist.php | 4 +- tests/Scoper/PhpScoperSpecTest.php | 346 ++++++++++++++++++ tests/Scoper/PhpScoperTest.php | 171 --------- tests/WhitelistTest.php | 4 +- 131 files changed, 622 insertions(+), 182 deletions(-) create mode 100644 tests/Scoper/PhpScoperSpecTest.php diff --git a/specs/binary/simple.php b/specs/binary/simple.php index df7d471b..f69e4fb7 100644 --- a/specs/binary/simple.php +++ b/specs/binary/simple.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Some statements made directly in the global namespace' => <<<'PHP' diff --git a/specs/class-FQ.php b/specs/class-FQ.php index 50371163..dd6a3129 100644 --- a/specs/class-FQ.php +++ b/specs/class-FQ.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Different kind of whitelisted class constant calls in the global scope' => [ 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 3a7e3fee..eaf4b1e9 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace' => [ 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 c7729824..e2cee3c6 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a class which is imported via a use statement and which belongs to the global namespace' => [ diff --git a/specs/class-const/global-scope-single-level.php b/specs/class-const/global-scope-single-level.php index f0b4fefa..941bd43b 100644 --- a/specs/class-const/global-scope-single-level.php +++ b/specs/class-const/global-scope-single-level.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a class belonging to the global namespace' => [ 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 ac84d2a5..e0580cef 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a namespaced class partially imported with an aliased use statement' => [ 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 6bb36b0b..74f1bc40 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a namespaced class partially imported with a use statement' => [ diff --git a/specs/class-const/global-scope-two-level.php b/specs/class-const/global-scope-two-level.php index 88738e87..c477ee7a 100644 --- a/specs/class-const/global-scope-two-level.php +++ b/specs/class-const/global-scope-two-level.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a namespaced class' => [ 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 1399697f..794caf8c 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace' => [ diff --git a/specs/class-const/namespace-scope-single-level.php b/specs/class-const/namespace-scope-single-level.php index fde39f37..fb29df21 100644 --- a/specs/class-const/namespace-scope-single-level.php +++ b/specs/class-const/namespace-scope-single-level.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a class belonging to the global namespace or the current namespace' => [ 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 39af30f0..f597e41f 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a namespaced class partially imported with an aliased use statement' => [ 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 65062f47..6a8201d8 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a namespaced class partially imported with a use statement' => [ diff --git a/specs/class-const/namespace-scope-two-level.php b/specs/class-const/namespace-scope-two-level.php index 1377eab4..a886aa1a 100644 --- a/specs/class-const/namespace-scope-two-level.php +++ b/specs/class-const/namespace-scope-two-level.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a namespaced class' => [ 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 9c01279c..336ae183 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a class which is imported via a use statement and which belongs to the global namespace' => [ 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 773e176c..f5a43165 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace' => <<<'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 1e5d02c2..84ef395e 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a class which is imported via a use statement and which belongs to the global namespace' => <<<'PHP' diff --git a/specs/class-static-prop/global-scope-single-level.php b/specs/class-static-prop/global-scope-single-level.php index 4207f1ab..0775ec0b 100644 --- a/specs/class-static-prop/global-scope-single-level.php +++ b/specs/class-static-prop/global-scope-single-level.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a class belonging to the global namespace' => <<<'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 96178040..fd77534b 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a namespaced class partially imported with an aliased use statement' => <<<'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 a211cc25..db75b941 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a namespaced class partially imported with a use statement' => <<<'PHP' diff --git a/specs/class-static-prop/global-scope-two-level.php b/specs/class-static-prop/global-scope-two-level.php index fc1ec9cc..97b54811 100644 --- a/specs/class-static-prop/global-scope-two-level.php +++ b/specs/class-static-prop/global-scope-two-level.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a namespaced class' => <<<'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 30d0de5e..3bfc7ae6 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a aliased class which is imported via an aliased use statement and which belongs to the global namespace' => <<<'PHP' diff --git a/specs/class-static-prop/namespace-scope-single-level.php b/specs/class-static-prop/namespace-scope-single-level.php index a424820f..296332fe 100644 --- a/specs/class-static-prop/namespace-scope-single-level.php +++ b/specs/class-static-prop/namespace-scope-single-level.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a class belonging to the global namespace or the current namespace' => <<<'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 b0092cef..b2656150 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a namespaced class partially imported with an aliased use statement' => <<<'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 1ee81879..1f860f50 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a namespaced class partially imported with a use statement' => <<<'PHP' diff --git a/specs/class-static-prop/namespace-scope-two-level.php b/specs/class-static-prop/namespace-scope-two-level.php index caa83644..7c3352a4 100644 --- a/specs/class-static-prop/namespace-scope-two-level.php +++ b/specs/class-static-prop/namespace-scope-two-level.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a namespaced class' => <<<'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 75c3b1ee..50a82675 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on a class which is imported via a use statement and which belongs to the global namespace' => <<<'PHP' diff --git a/specs/class/abstract.php b/specs/class/abstract.php index 619b79a6..3707e21a 100644 --- a/specs/class/abstract.php +++ b/specs/class/abstract.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Declaration in the global namespace' => <<<'PHP' diff --git a/specs/class/anonymous.php b/specs/class/anonymous.php index ef3c2f95..33104724 100644 --- a/specs/class/anonymous.php +++ b/specs/class/anonymous.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Declaration in the global namespace' => <<<'PHP' diff --git a/specs/class/conditional.php b/specs/class/conditional.php index bd1e3bb2..0c80ed17 100644 --- a/specs/class/conditional.php +++ b/specs/class/conditional.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Declaration in the global namespace' => <<<'PHP' diff --git a/specs/class/final.php b/specs/class/final.php index 41323db5..c3518da9 100644 --- a/specs/class/final.php +++ b/specs/class/final.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Declaration in the global namespace' => <<<'PHP' diff --git a/specs/class/interface.php b/specs/class/interface.php index e1bbe8c5..cba471cf 100644 --- a/specs/class/interface.php +++ b/specs/class/interface.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Declaration in the global namespace' => <<<'PHP' diff --git a/specs/class/regular-extend.php b/specs/class/regular-extend.php index 03fc5aa4..b982a81b 100644 --- a/specs/class/regular-extend.php +++ b/specs/class/regular-extend.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Declaration in the global namespace' => <<<'PHP' diff --git a/specs/class/regular.php b/specs/class/regular.php index f8967878..5c1bbc79 100644 --- a/specs/class/regular.php +++ b/specs/class/regular.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Declaration in the global namespace' => <<<'PHP' diff --git a/specs/class/trait.php b/specs/class/trait.php index 02c6fb6d..e690279a 100644 --- a/specs/class/trait.php +++ b/specs/class/trait.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Declaration in the global namespace' => <<<'PHP' diff --git a/specs/const/const-declaration-with-global-whitelisting.php b/specs/const/const-declaration-with-global-whitelisting.php index 3b4c6666..9cc22438 100644 --- a/specs/const/const-declaration-with-global-whitelisting.php +++ b/specs/const/const-declaration-with-global-whitelisting.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constants declaration in the global namespace' => [ diff --git a/specs/const/const-declaration.php b/specs/const/const-declaration.php index 28210066..50d74d93 100644 --- a/specs/const/const-declaration.php +++ b/specs/const/const-declaration.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constants declaration in the global namespace' => [ diff --git a/specs/const/global-scope-global-with-global-whitelisting.php b/specs/const/global-scope-global-with-global-whitelisting.php index 2b07979b..e3f308b3 100644 --- a/specs/const/global-scope-global-with-global-whitelisting.php +++ b/specs/const/global-scope-global-with-global-whitelisting.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call in the global namespace' => <<<'PHP' 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 799695cc..480bfab6 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call imported with an aliased use statement' => <<<'PHP' diff --git a/specs/const/global-scope-global-with-single-level-use-statement-with-global-whitelisting.php b/specs/const/global-scope-global-with-single-level-use-statement-with-global-whitelisting.php index a509a918..b1cd1596 100644 --- a/specs/const/global-scope-global-with-single-level-use-statement-with-global-whitelisting.php +++ b/specs/const/global-scope-global-with-single-level-use-statement-with-global-whitelisting.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call imported with a use statement' => <<<'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 f6e721ec..ec9693f3 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call imported with a use statement' => <<<'PHP' diff --git a/specs/const/global-scope-global.php b/specs/const/global-scope-global.php index f8c9b0e7..b7be1b85 100644 --- a/specs/const/global-scope-global.php +++ b/specs/const/global-scope-global.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call in the global namespace' => <<<'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 81aff860..225437a8 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on an imported single-level namespace' => <<<'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 b108f73d..93b67725 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call on an imported single-level namespace' => <<<'PHP' diff --git a/specs/const/global-scope-single-part-namespaced.php b/specs/const/global-scope-single-part-namespaced.php index d881f3d6..ea3d82c8 100644 --- a/specs/const/global-scope-single-part-namespaced.php +++ b/specs/const/global-scope-single-part-namespaced.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Namespaced constant call' => <<<'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 21711668..cdcad581 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Namespaced constant call with namespace partially imported' => <<<'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 bb48a964..72e7fa61 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Namespaced constant call with namespace partially imported' => <<<'PHP' diff --git a/specs/const/global-scope-two-parts-namespaced.php b/specs/const/global-scope-two-parts-namespaced.php index 9afc4aee..01202d8e 100644 --- a/specs/const/global-scope-two-parts-namespaced.php +++ b/specs/const/global-scope-two-parts-namespaced.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Namespaced constant call' => <<<'PHP' diff --git a/specs/const/namespace-global-with-global-whitelisting.php b/specs/const/namespace-global-with-global-whitelisting.php index 7bb1b248..50c07a54 100644 --- a/specs/const/namespace-global-with-global-whitelisting.php +++ b/specs/const/namespace-global-with-global-whitelisting.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call in a namespace' => <<<'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 d7beae92..932acb5d 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call imported with an aliased use statement' => <<<'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 02902b09..62e8908b 100644 --- a/specs/const/namespace-global-with-single-level-use-statement.php +++ b/specs/const/namespace-global-with-single-level-use-statement.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call imported with a use statement' => <<<'PHP' diff --git a/specs/const/namespace-global.php b/specs/const/namespace-global.php index 0ae4b4bd..cfc1e806 100644 --- a/specs/const/namespace-global.php +++ b/specs/const/namespace-global.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant call in a namespace' => <<<'PHP' diff --git a/specs/const/namespace-single-part-namespaced.php b/specs/const/namespace-single-part-namespaced.php index ff78cf0b..96f9f515 100644 --- a/specs/const/namespace-single-part-namespaced.php +++ b/specs/const/namespace-single-part-namespaced.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Namespaced constant call' => <<<'PHP' diff --git a/specs/const/native-const-with-global-whitelisting.php b/specs/const/native-const-with-global-whitelisting.php index 12fa70b9..007a848a 100644 --- a/specs/const/native-const-with-global-whitelisting.php +++ b/specs/const/native-const-with-global-whitelisting.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Internal function in a namespace' => <<<'PHP' diff --git a/specs/const/native-const.php b/specs/const/native-const.php index 4990375b..26dda4aa 100644 --- a/specs/const/native-const.php +++ b/specs/const/native-const.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Internal function in a namespace' => <<<'PHP' diff --git a/specs/exp/cast.php b/specs/exp/cast.php index 799cf51a..ec82e97f 100644 --- a/specs/exp/cast.php +++ b/specs/exp/cast.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Cast variable' => <<<'PHP' diff --git a/specs/exp/catch.php b/specs/exp/catch.php index 1d8dcb59..63fc4bb1 100644 --- a/specs/exp/catch.php +++ b/specs/exp/catch.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Catch an internal class' => <<<'PHP' diff --git a/specs/exp/instanceof.php b/specs/exp/instanceof.php index b4588188..408d4a74 100644 --- a/specs/exp/instanceof.php +++ b/specs/exp/instanceof.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Instance of an internal class' => <<<'PHP' diff --git a/specs/func-declaration/global.php b/specs/func-declaration/global.php index 0f928d73..5f7b8173 100644 --- a/specs/func-declaration/global.php +++ b/specs/func-declaration/global.php @@ -20,9 +20,15 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], - 'Simple function declaration' => <<<'PHP' + 'Simple function declaration' => [ + 'registered-functions' => [ + ['foo', 'Humbug\foo'], + ], + 'payload' => <<<'PHP' [ 'whitelist' => ['foo'], + 'registered-functions' => [ + ['foo', 'Humbug\foo'], + ], 'payload' => <<<'PHP' [ 'whitelist-global-functions' => false, 'whitelist' => ['foo'], + 'registered-functions' => [ + ['foo', 'Humbug\foo'], + ], 'payload' => <<<'PHP' [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Method declarations' => [ diff --git a/specs/func-declaration/namespace.php b/specs/func-declaration/namespace.php index 02131782..2f71f7d5 100644 --- a/specs/func-declaration/namespace.php +++ b/specs/func-declaration/namespace.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Simple function declaration' => <<<'PHP' 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 07f14193..6e07df6e 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Global function call imported with a use statement in the global scope' => <<<'PHP' @@ -39,7 +41,7 @@ PHP , - 'Global function call imported with a use statement in the global scope' => <<<'PHP' + 'Global FQ function call imported with a use statement in the global scope' => <<<'PHP' [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Global function call imported with a use statement in the global scope' => <<<'PHP' diff --git a/specs/function/global-scope-global-func.php b/specs/function/global-scope-global-func.php index d21d5172..36b2e566 100644 --- a/specs/function/global-scope-global-func.php +++ b/specs/function/global-scope-global-func.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Global function call in the global scope' => <<<'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 70b3b2b0..dc602104 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Namespaced function call imported with a partial use statement in the global scope' => <<<'PHP' @@ -98,6 +100,9 @@ function main() 'Whitelisted namespaced function call imported with a partial use statement in the global scope' => [ 'whitelist' => ['Foo\main'], + 'registered-functions' => [ + ['Foo\main', 'Humbug\Foo\main'], + ], 'payload' => <<<'PHP' [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Namespaced function call imported with a partial use statement in the global scope' => <<<'PHP' diff --git a/specs/function/global-scope-single-part-namespaced-func.php b/specs/function/global-scope-single-part-namespaced-func.php index 4d588e60..9fec4b99 100644 --- a/specs/function/global-scope-single-part-namespaced-func.php +++ b/specs/function/global-scope-single-part-namespaced-func.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Namespaced function call' => <<<'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 6dac3b0e..d5002b1c 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Global function call imported with a use statement in a namespace' => <<<'PHP' @@ -41,7 +43,7 @@ PHP , - 'Global function call imported with a use statement in a namespace' => <<<'PHP' + 'Global FQ function call imported with a use statement in a namespace' => <<<'PHP' [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Global function call imported with a use statement in a namespace' => <<<'PHP' @@ -41,7 +43,7 @@ PHP , - 'Global function call imported with a use statement in a namespace' => <<<'PHP' + 'Global FQ function call imported with a use statement in a namespace' => <<<'PHP' [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Global function call in a namespace' => <<<'PHP' diff --git a/specs/function/namespace-global-scope-func.php b/specs/function/namespace-global-scope-func.php index 1ebcbbf2..4921259f 100644 --- a/specs/function/namespace-global-scope-func.php +++ b/specs/function/namespace-global-scope-func.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], // We don't do anything as there is no ways to distinguish between a namespaced function call diff --git a/specs/function/namespace-single-part-namespaced-func.php b/specs/function/namespace-single-part-namespaced-func.php index b29aaebb..db59c57c 100644 --- a/specs/function/namespace-single-part-namespaced-func.php +++ b/specs/function/namespace-single-part-namespaced-func.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Namespaced function call' => <<<'PHP' diff --git a/specs/function/native-func.php b/specs/function/native-func.php index 49fc4da0..2f9bb8b9 100644 --- a/specs/function/native-func.php +++ b/specs/function/native-func.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Internal function in a namespace' => <<<'PHP' diff --git a/specs/misc.php b/specs/misc.php index f667cbf2..65264187 100644 --- a/specs/misc.php +++ b/specs/misc.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Empty file' => <<<'PHP' diff --git a/specs/namespace/after-hashbang.php b/specs/namespace/after-hashbang.php index 59810fd7..7d04cbf6 100644 --- a/specs/namespace/after-hashbang.php +++ b/specs/namespace/after-hashbang.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], <<<'PHP' diff --git a/specs/namespace/braces.php b/specs/namespace/braces.php index 3080f78a..5ee92d11 100644 --- a/specs/namespace/braces.php +++ b/specs/namespace/braces.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'One level namespace' => <<<'PHP' diff --git a/specs/namespace/creation-for-whitelist.php b/specs/namespace/creation-for-whitelist.php index 74172de2..c521dba1 100644 --- a/specs/namespace/creation-for-whitelist.php +++ b/specs/namespace/creation-for-whitelist.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Single class should receive namespace' => <<<'PHP' diff --git a/specs/namespace/no-braces.php b/specs/namespace/no-braces.php index 324865e6..292d612c 100644 --- a/specs/namespace/no-braces.php +++ b/specs/namespace/no-braces.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Root namespace' => <<<'PHP' diff --git a/specs/namespace/outside-statements.php b/specs/namespace/outside-statements.php index f61e4018..503d154b 100644 --- a/specs/namespace/outside-statements.php +++ b/specs/namespace/outside-statements.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Declare statement' => <<<'PHP' diff --git a/specs/new/global-scope-single-part-with-single-level-use-statement-an-alias.php b/specs/new/global-scope-single-part-with-single-level-use-statement-an-alias.php index 33358e43..22812053 100644 --- a/specs/new/global-scope-single-part-with-single-level-use-statement-an-alias.php +++ b/specs/new/global-scope-single-part-with-single-level-use-statement-an-alias.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'New statement call of a class belonging to the global namespace imported via an aliased use statement' => [ 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 7fb17469..d4c9faad 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'New statement call of a class belonging to the global namespace imported via a use statement' => [ diff --git a/specs/new/global-scope-single-part.php b/specs/new/global-scope-single-part.php index 5e84c9bb..3484ce3c 100644 --- a/specs/new/global-scope-single-part.php +++ b/specs/new/global-scope-single-part.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'New statement call of a class belonging to the global namespace' => [ @@ -42,7 +44,7 @@ class Foo PHP ], - 'New statement call of a class belonging to the global namespace' => [ + 'New statement call of an internal class belonging to the global namespace' => [ 'payload' => <<<'PHP' [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'New statement call of a namespaced class partially imported with an aliased use statement' => [ 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 9f6cf116..13b245a2 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'New statement call of a namespaced class partially imported with a use statement' => [ diff --git a/specs/new/global-scope-two-parts.php b/specs/new/global-scope-two-parts.php index 6c1b1154..a65d0e0d 100644 --- a/specs/new/global-scope-two-parts.php +++ b/specs/new/global-scope-two-parts.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'New statement call of a namespaced class' => [ 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 483e72c9..9e6d9bcf 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 @@ -21,6 +21,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'New statement call of a class' => [ diff --git a/specs/new/namespace-single-part.php b/specs/new/namespace-single-part.php index 675b507c..def0f0bd 100644 --- a/specs/new/namespace-single-part.php +++ b/specs/new/namespace-single-part.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'New statement call of a class' => [ 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 abfb2218..f552efb3 100644 --- a/specs/new/namespace-two-parts-with-single-level-use.php +++ b/specs/new/namespace-two-parts-with-single-level-use.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'New statement call of a class belonging to the global namespace imported via a use statement' => [ 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 40c1287a..5256d0bf 100644 --- a/specs/new/namespace-two-parts-with-two-level-use.php +++ b/specs/new/namespace-two-parts-with-two-level-use.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'New statement call of a class via a use statement' => [ diff --git a/specs/new/namespace-two-parts.php b/specs/new/namespace-two-parts.php index 3a05a0f9..2932ab30 100644 --- a/specs/new/namespace-two-parts.php +++ b/specs/new/namespace-two-parts.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'New statement call of a class' => [ diff --git a/specs/special-keywords/self-static-parent-const.php b/specs/special-keywords/self-static-parent-const.php index 88a43d7c..d28cff5e 100644 --- a/specs/special-keywords/self-static-parent-const.php +++ b/specs/special-keywords/self-static-parent-const.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Usage for classes in the global scope' => <<<'PHP' diff --git a/specs/special-keywords/self-static-parent-method.php b/specs/special-keywords/self-static-parent-method.php index a3a7e29f..17b582b3 100644 --- a/specs/special-keywords/self-static-parent-method.php +++ b/specs/special-keywords/self-static-parent-method.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Usage for classes in the global scope' => <<<'PHP' diff --git a/specs/special-keywords/self-static-parent-static-var.php b/specs/special-keywords/self-static-parent-static-var.php index c6b9e939..793afc54 100644 --- a/specs/special-keywords/self-static-parent-static-var.php +++ b/specs/special-keywords/self-static-parent-static-var.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Usage for classes in the global scope' => <<<'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 7f4f927c..798ddbc1 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Static method call statement of a class belonging to the global namespace imported via an aliased use statement' => <<<'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 bbd1c16b..79fb45fd 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Static method call statement of a class belonging to the global namespace imported via a use statement' => <<<'PHP' diff --git a/specs/static-method/global-scope-single-part.php b/specs/static-method/global-scope-single-part.php index 2dcf2352..b604e3cc 100644 --- a/specs/static-method/global-scope-single-part.php +++ b/specs/static-method/global-scope-single-part.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Static method call statement of a class belonging to the global namespace' => <<<'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 a2a08097..e0d633ad 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Static method call statement of a namespaced class partially imported with an aliased use statement' => <<<'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 cfac6e75..03834fe3 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Static method call statement of a namespaced class partially imported with a use statement' => <<<'PHP' diff --git a/specs/static-method/global-scope-two-parts.php b/specs/static-method/global-scope-two-parts.php index 3fdb5377..e9b86d22 100644 --- a/specs/static-method/global-scope-two-parts.php +++ b/specs/static-method/global-scope-two-parts.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Static method call statement of a namespaced class' => <<<'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 c72ec91d..ffca3298 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 @@ -21,6 +21,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Static method call statement of a class' => <<<'PHP' diff --git a/specs/static-method/namespace-single-part.php b/specs/static-method/namespace-single-part.php index 7dd9e35a..4d4b066f 100644 --- a/specs/static-method/namespace-single-part.php +++ b/specs/static-method/namespace-single-part.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Static method call statement of a class' => <<<'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 9029805e..d3ee81e9 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Static method call statement of a class belonging to the global namespace imported via a use statement' => <<<'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 dfee841c..2cac939e 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 @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Static method call statement of a class via a use statement' => <<<'PHP' diff --git a/specs/static-method/namespace-two-parts.php b/specs/static-method/namespace-two-parts.php index e2e2df6a..0b70890a 100644 --- a/specs/static-method/namespace-two-parts.php +++ b/specs/static-method/namespace-two-parts.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Static method call statement of a class' => <<<'PHP' diff --git a/specs/string-literal/array-var.php b/specs/string-literal/array-var.php index 5e03457b..4e230056 100644 --- a/specs/string-literal/array-var.php +++ b/specs/string-literal/array-var.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'String argument' => <<<'PHP' diff --git a/specs/string-literal/class-const-array.php b/specs/string-literal/class-const-array.php index 0599aa9d..72b580cc 100644 --- a/specs/string-literal/class-const-array.php +++ b/specs/string-literal/class-const-array.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'FQCN string argument' => <<<'PHP' diff --git a/specs/string-literal/class-const.php b/specs/string-literal/class-const.php index e4864c0d..60d561ca 100644 --- a/specs/string-literal/class-const.php +++ b/specs/string-literal/class-const.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'FQCN string argument' => <<<'PHP' diff --git a/specs/string-literal/class-prop.php b/specs/string-literal/class-prop.php index f6b54d92..e40a5207 100644 --- a/specs/string-literal/class-prop.php +++ b/specs/string-literal/class-prop.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'FQCN string argument' => <<<'PHP' diff --git a/specs/string-literal/class-var.php b/specs/string-literal/class-var.php index ff64ddae..f43278ff 100644 --- a/specs/string-literal/class-var.php +++ b/specs/string-literal/class-var.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'FQCN string argument' => <<<'PHP' diff --git a/specs/string-literal/const.php b/specs/string-literal/const.php index 5877aa9c..f9f5d87b 100644 --- a/specs/string-literal/const.php +++ b/specs/string-literal/const.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'FQCN string argument' => <<<'PHP' diff --git a/specs/string-literal/define-value.php b/specs/string-literal/define-value.php index ea358d38..4c7b7ca9 100644 --- a/specs/string-literal/define-value.php +++ b/specs/string-literal/define-value.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'FQCN string argument' => <<<'PHP' diff --git a/specs/string-literal/func-arg.php b/specs/string-literal/func-arg.php index 3a28a7c5..e59c691f 100644 --- a/specs/string-literal/func-arg.php +++ b/specs/string-literal/func-arg.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'FQCN string argument' => <<<'PHP' diff --git a/specs/string-literal/method-arg.php b/specs/string-literal/method-arg.php index 6e68e713..5b070062 100644 --- a/specs/string-literal/method-arg.php +++ b/specs/string-literal/method-arg.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'FQCN string argument' => <<<'PHP' diff --git a/specs/string-literal/misc.php b/specs/string-literal/misc.php index 28f40254..e8c77fd3 100644 --- a/specs/string-literal/misc.php +++ b/specs/string-literal/misc.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'PHP heredoc as argument' => <<<'PHP' diff --git a/specs/string-literal/new.php b/specs/string-literal/new.php index aed4fb3b..fe3e2bee 100644 --- a/specs/string-literal/new.php +++ b/specs/string-literal/new.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'FQCN string argument' => <<<'PHP' diff --git a/specs/string-literal/var.php b/specs/string-literal/var.php index 30e914d7..f9ba49ce 100644 --- a/specs/string-literal/var.php +++ b/specs/string-literal/var.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'FQCN string argument' => <<<'PHP' diff --git a/specs/use/use-class-alias.php b/specs/use/use-class-alias.php index 62204f05..d718bbf0 100644 --- a/specs/use/use-class-alias.php +++ b/specs/use/use-class-alias.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Use statement of a class belonging to the global scope' => <<<'PHP' diff --git a/specs/use/use-class-group.php b/specs/use/use-class-group.php index 7833468a..a1661b0d 100644 --- a/specs/use/use-class-group.php +++ b/specs/use/use-class-group.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Multiple group use statement' => <<<'PHP' diff --git a/specs/use/use-class.php b/specs/use/use-class.php index 0fb6849a..f3a84190 100644 --- a/specs/use/use-class.php +++ b/specs/use/use-class.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Use statement of a class belonging to the global scope' => <<<'PHP' diff --git a/specs/use/use-const-alias.php b/specs/use/use-const-alias.php index 19f3300e..b6c8c703 100644 --- a/specs/use/use-const-alias.php +++ b/specs/use/use-const-alias.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant use statement for a constant belonging to the global namespace' => <<<'PHP' diff --git a/specs/use/use-const-group.php b/specs/use/use-const-group.php index 708d1a1c..b043905a 100644 --- a/specs/use/use-const-group.php +++ b/specs/use/use-const-group.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], <<<'PHP' diff --git a/specs/use/use-const.php b/specs/use/use-const.php index 831b1193..db1fee7e 100644 --- a/specs/use/use-const.php +++ b/specs/use/use-const.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Constant use statement for a constant belonging to the global namespace' => <<<'PHP' diff --git a/specs/use/use-func-alias.php b/specs/use/use-func-alias.php index 56d7181e..6f65d3e3 100644 --- a/specs/use/use-func-alias.php +++ b/specs/use/use-func-alias.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Use statement for a function belonging to the global namespace' => <<<'PHP' diff --git a/specs/use/use-func-group.php b/specs/use/use-func-group.php index 6434a618..05202fce 100644 --- a/specs/use/use-func-group.php +++ b/specs/use/use-func-group.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], <<<'PHP' diff --git a/specs/use/use-func.php b/specs/use/use-func.php index d8424b7b..0276fe85 100644 --- a/specs/use/use-func.php +++ b/specs/use/use-func.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Use statement for a function belonging to the global namespace' => <<<'PHP' diff --git a/specs/use/use-mix-group.php b/specs/use/use-mix-group.php index 2bf2ad0d..a54a6ec3 100644 --- a/specs/use/use-mix-group.php +++ b/specs/use/use-mix-group.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => true, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], <<<'PHP' diff --git a/specs/whitelist-case-sensitiveness.php b/specs/whitelist-case-sensitiveness.php index a5c0d7a8..793e80c4 100644 --- a/specs/whitelist-case-sensitiveness.php +++ b/specs/whitelist-case-sensitiveness.php @@ -20,6 +20,8 @@ 'whitelist' => [], 'whitelist-global-constants' => false, 'whitelist-global-functions' => true, + 'registered-classes' => [], + 'registered-functions' => [], ], 'Class whitelists are case insensitive' => [ diff --git a/src/Autoload/ScoperAutoloadGenerator.php b/src/Autoload/ScoperAutoloadGenerator.php index dbe932e1..5ec59827 100644 --- a/src/Autoload/ScoperAutoloadGenerator.php +++ b/src/Autoload/ScoperAutoloadGenerator.php @@ -35,7 +35,7 @@ public function __construct(Whitelist $whitelist) public function dump(string $prefix): string { - $whitelistedFunctions = $this->whitelist->getWhitelistedFunctions(); + $whitelistedFunctions = $this->whitelist->getRecordedWhitelistedFunctions(); $hasNamespacedFunctions = $this->hasNamespacedFunctions($whitelistedFunctions); diff --git a/src/Whitelist.php b/src/Whitelist.php index a01a2615..5b2d4471 100644 --- a/src/Whitelist.php +++ b/src/Whitelist.php @@ -179,7 +179,7 @@ public function recordWhitelistedFunction(FullyQualified $original, FullyQualifi $this->whitelistedFunctions[] = [(string) $original, (string) $alias]; } - public function getWhitelistedFunctions(): array + public function getRecordedWhitelistedFunctions(): array { return array_values( array_unique( @@ -220,7 +220,7 @@ public function recordWhitelistedClass(FullyQualified $original, FullyQualified $this->whitelistedClasses[] = [(string) $original, (string) $alias]; } - public function getWhitelistedClasses(): array + public function getRecordedWhitelistedClasses(): array { return $this->whitelistedClasses; } diff --git a/tests/Scoper/PhpScoperSpecTest.php b/tests/Scoper/PhpScoperSpecTest.php new file mode 100644 index 00000000..c5f81a64 --- /dev/null +++ b/tests/Scoper/PhpScoperSpecTest.php @@ -0,0 +1,346 @@ +, + * Pádraic Brady + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Humbug\PhpScoper\Scoper; + +use function array_map; +use function current; +use Generator; +use Humbug\PhpScoper\PhpParser\FakeParser; +use Humbug\PhpScoper\PhpParser\TraverserFactory; +use Humbug\PhpScoper\Reflector; +use Humbug\PhpScoper\Scoper; +use Humbug\PhpScoper\Whitelist; +use LogicException; +use const PHP_EOL; +use PhpParser\Error as PhpParserError; +use PhpParser\Node\Name; +use PhpParser\NodeTraverserInterface; +use PhpParser\Parser; +use PHPUnit\Framework\TestCase; +use Prophecy\Argument; +use Prophecy\Prophecy\ObjectProphecy; +use Roave\BetterReflection\BetterReflection; +use Roave\BetterReflection\Reflector\ClassReflector; +use Roave\BetterReflection\Reflector\FunctionReflector; +use Roave\BetterReflection\SourceLocator\Type\AggregateSourceLocator; +use Roave\BetterReflection\SourceLocator\Type\PhpInternalSourceLocator; +use Roave\BetterReflection\SourceLocator\Type\StringSourceLocator; +use Symfony\Component\Finder\Finder; +use Throwable; +use UnexpectedValueException; +use function Humbug\PhpScoper\create_fake_patcher; +use function Humbug\PhpScoper\create_parser; +use function implode; +use function sprintf; + +class PhpScoperSpecTest extends TestCase +{ + private const SPECS_PATH = __DIR__.'/../../specs'; + private const SECONDARY_SPECS_PATH = __DIR__.'/../../_specs'; + + /** + * This test is to ensure no file is left in _specs for the CI. It is fine otherwise for this test to fail locally + * when developing something. + */ + public function test_it_uses_the_right_specs_directory() + { + $files = (new Finder())->files()->in(self::SECONDARY_SPECS_PATH); + + $this->assertCount(0, $files); + } + + /** + * @dataProvider provideValidFiles + */ + public function test_can_scope_valid_files( + string $spec, + string $contents, + string $prefix, + Whitelist $whitelist, + ?string $expected, + array $expectedRegisteredClasses, + array $expectedRegisteredFunctions + ) { + $filePath = 'file.php'; + $patchers = [create_fake_patcher()]; + $scoper = $this->createScoper($contents); + + try { + $actual = $scoper->scope($filePath, $contents, $prefix, $patchers, $whitelist); + + if (null === $expected) { + $this->fail('Expected exception to be thrown.'); + } + } catch (UnexpectedValueException $exception) { + if (null !== $expected) { + throw $exception; + } + + $this->assertTrue(true); + + return; + } catch (Throwable $throwable) { + $this->fail('Could not parse the spec: '.$spec); + } + + $specMessage = $this->createSpecMessage( + $spec, + $contents, + $whitelist, + $expected, + $actual, + $expectedRegisteredClasses, + $expectedRegisteredFunctions + ); + + $this->assertSame( + $expected, + $actual, + $specMessage + ); + $this->assertSame( + $whitelist->getRecordedWhitelistedClasses(), + $expectedRegisteredClasses, + $specMessage + ); + $this->assertSame( + $whitelist->getRecordedWhitelistedFunctions(), + $expectedRegisteredFunctions, + $specMessage + ); + } + + public function provideValidFiles() + { + $files = (new Finder())->files()->in(self::SECONDARY_SPECS_PATH); + + if (0 === count($files)) { + $files = (new Finder())->files()->in(self::SPECS_PATH); + } + + $files->sortByName(); + + foreach ($files as $file) { + try { + $fixtures = include $file; + + $meta = $fixtures['meta']; + unset($fixtures['meta']); + + foreach ($fixtures as $fixtureTitle => $fixtureSet) { + yield $this->parseSpecFile($meta, $fixtureTitle, $fixtureSet)->current(); + } + } catch (Throwable $throwable) { + $this->fail( + sprintf( + 'An error occurred while parsing the file "%s": %s', + $file, + $throwable->getMessage() + ) + ); + } + } + } + + private function createScoper(string $contents): Scoper + { + $astLocator = (new BetterReflection())->astLocator(); + + $sourceLocator = new AggregateSourceLocator([ + new StringSourceLocator($contents, $astLocator), + new PhpInternalSourceLocator($astLocator), + ]); + + $classReflector = new ClassReflector($sourceLocator); + + return new PhpScoper( + create_parser(), + new FakeScoper(), + new TraverserFactory( + new Reflector( + $classReflector, + new FunctionReflector($sourceLocator, $classReflector) + ) + ) + ); + } + + /** + * @param array $meta + * @param string|int $fixtureTitle + * @param string|array $fixtureSet + * + * @return Generator + */ + private function parseSpecFile(array $meta, $fixtureTitle, $fixtureSet): Generator + { + $spec = sprintf( + '[%s] %s', + $meta['title'], + isset($fixtureSet['spec']) ? $fixtureSet['spec'] : $fixtureTitle + ); + + $payload = is_string($fixtureSet) ? $fixtureSet : $fixtureSet['payload']; + + $payloadParts = preg_split("/\n----(?:\n|$)/", $payload); + + yield [ + $spec, + $payloadParts[0], // Input + $fixtureSet['prefix'] ?? $meta['prefix'], + Whitelist::create( + $fixtureSet['whitelist-global-constants'] ?? $meta['whitelist-global-constants'], + $fixtureSet['whitelist-global-functions'] ?? $meta['whitelist-global-functions'], + ...($fixtureSet['whitelist'] ?? $meta['whitelist']) + ), + '' === $payloadParts[1] ? null : $payloadParts[1], // Expected output; null means an exception is expected, + $fixtureSet['registered-classes'] ?? $meta['registered-classes'], + $fixtureSet['registered-functions'] ?? $meta['registered-functions'], + ]; + } + + /** + * @param string[][] $expectedRegisteredClasses + * @param string[][] $expectedRegisteredFunctions + */ + private function createSpecMessage( + string $spec, + string $contents, + Whitelist $whitelist, + ?string $expected, + ?string $actual, + array $expectedRegisteredClasses, + array $expectedRegisteredFunctions + ): string + { + $formattedWhitelist = $this->formatSimpleList($whitelist->toArray()); + + $formattedWhitelistGlobalConstants = $this->convertBoolToString($whitelist->whitelistGlobalConstants()); + $formattedWhitelistGlobalFunctions = $this->convertBoolToString($whitelist->whitelistGlobalFunctions()); + + $whitelist->getRecordedWhitelistedFunctions(); + $whitelist->getRecordedWhitelistedClasses(); + + $formattedExpectedRegisteredClasses = $this->formatTupleList($expectedRegisteredClasses); + $formattedExpectedRegisteredFunctions = $this->formatTupleList($expectedRegisteredFunctions); + + $formattedActualRegisteredClasses = $this->formatTupleList($whitelist->getRecordedWhitelistedClasses()); + $formattedActualRegisteredFunctions = $this->formatTupleList($whitelist->getRecordedWhitelistedFunctions()); + + $titleSeparator = str_repeat( + '=', + min( + strlen($spec), + 80 + ) + ); + + return << %s]', ...$tuple); + } + + return sprintf( + "[\n%s\n]", + implode( + PHP_EOL, + array_map( + function (array $stringTuple): string { + return sprintf(' - %s => %s', ...$stringTuple); + }, + $stringTuples + ) + ) + ); + } + + private function convertBoolToString(bool $bool): string + { + return true === $bool ? 'true' : 'false'; + } +} diff --git a/tests/Scoper/PhpScoperTest.php b/tests/Scoper/PhpScoperTest.php index 495e4557..e04821f5 100644 --- a/tests/Scoper/PhpScoperTest.php +++ b/tests/Scoper/PhpScoperTest.php @@ -44,9 +44,6 @@ class PhpScoperTest extends TestCase { - private const SPECS_PATH = __DIR__.'/../../specs'; - private const SECONDARY_SPECS_PATH = __DIR__.'/../../_specs'; - /** * @var Scoper */ @@ -419,172 +416,4 @@ function (...$args) use (&$i): bool { $firstTraverserProphecy->traverse(Argument::cetera())->shouldHaveBeenCalledTimes(1); $secondTraverserProphecy->traverse(Argument::cetera())->shouldHaveBeenCalledTimes(1); } - - /** - * @dataProvider provideValidFiles - */ - public function test_can_scope_valid_files(string $spec, string $contents, string $prefix, Whitelist $whitelist, ?string $expected) - { - $filePath = 'file.php'; - - $patchers = [create_fake_patcher()]; - - $astLocator = (new BetterReflection())->astLocator(); - - $sourceLocator = new AggregateSourceLocator([ - new StringSourceLocator($contents, $astLocator), - new PhpInternalSourceLocator($astLocator), - ]); - - $classReflector = new ClassReflector($sourceLocator); - - $this->scoper = new PhpScoper( - create_parser(), - new FakeScoper(), - new TraverserFactory( - new Reflector( - $classReflector, - new FunctionReflector($sourceLocator, $classReflector) - ) - ) - ); - - try { - $actual = $this->scoper->scope($filePath, $contents, $prefix, $patchers, $whitelist); - - if (null === $expected) { - $this->fail('Expected exception to be thrown.'); - } - } catch (UnexpectedValueException $exception) { - if (null !== $expected) { - throw $exception; - } - - $this->assertTrue(true); - - return; - } - - $formattedWhitelist = 0 === count($whitelist->toArray()) - ? '[]' - : sprintf('[%s]', implode(', ', $whitelist->toArray())) - ; - - $formattedWhitelistGlobalConstants = $whitelist->whitelistGlobalConstants() ? 'true' : 'false'; - $formattedWhitelistGlobalFunctions = $whitelist->whitelistGlobalFunctions() ? 'true' : 'false'; - - $titleSeparator = str_repeat( - '=', - min( - strlen($spec), - 80 - ) - ); - - $this->assertSame( - $expected, - $actual, - <<files()->in(self::SECONDARY_SPECS_PATH); - - $this->assertCount(0, $files); - } - - public function provideValidFiles() - { - $files = (new Finder())->files()->in(self::SECONDARY_SPECS_PATH); - - if (0 === count($files)) { - $files = (new Finder())->files()->in(self::SPECS_PATH); - } - - $files->sortByName(); - - foreach ($files as $file) { - try { - $fixtures = include $file; - - $meta = $fixtures['meta']; - unset($fixtures['meta']); - - foreach ($fixtures as $fixtureTitle => $fixtureSet) { - yield $this->parseSpecFile($meta, $fixtureTitle, $fixtureSet)->current(); - } - } catch (Throwable $throwable) { - $this->fail( - sprintf( - 'An error occurred while parsing the file "%s": %s', - $file, - $throwable->getMessage() - ) - ); - } - } - } - - /** - * @param array $meta - * @param string|int $fixtureTitle - * @param string|array $fixtureSet - * - * @return Generator - */ - private function parseSpecFile(array $meta, $fixtureTitle, $fixtureSet): Generator - { - $spec = sprintf( - '[%s] %s', - $meta['title'], - isset($fixtureSet['spec']) ? $fixtureSet['spec'] : $fixtureTitle - ); - - $payload = is_string($fixtureSet) ? $fixtureSet : $fixtureSet['payload']; - - $payloadParts = preg_split("/\n----(?:\n|$)/", $payload); - - yield [ - $spec, - $payloadParts[0], // Input - $fixtureSet['prefix'] ?? $meta['prefix'], - Whitelist::create( - $fixtureSet['whitelist-global-constants'] ?? $meta['whitelist-global-constants'], - $fixtureSet['whitelist-global-functions'] ?? $meta['whitelist-global-functions'], - ...($fixtureSet['whitelist'] ?? $meta['whitelist']) - ), - '' === $payloadParts[1] ? null : $payloadParts[1], // Expected output - ]; - } } diff --git a/tests/WhitelistTest.php b/tests/WhitelistTest.php index 1249c082..659db6f4 100644 --- a/tests/WhitelistTest.php +++ b/tests/WhitelistTest.php @@ -118,7 +118,7 @@ public function test_it_can_record_whitelisted_functions() ['Acme\foo', 'Humbug\Acme\foo'], ['Acme\bar', 'Humbug\Acme\bar'], ], - $whitelist->getWhitelistedFunctions() + $whitelist->getRecordedWhitelistedFunctions() ); } @@ -145,7 +145,7 @@ public function test_it_can_record_whitelisted_classes() ['Acme\foo', 'Humbug\Acme\foo'], ['Acme\bar', 'Humbug\Acme\bar'], ], - $whitelist->getWhitelistedFunctions() + $whitelist->getRecordedWhitelistedFunctions() ); } From 0a1b5336ebb8655e658c7adbee4be5ef6ea1e53c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Tue, 24 Jul 2018 11:52:51 +0200 Subject: [PATCH 2/3] Add missing emta --- specs/class/conditional.php | 8 +-- specs/func-declaration/global.php | 12 +++++ specs/func-declaration/namespace.php | 23 ++------- ...-namespaced-func-with-single-level-use.php | 3 ++ src/PhpParser/Node/NamedIdentifier.php | 28 +++++++++++ .../Collection/UseStmtCollection.php | 28 +++++++++-- .../FunctionIdentifierRecorder.php | 2 +- .../Resolver/FullyQualifiedNameResolver.php | 6 +-- tests/Scoper/PhpScoperSpecTest.php | 49 +++++++++++++++++++ 9 files changed, 127 insertions(+), 32 deletions(-) create mode 100644 src/PhpParser/Node/NamedIdentifier.php diff --git a/specs/class/conditional.php b/specs/class/conditional.php index 0c80ed17..c453ca3f 100644 --- a/specs/class/conditional.php +++ b/specs/class/conditional.php @@ -64,9 +64,9 @@ class A } PHP - , + ], - 'Declaration in a namespace: prefix each namespace' => <<<'PHP' + 'Declaration in a namespace' => <<<'PHP' [ 'whitelist' => ['Foo\A'], @@ -110,7 +110,7 @@ class A } PHP - ], + ], 'Multiple declarations in different namespaces' => <<<'PHP' [ 'whitelist' => ['X\Y', 'BAR_CONST'], + 'registered-functions' => [ + ['foo', 'Humbug\foo'], + ], 'payload' => <<<'PHP' [ 'whitelist-global-constants' => true, + 'registered-functions' => [ + ['foo', 'Humbug\foo'], + ], 'payload' => <<<'PHP' [ 'whitelist' => ['X\Y'], + 'registered-functions' => [ + ['foo', 'Humbug\foo'], + ], 'payload' => <<<'PHP' [ 'whitelist' => ['X\Y'], + 'registered-functions' => [ + ['foo', 'Humbug\foo'], + ], 'payload' => <<<'PHP' [ 'whitelist' => ['Acme\foo'], + 'registered-functions' => [ + ['Acme\foo', 'Humbug\Acme\foo'], + ], 'payload' => <<<'PHP' [ - 'whitelist-global-functions' => false, - 'whitelist' => ['foo'], - 'payload' => <<<'PHP' - [ 'whitelist' => ['Foo\main'], + 'registered-functions' => [ + ['Foo\main', 'Humbug\Foo\main'], + ], 'payload' => <<<'PHP' name, $node->getAttributes()); + $instance->originalNode = $node; + + return $instance; + } + + public function getOriginalNode(): Identifier + { + return $this->originalNode; + } +} \ No newline at end of file diff --git a/src/PhpParser/NodeVisitor/Collection/UseStmtCollection.php b/src/PhpParser/NodeVisitor/Collection/UseStmtCollection.php index b0f87516..f368f823 100644 --- a/src/PhpParser/NodeVisitor/Collection/UseStmtCollection.php +++ b/src/PhpParser/NodeVisitor/Collection/UseStmtCollection.php @@ -15,12 +15,16 @@ namespace Humbug\PhpScoper\PhpParser\NodeVisitor\Collection; use ArrayIterator; +use function count; +use Humbug\PhpScoper\PhpParser\Node\NamedIdentifier; use Humbug\PhpScoper\PhpParser\NodeVisitor\ParentNodeAppender; use IteratorAggregate; +use PhpParser\Node; use PhpParser\Node\Expr\ConstFetch; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Name; use PhpParser\Node\Stmt\ClassLike; +use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\Use_; use PhpParser\Node\Stmt\UseUse; use function Humbug\PhpScoper\clone_node; @@ -68,8 +72,8 @@ public function findStatementForNode(?Name $namespaceName, Name $node): ?Name $parentNode = ParentNodeAppender::findParent($node); if ($parentNode instanceof ClassLike - && $node->hasAttribute('original_node') - && $node->getAttribute('original_node') === $parentNode->name + && $node instanceof NamedIdentifier + && $node->getOriginalNode() === $parentNode->name ) { // The current node can either be the class like name or one of its elements, e.g. extends or implements. // In the first case, the node was original an Identifier. @@ -86,7 +90,7 @@ public function findStatementForNode(?Name $namespaceName, Name $node): ?Name } if ($name === $useStatement->getAlias()->toLowerString()) { - if ($parentNode instanceof FuncCall && 1 === count($node->parts)) { + if ($this->isFunctionName($node, $parentNode)) { if (Use_::TYPE_FUNCTION === $use_->type) { return $useStatement->name; } @@ -122,4 +126,22 @@ public function getIterator(): iterable { return new ArrayIterator($this->nodes); } + + private function isFunctionName(Name $node, ?Node $parentNode): bool + { + if (null === $parentNode || 1 !== count($node->parts)) { + return false; + } + + if ($parentNode instanceof FuncCall) { + return true; + } + + if (false === ($parentNode instanceof Function_)) { + return false; + } + /** @var Function_ $parentNode */ + + return $node instanceof NamedIdentifier && $node->getOriginalNode() === $parentNode->name; + } } diff --git a/src/PhpParser/NodeVisitor/FunctionIdentifierRecorder.php b/src/PhpParser/NodeVisitor/FunctionIdentifierRecorder.php index dd7b2227..aa2c4668 100644 --- a/src/PhpParser/NodeVisitor/FunctionIdentifierRecorder.php +++ b/src/PhpParser/NodeVisitor/FunctionIdentifierRecorder.php @@ -54,7 +54,7 @@ public function enterNode(Node $node): Node $parent = ParentNodeAppender::getParent($node); - if (false === ($parent instanceof Function_)) { + if (false === ($parent instanceof Function_) || $node === $parent->returnType) { return $node; } diff --git a/src/PhpParser/NodeVisitor/Resolver/FullyQualifiedNameResolver.php b/src/PhpParser/NodeVisitor/Resolver/FullyQualifiedNameResolver.php index 59d73c53..14ea3756 100644 --- a/src/PhpParser/NodeVisitor/Resolver/FullyQualifiedNameResolver.php +++ b/src/PhpParser/NodeVisitor/Resolver/FullyQualifiedNameResolver.php @@ -14,6 +14,7 @@ namespace Humbug\PhpScoper\PhpParser\NodeVisitor\Resolver; +use Humbug\PhpScoper\PhpParser\Node\NamedIdentifier; use Humbug\PhpScoper\PhpParser\NodeVisitor\Collection\NamespaceStmtCollection; use Humbug\PhpScoper\PhpParser\NodeVisitor\Collection\UseStmtCollection; use Humbug\PhpScoper\PhpParser\NodeVisitor\NameStmtPrefixer; @@ -53,10 +54,7 @@ public function resolveName(Node $node): ResolvedValue } if ($node instanceof Identifier) { - $attributes = $node->getAttributes(); - $attributes['original_node'] = $node; - - $node = new Name($node->name, $attributes); + $node = NamedIdentifier::create($node); } $namespaceName = $this->namespaceStatements->findNamespaceForNode($node); diff --git a/tests/Scoper/PhpScoperSpecTest.php b/tests/Scoper/PhpScoperSpecTest.php index c5f81a64..1099f1ac 100644 --- a/tests/Scoper/PhpScoperSpecTest.php +++ b/tests/Scoper/PhpScoperSpecTest.php @@ -14,6 +14,8 @@ namespace Humbug\PhpScoper\Scoper; +use function array_diff; +use function array_keys; use function array_map; use function current; use Generator; @@ -22,6 +24,7 @@ use Humbug\PhpScoper\Reflector; use Humbug\PhpScoper\Scoper; use Humbug\PhpScoper\Whitelist; +use function is_array; use LogicException; use const PHP_EOL; use PhpParser\Error as PhpParserError; @@ -50,6 +53,26 @@ class PhpScoperSpecTest extends TestCase private const SPECS_PATH = __DIR__.'/../../specs'; private const SECONDARY_SPECS_PATH = __DIR__.'/../../_specs'; + private const SPECS_META_KEYS = [ + 'title', + 'prefix', + 'whitelist', + 'whitelist-global-constants', + 'whitelist-global-functions', + 'registered-classes', + 'registered-functions', + ]; + + private const SPECS_SPEC_KEYS = [ + 'prefix', + 'whitelist', + 'whitelist-global-constants', + 'whitelist-global-functions', + 'registered-classes', + 'registered-functions', + 'payload', + ]; + /** * This test is to ensure no file is left in _specs for the CI. It is fine otherwise for this test to fail locally * when developing something. @@ -196,6 +219,32 @@ private function parseSpecFile(array $meta, $fixtureTitle, $fixtureSet): Generat $payloadParts = preg_split("/\n----(?:\n|$)/", $payload); + $this->assertSame( + [], + $diff = array_diff( + array_keys($meta), + self::SPECS_META_KEYS + ), + sprintf( + 'Expected the keys found in the meta section to be known keys, unknown keys: "%s"', + implode('", "', $diff) + ) + ); + + if (is_array($fixtureSet)) { + $this->assertSame( + [], + $diff = array_diff( + array_keys($fixtureSet), + self::SPECS_SPEC_KEYS + ), + sprintf( + 'Expected the keys found in the spec section to be known keys, unknown keys: "%s"', + implode('", "', $diff) + ) + ); + } + yield [ $spec, $payloadParts[0], // Input From 6c172adb712fd07fe22e05031104b016607e141c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Tue, 24 Jul 2018 12:04:52 +0200 Subject: [PATCH 3/3] Fix CS --- src/Autoload/ScoperAutoloadGenerator.php | 2 +- src/PhpParser/Node/NamedIdentifier.php | 13 ++++++++++- .../Collection/UseStmtCollection.php | 4 ++-- tests/Scoper/PhpScoperSpecTest.php | 23 ++++++------------- tests/Scoper/PhpScoperTest.php | 10 -------- 5 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/Autoload/ScoperAutoloadGenerator.php b/src/Autoload/ScoperAutoloadGenerator.php index 5ec59827..2be2bca5 100644 --- a/src/Autoload/ScoperAutoloadGenerator.php +++ b/src/Autoload/ScoperAutoloadGenerator.php @@ -193,7 +193,7 @@ function %1$s() { private function hasNamespacedFunctions(array $functions): bool { foreach ($functions as [$original, $alias]) { - /** + /* * @var string * @var string $alias */ diff --git a/src/PhpParser/Node/NamedIdentifier.php b/src/PhpParser/Node/NamedIdentifier.php index 671c22c5..29a29b7a 100644 --- a/src/PhpParser/Node/NamedIdentifier.php +++ b/src/PhpParser/Node/NamedIdentifier.php @@ -2,7 +2,18 @@ declare(strict_types=1); +/* + * This file is part of the humbug/php-scoper package. + * + * Copyright (c) 2017 Théo FIDRY , + * Pádraic Brady + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Humbug\PhpScoper\PhpParser\Node; + use PhpParser\Node\Identifier; use PhpParser\Node\Name; @@ -25,4 +36,4 @@ public function getOriginalNode(): Identifier { return $this->originalNode; } -} \ No newline at end of file +} diff --git a/src/PhpParser/NodeVisitor/Collection/UseStmtCollection.php b/src/PhpParser/NodeVisitor/Collection/UseStmtCollection.php index f368f823..ce3ecd5f 100644 --- a/src/PhpParser/NodeVisitor/Collection/UseStmtCollection.php +++ b/src/PhpParser/NodeVisitor/Collection/UseStmtCollection.php @@ -15,7 +15,6 @@ namespace Humbug\PhpScoper\PhpParser\NodeVisitor\Collection; use ArrayIterator; -use function count; use Humbug\PhpScoper\PhpParser\Node\NamedIdentifier; use Humbug\PhpScoper\PhpParser\NodeVisitor\ParentNodeAppender; use IteratorAggregate; @@ -27,6 +26,7 @@ use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\Use_; use PhpParser\Node\Stmt\UseUse; +use function count; use function Humbug\PhpScoper\clone_node; /** @@ -140,7 +140,7 @@ private function isFunctionName(Name $node, ?Node $parentNode): bool if (false === ($parentNode instanceof Function_)) { return false; } - /** @var Function_ $parentNode */ + /* @var Function_ $parentNode */ return $node instanceof NamedIdentifier && $node->getOriginalNode() === $parentNode->name; } diff --git a/tests/Scoper/PhpScoperSpecTest.php b/tests/Scoper/PhpScoperSpecTest.php index 1099f1ac..02047145 100644 --- a/tests/Scoper/PhpScoperSpecTest.php +++ b/tests/Scoper/PhpScoperSpecTest.php @@ -14,26 +14,12 @@ namespace Humbug\PhpScoper\Scoper; -use function array_diff; -use function array_keys; -use function array_map; -use function current; use Generator; -use Humbug\PhpScoper\PhpParser\FakeParser; use Humbug\PhpScoper\PhpParser\TraverserFactory; use Humbug\PhpScoper\Reflector; use Humbug\PhpScoper\Scoper; use Humbug\PhpScoper\Whitelist; -use function is_array; -use LogicException; -use const PHP_EOL; -use PhpParser\Error as PhpParserError; -use PhpParser\Node\Name; -use PhpParser\NodeTraverserInterface; -use PhpParser\Parser; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; -use Prophecy\Prophecy\ObjectProphecy; use Roave\BetterReflection\BetterReflection; use Roave\BetterReflection\Reflector\ClassReflector; use Roave\BetterReflection\Reflector\FunctionReflector; @@ -43,9 +29,15 @@ use Symfony\Component\Finder\Finder; use Throwable; use UnexpectedValueException; +use const PHP_EOL; +use function array_diff; +use function array_keys; +use function array_map; +use function current; use function Humbug\PhpScoper\create_fake_patcher; use function Humbug\PhpScoper\create_parser; use function implode; +use function is_array; use function sprintf; class PhpScoperSpecTest extends TestCase @@ -272,8 +264,7 @@ private function createSpecMessage( ?string $actual, array $expectedRegisteredClasses, array $expectedRegisteredFunctions - ): string - { + ): string { $formattedWhitelist = $this->formatSimpleList($whitelist->toArray()); $formattedWhitelistGlobalConstants = $this->convertBoolToString($whitelist->whitelistGlobalConstants()); diff --git a/tests/Scoper/PhpScoperTest.php b/tests/Scoper/PhpScoperTest.php index e04821f5..94a1ea70 100644 --- a/tests/Scoper/PhpScoperTest.php +++ b/tests/Scoper/PhpScoperTest.php @@ -14,7 +14,6 @@ namespace Humbug\PhpScoper\Scoper; -use Generator; use Humbug\PhpScoper\PhpParser\FakeParser; use Humbug\PhpScoper\PhpParser\TraverserFactory; use Humbug\PhpScoper\Reflector; @@ -28,19 +27,10 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; -use Roave\BetterReflection\BetterReflection; use Roave\BetterReflection\Reflector\ClassReflector; use Roave\BetterReflection\Reflector\FunctionReflector; -use Roave\BetterReflection\SourceLocator\Type\AggregateSourceLocator; -use Roave\BetterReflection\SourceLocator\Type\PhpInternalSourceLocator; -use Roave\BetterReflection\SourceLocator\Type\StringSourceLocator; -use Symfony\Component\Finder\Finder; -use Throwable; -use UnexpectedValueException; use function Humbug\PhpScoper\create_fake_patcher; use function Humbug\PhpScoper\create_parser; -use function implode; -use function sprintf; class PhpScoperTest extends TestCase {