1
0
Fork 0

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)
...
```
pull/10053/head
jrfnl 2021-08-05 06:18:14 +02:00
parent c65bd832d6
commit 7022ceb0a6
1 changed files with 1 additions and 1 deletions

View File

@ -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);
}