From 11879ea737978fabb8127616e703e571ff71b184 Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 26 Apr 2023 14:26:45 +0100 Subject: [PATCH] ArrayLoader: handle invalid support value (#11440) --- src/Composer/Package/Loader/ArrayLoader.php | 2 +- .../Composer/Test/Package/Loader/ArrayLoaderTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index d33f1bc3f..67256e63f 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -282,7 +282,7 @@ class ArrayLoader implements LoaderInterface $package->setAuthors($config['authors']); } - if (isset($config['support'])) { + if (isset($config['support']) && \is_array($config['support'])) { $package->setSupport($config['support']); } diff --git a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php index 38ed6247b..f12a806f2 100644 --- a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php @@ -429,4 +429,16 @@ class ArrayLoaderTest extends TestCase $package = $this->loader->load($config); $this->assertCount(0, $package->getReplaces()); } + + public function testSupportStringValue(): void + { + $config = array( + 'name' => 'acme/package', + 'version' => 'dev-1', + 'support' => 'https://example.org', + ); + + $package = $this->loader->load($config); + $this->assertSame([], $package->getSupport()); + } }