From d024d007db9bfe045a96c5ab87e607ba7e9b7701 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 21 Jul 2021 14:02:30 +0200 Subject: [PATCH] Fix some PHP 8.1 deprecation warnings, fixes #10008 --- src/Composer/DependencyResolver/Pool.php | 1 + src/Composer/Repository/ArrayRepository.php | 1 + tests/Composer/Test/Platform/HhvmDetectorTest.php | 6 +++++- tests/Composer/Test/Util/ProcessExecutorTest.php | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Composer/DependencyResolver/Pool.php b/src/Composer/DependencyResolver/Pool.php index 348583513ebc..ceb8777ee429 100644 --- a/src/Composer/DependencyResolver/Pool.php +++ b/src/Composer/DependencyResolver/Pool.php @@ -79,6 +79,7 @@ public function packageById($id) /** * Returns how many packages have been loaded into the pool */ + #[\ReturnTypeWillChange] public function count() { return \count($this->packages); diff --git a/src/Composer/Repository/ArrayRepository.php b/src/Composer/Repository/ArrayRepository.php index 90cf938f4210..07aa04db12bc 100644 --- a/src/Composer/Repository/ArrayRepository.php +++ b/src/Composer/Repository/ArrayRepository.php @@ -283,6 +283,7 @@ public function getPackages() * * @return int Number of packages */ + #[\ReturnTypeWillChange] public function count() { if (null === $this->packages) { diff --git a/tests/Composer/Test/Platform/HhvmDetectorTest.php b/tests/Composer/Test/Platform/HhvmDetectorTest.php index 51926156cd8c..d739fc8d3831 100644 --- a/tests/Composer/Test/Platform/HhvmDetectorTest.php +++ b/tests/Composer/Test/Platform/HhvmDetectorTest.php @@ -68,7 +68,11 @@ public function testHHVMVersionWhenExecutingInPHP() self::assertSame(self::getVersionParser()->normalize($version), self::getVersionParser()->normalize($detectedVersion)); } - /** @runInSeparateProcess */ + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @requires PHP < 8.1 + */ public function testHHVMVersionWhenRunningInHHVMWithMockedConstant() { if (!defined('HHVM_VERSION_ID')) { diff --git a/tests/Composer/Test/Util/ProcessExecutorTest.php b/tests/Composer/Test/Util/ProcessExecutorTest.php index 988682c01fb0..ca2a8112b53b 100644 --- a/tests/Composer/Test/Util/ProcessExecutorTest.php +++ b/tests/Composer/Test/Util/ProcessExecutorTest.php @@ -111,7 +111,7 @@ public function testConsoleIODoesNotFormatSymfonyConsoleStyle() $output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true); $process = new ProcessExecutor(new ConsoleIO(new ArrayInput(array()), $output, new HelperSet(array()))); - $process->execute('php -r "echo \'foo\'.PHP_EOL;"'); + $process->execute('php -ddisplay_errors=0 -derror_reporting=0 -r "echo \'foo\'.PHP_EOL;"'); $this->assertSame('foo'.PHP_EOL, $output->fetch()); }