From 1f63b44b95663cb1f11d0f4e64c53524e7dac5f2 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sat, 20 Jul 2024 23:29:11 +0200 Subject: [PATCH 1/3] Fix function with multiple namespaces --- src/Autoload/ScoperAutoloadGenerator.php | 2 +- tests/Autoload/ScoperAutoloadGeneratorTest.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Autoload/ScoperAutoloadGenerator.php b/src/Autoload/ScoperAutoloadGenerator.php index b4c9206a..decbbf11 100644 --- a/src/Autoload/ScoperAutoloadGenerator.php +++ b/src/Autoload/ScoperAutoloadGenerator.php @@ -306,7 +306,7 @@ private static function groupFunctionsByNamespace(array $exposedFunctions): arra $originalFQ = new FullyQualified($exposed); $namespace = $originalFQ->slice(0, -1); - $functionName = null === $namespace ? $exposed : (string) $originalFQ->slice(1); + $functionName = null === $namespace ? $exposed : (string) $originalFQ->slice(-1, 1); $groupedFunctions[(string) $namespace][] = [$exposed, $functionName, $prefix]; } diff --git a/tests/Autoload/ScoperAutoloadGeneratorTest.php b/tests/Autoload/ScoperAutoloadGeneratorTest.php index 7fa4b91d..867c96a9 100644 --- a/tests/Autoload/ScoperAutoloadGeneratorTest.php +++ b/tests/Autoload/ScoperAutoloadGeneratorTest.php @@ -188,6 +188,7 @@ public static function provideRegistry(): iterable ['Acme\bar', 'Humbug\Acme\bar'], ['Acme\foo', 'Humbug\Acme\foo'], ['Emca\baz', 'Humbug\Emca\baz'], + ['Acme\Emca\foo', 'Humbug\Acme\Emca\foo'], ], ), [], @@ -218,6 +219,10 @@ public static function provideRegistry(): iterable // Function aliases. For more information see: // https://github.com/humbug/php-scoper/blob/master/docs/further-reading.md#function-aliases + namespace Acme\Emca { + if (!function_exists('Acme\Emca\foo')) { function foo() { return \Humbug\Acme\Emca\foo(...func_get_args()); } } + } + namespace Acme { if (!function_exists('Acme\bar')) { function bar() { return \Humbug\Acme\bar(...func_get_args()); } } if (!function_exists('Acme\foo')) { function foo() { return \Humbug\Acme\foo(...func_get_args()); } } From cf83e2575fd6a96bd7a3a5b837ff2c406d337fdd Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 15 Aug 2024 10:53:20 +0200 Subject: [PATCH 2/3] Fix cs --- tests/Autoload/ScoperAutoloadGeneratorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Autoload/ScoperAutoloadGeneratorTest.php b/tests/Autoload/ScoperAutoloadGeneratorTest.php index 867c96a9..939de540 100644 --- a/tests/Autoload/ScoperAutoloadGeneratorTest.php +++ b/tests/Autoload/ScoperAutoloadGeneratorTest.php @@ -222,7 +222,7 @@ public static function provideRegistry(): iterable namespace Acme\Emca { if (!function_exists('Acme\Emca\foo')) { function foo() { return \Humbug\Acme\Emca\foo(...func_get_args()); } } } - + namespace Acme { if (!function_exists('Acme\bar')) { function bar() { return \Humbug\Acme\bar(...func_get_args()); } } if (!function_exists('Acme\foo')) { function foo() { return \Humbug\Acme\foo(...func_get_args()); } } From 7293887e7d38ecbcaac668c8024622ccd21cee9a Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 2 Sep 2024 15:26:19 +0200 Subject: [PATCH 3/3] Fix --- tests/AutoReview/GAE2ETest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/AutoReview/GAE2ETest.php b/tests/AutoReview/GAE2ETest.php index a574103a..f93e0858 100644 --- a/tests/AutoReview/GAE2ETest.php +++ b/tests/AutoReview/GAE2ETest.php @@ -31,7 +31,7 @@ class GAE2ETest extends TestCase public function test_github_actions_executes_all_the_e2e_tests(): void { - $expected = array_diff(E2ECollector::getE2ENames(), self::IGNORED_E2E_TESTS); + $expected = array_values(array_diff(E2ECollector::getE2ENames(), self::IGNORED_E2E_TESTS)); $actual = GAE2ECollector::getExecutedE2ETests(); self::assertEqualsCanonicalizing($expected, $actual);