From 095c36ecf857a99f77fad4e33423d54d5a00740b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 9 Dec 2021 13:02:20 +0100 Subject: [PATCH] Fix some PHPStan errors/.. --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/phpstan.yml | 1 + src/Composer/Compiler.php | 4 +-- .../Installer/InstallationManager.php | 2 +- .../Test/Downloader/ZipDownloaderTest.php | 26 +++++++++---------- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 4040da8c3..26a92fdb3 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -58,7 +58,7 @@ jobs: - php-version: "8.2" dependencies: highest-ignore os: ubuntu-latest - experimental: false + experimental: true steps: - name: "Checkout" diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 0488fa089..a3c9dc084 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -23,6 +23,7 @@ jobs: php-version: - "7.2" - "8.1" + fail-fast: false steps: - name: "Checkout" diff --git a/src/Composer/Compiler.php b/src/Composer/Compiler.php index 622965076..9bb3e8543 100644 --- a/src/Composer/Compiler.php +++ b/src/Composer/Compiler.php @@ -174,10 +174,10 @@ class Compiler } if ($extraFiles) { - throw new \RuntimeException('These files were expected but not added to the phar, they might be excluded or gone from the source package:'.PHP_EOL.implode(PHP_EOL, $extraFiles)); + throw new \RuntimeException('These files were expected but not added to the phar, they might be excluded or gone from the source package:'.PHP_EOL.var_export($extraFiles, true)); } if ($unexpectedFiles) { - throw new \RuntimeException('These files were unexpectedly added to the phar, make sure they are excluded or listed in $extraFiles:'.PHP_EOL.implode(PHP_EOL, $unexpectedFiles)); + throw new \RuntimeException('These files were unexpectedly added to the phar, make sure they are excluded or listed in $extraFiles:'.PHP_EOL.var_export($unexpectedFiles, true)); } // Add bin/composer diff --git a/src/Composer/Installer/InstallationManager.php b/src/Composer/Installer/InstallationManager.php index 07e6709c7..e1d3d2ee2 100644 --- a/src/Composer/Installer/InstallationManager.php +++ b/src/Composer/Installer/InstallationManager.php @@ -223,7 +223,7 @@ class InstallationManager }; $handleInterruptsUnix = function_exists('pcntl_async_signals') && function_exists('pcntl_signal'); - $handleInterruptsWindows = function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli'; + $handleInterruptsWindows = PHP_VERSION_ID >= 70400 && function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli'; $prevHandler = null; $windowsHandler = null; if ($handleInterruptsUnix) { diff --git a/tests/Composer/Test/Downloader/ZipDownloaderTest.php b/tests/Composer/Test/Downloader/ZipDownloaderTest.php index 3885a33e6..eec37356a 100644 --- a/tests/Composer/Test/Downloader/ZipDownloaderTest.php +++ b/tests/Composer/Test/Downloader/ZipDownloaderTest.php @@ -114,7 +114,7 @@ class ZipDownloaderTest extends TestCase $this->setPrivateProperty('hasZipArchive', true); $downloader = new MockedZipDownloader($this->io, $this->config, $this->httpDownloader); - $zipArchive = $this->getMockBuilder('ZipArchive')->onlyMethods(['open', 'extractTo'])->getMock(); + $zipArchive = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchive->expects($this->once()) ->method('open') ->will($this->returnValue(true)); @@ -137,10 +137,10 @@ class ZipDownloaderTest extends TestCase $this->setPrivateProperty('hasZipArchive', true); $downloader = new MockedZipDownloader($this->io, $this->config, $this->httpDownloader); $zipArchive = $this->getMockBuilder('ZipArchive')->getMock(); - $zipArchive->expects($this->at(0)) + $zipArchive->expects($this->once()) ->method('open') ->will($this->returnValue(true)); - $zipArchive->expects($this->at(1)) + $zipArchive->expects($this->once()) ->method('extractTo') ->will($this->throwException(new \ErrorException('Not a directory'))); @@ -158,10 +158,10 @@ class ZipDownloaderTest extends TestCase $this->setPrivateProperty('hasZipArchive', true); $downloader = new MockedZipDownloader($this->io, $this->config, $this->httpDownloader); $zipArchive = $this->getMockBuilder('ZipArchive')->getMock(); - $zipArchive->expects($this->at(0)) + $zipArchive->expects($this->once()) ->method('open') ->will($this->returnValue(true)); - $zipArchive->expects($this->at(1)) + $zipArchive->expects($this->once()) ->method('extractTo') ->will($this->returnValue(true)); @@ -189,7 +189,7 @@ class ZipDownloaderTest extends TestCase ->will($this->returnValue('output')); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); - $processExecutor->expects($this->at(0)) + $processExecutor->expects($this->once()) ->method('executeAsync') ->will($this->returnValue(\React\Promise\resolve($procMock))); @@ -216,7 +216,7 @@ class ZipDownloaderTest extends TestCase ->will($this->returnValue('output')); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); - $processExecutor->expects($this->at(0)) + $processExecutor->expects($this->once()) ->method('executeAsync') ->will($this->returnValue(\React\Promise\resolve($procMock))); @@ -246,15 +246,15 @@ class ZipDownloaderTest extends TestCase ->will($this->returnValue('output')); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); - $processExecutor->expects($this->at(0)) + $processExecutor->expects($this->once()) ->method('executeAsync') ->will($this->returnValue(\React\Promise\resolve($procMock))); $zipArchive = $this->getMockBuilder('ZipArchive')->getMock(); - $zipArchive->expects($this->at(0)) + $zipArchive->expects($this->once()) ->method('open') ->will($this->returnValue(true)); - $zipArchive->expects($this->at(1)) + $zipArchive->expects($this->once()) ->method('extractTo') ->will($this->returnValue(true)); @@ -286,15 +286,15 @@ class ZipDownloaderTest extends TestCase ->will($this->returnValue('output')); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); - $processExecutor->expects($this->at(0)) + $processExecutor->expects($this->once()) ->method('executeAsync') ->will($this->returnValue(\React\Promise\resolve($procMock))); $zipArchive = $this->getMockBuilder('ZipArchive')->getMock(); - $zipArchive->expects($this->at(0)) + $zipArchive->expects($this->once()) ->method('open') ->will($this->returnValue(true)); - $zipArchive->expects($this->at(1)) + $zipArchive->expects($this->once()) ->method('extractTo') ->will($this->returnValue(false));