1
0
Fork 0

PHP 8.3 | Tests: fix deprecation notices (#11599)

* PHP 8.3 | ZipDownloaderTest: fix deprecation notice

Calling `ReflectionProperty::setValue()` with only one argument (to set a static property) is deprecated.
Passing `null` as the first (`$object`) parameter will work cross-version.

As the `ZipDownloaderTest::setPrivateProperty()` method has a `null` default value for the `$obj` parameter anyway, this means the if/else toggle can be removed.

Ref: https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures#reflectionpropertysetvalue

* PHP 8.3 | InstalledVersionsTest: fix deprecation notice

Calling `ReflectionProperty::setValue()` with only one argument (to set a static property) is deprecated.
Passing `null` as the first (`$object`) parameter will work cross-version.

Ref: https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures#reflectionpropertysetvalue

---------

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
pull/11601/head
Juliette 2023-08-30 11:42:33 +02:00 committed by GitHub
parent 094fb6cd70
commit 512690dba4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -65,11 +65,7 @@ class ZipDownloaderTest extends TestCase
$reflectionClass = new \ReflectionClass('Composer\Downloader\ZipDownloader');
$reflectedProperty = $reflectionClass->getProperty($name);
$reflectedProperty->setAccessible(true);
if ($obj === null) {
$reflectedProperty->setValue($value);
} else {
$reflectedProperty->setValue($obj, $value);
}
$reflectedProperty->setValue($obj, $value);
}
public function testErrorMessages(): void

View File

@ -33,14 +33,14 @@ class InstalledVersionsTest extends TestCase
$prop = new \ReflectionProperty('Composer\Autoload\ClassLoader', 'registeredLoaders');
$prop->setAccessible(true);
self::$previousRegisteredLoaders = $prop->getValue();
$prop->setValue([]);
$prop->setValue(null, []);
}
public static function tearDownAfterClass(): void
{
$prop = new \ReflectionProperty('Composer\Autoload\ClassLoader', 'registeredLoaders');
$prop->setAccessible(true);
$prop->setValue(self::$previousRegisteredLoaders);
$prop->setValue(null, self::$previousRegisteredLoaders);
InstalledVersions::reload(null); // @phpstan-ignore-line
}