From fdb35a6a061847d5f5c1fa440c00826f688c3879 Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Mon, 13 Apr 2020 06:41:10 +0700 Subject: [PATCH] Fix \Composer\Installer\PackageEvent::__construct() and \Composer\Repository\ComposerRepository::isVersionAcceptable() required arguments used after optional, which is deprecated in PHP 8.0 1. `Deprecated: Required parameter $name follows optional parameter $constraint in src\Composer\Repository\ComposerRepository.php on line 745` 2. `Deprecated: Required parameter $operation follows optional parameter $operations in src\Composer\Installer\PackageEvent.php on line 73` Optional parameters with a type declared, and a default value of `null` is excepted from this deprecation. See https://php.watch/versions/8.0/deprecate-required-param-after-optional. This is the case in `ComposerRepository::isVersionAcceptable`, which still has two optional parameters as first two parameters, but this will not raise a deprecation notice. --- src/Composer/Installer/PackageEvent.php | 2 +- src/Composer/Repository/ComposerRepository.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Installer/PackageEvent.php b/src/Composer/Installer/PackageEvent.php index 881820c91..0be86a77c 100644 --- a/src/Composer/Installer/PackageEvent.php +++ b/src/Composer/Installer/PackageEvent.php @@ -70,7 +70,7 @@ class PackageEvent extends Event * @param OperationInterface[] $operations * @param OperationInterface $operation */ - public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, RepositoryInterface $localRepo, array $operations = array(), OperationInterface $operation) + public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation) { parent::__construct($eventName); diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index e9131839c..3c59a6824 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -742,7 +742,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito * @param string $name package name (must be lowercased already) * @private */ - public function isVersionAcceptable(array $acceptableStabilities = null, array $stabilityFlags = null, $constraint = null, $name, $versionData) + public function isVersionAcceptable(array $acceptableStabilities = null, array $stabilityFlags = null, $constraint, $name, $versionData) { $versions = array($versionData['version_normalized']);