From 7022ceb0a60c5a69a5204d3db9685b161911454d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 5 Aug 2021 06:18:14 +0200 Subject: [PATCH] PHP 8.1: prevent a "null to non-nullable" deprecation notice (test only fix) Not all tests in the `InstallerTest` class actually create a temporary directory and set the `$this->tempComposerHome` property. Those tests which didn't, throw a notice in PHP 8.1. Fixes 3 notices along the lines of: ``` Deprecation triggered by Composer\Test\InstallerTest::tearDown: is_dir(): Passing null to parameter #1 ($filename) of type string is deprecated Stack trace: 0 [internal function]: Symfony\Bridge\PhpUnit\DeprecationErrorHandler->handleError(8192, '...', '...', 53) 1 tests/Composer/Test/InstallerTest.php(53): is_dir(NULL) ... ``` --- tests/Composer/Test/InstallerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index 8be804206..3526db5c1 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -50,7 +50,7 @@ class InstallerTest extends TestCase public function tearDown() { chdir($this->prevCwd); - if (is_dir($this->tempComposerHome)) { + if (isset($this->tempComposerHome) && is_dir($this->tempComposerHome)) { $fs = new Filesystem; $fs->removeDirectory($this->tempComposerHome); }