From 23b0a3819bb74214f04a0799c6f998c9822f54f4 Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 9 Feb 2022 10:45:10 +0000 Subject: [PATCH 1/4] ComposerRepository: fix array_keys(): Argument #1 () must be of type array, null given (#10529) --- src/Composer/Repository/ComposerRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 0154a49a5..640001cec 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -657,7 +657,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito return array(); } - if ($this->providersUrl) { + if (null !== $this->providersUrl && null !== $this->providerListing) { return array_keys($this->providerListing); } From eee8816bc3b2cc4b5d97ae7b526a8169246944ce Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 15 Feb 2022 16:14:06 +0100 Subject: [PATCH 2/4] Fix allow-plugins:false handling, fixes #10530 --- src/Composer/Plugin/PluginManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index c6073561b..fc89f9e52 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -656,7 +656,7 @@ class PluginManager } if (false === $allowPluginsConfig) { - return array('{^$}D' => false); + return array('{}' => false); } $rules = array(); From f808e4907cc656ba5728979186ab534048a89c38 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 15 Feb 2022 16:41:06 +0100 Subject: [PATCH 3/4] Fix handling for non-lowercased enum keyword, fixes #10521 --- src/Composer/Autoload/ClassMapGenerator.php | 2 +- tests/Composer/Test/Autoload/Fixtures/php8.1/enum_backed.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index cc2598596..4b38565eb 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -271,7 +271,7 @@ class ClassMapGenerator if ($name[0] === ':') { // This is an XHP class, https://github.com/facebook/xhp $name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1); - } elseif ($matches['type'][$i] === 'enum') { + } elseif (strtolower($matches['type'][$i]) === 'enum') { // something like: // enum Foo: int { HERP = '123'; } // The regex above captures the colon, which isn't part of diff --git a/tests/Composer/Test/Autoload/Fixtures/php8.1/enum_backed.php b/tests/Composer/Test/Autoload/Fixtures/php8.1/enum_backed.php index bab09e31b..3954c43e8 100644 --- a/tests/Composer/Test/Autoload/Fixtures/php8.1/enum_backed.php +++ b/tests/Composer/Test/Autoload/Fixtures/php8.1/enum_backed.php @@ -1,6 +1,6 @@ Date: Tue, 15 Feb 2022 16:42:50 +0100 Subject: [PATCH 4/4] Make tests more robust --- tests/Composer/Test/ConfigTest.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/Composer/Test/ConfigTest.php b/tests/Composer/Test/ConfigTest.php index fdf2587a3..d9d5c8cb2 100644 --- a/tests/Composer/Test/ConfigTest.php +++ b/tests/Composer/Test/ConfigTest.php @@ -330,16 +330,20 @@ class ConfigTest extends TestCase { Platform::putEnv('COMPOSER_PROCESS_TIMEOUT', '0'); $config = new Config(true); - $this->assertEquals(0, $config->get('process-timeout')); + $result = $config->get('process-timeout'); Platform::clearEnv('COMPOSER_PROCESS_TIMEOUT'); + + $this->assertEquals(0, $result); } public function testHtaccessProtect() { Platform::putEnv('COMPOSER_HTACCESS_PROTECT', '0'); $config = new Config(true); - $this->assertEquals(0, $config->get('htaccess-protect')); + $result = $config->get('htaccess-protect'); Platform::clearEnv('COMPOSER_HTACCESS_PROTECT'); + + $this->assertEquals(0, $result); } public function testGetSourceOfValue() @@ -362,7 +366,9 @@ class ConfigTest extends TestCase { Platform::putEnv('COMPOSER_HTACCESS_PROTECT', '0'); $config = new Config; - $this->assertEquals('COMPOSER_HTACCESS_PROTECT', $config->getSourceOfValue('htaccess-protect')); + $result = $config->getSourceOfValue('htaccess-protect'); Platform::clearEnv('COMPOSER_HTACCESS_PROTECT'); + + $this->assertEquals('COMPOSER_HTACCESS_PROTECT', $result); } }