composer / composer/installers

PHP 8.4 Deprecation: Implicitly marking parameter $binaryInstaller as nullable in Installer::__construct()

Open
#553 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
1.4k
Forks
400
PR merge metrics
No merged PRs in 30d

Description

### Description
When running with PHP 8.4, a deprecation notice is triggered in the Installer class. PHP 8.4 deprecates implicit nullable parameters (those that have a default value of null but lack an explicit ? type hint or |null union type).
### Error Message
Deprecation Notice: Composer\Installers\Installer::__construct(): Implicitly marking parameter $binaryInstaller as nullable is deprecated, the explicit nullable type must be used instead in /vendor/composer/installers/src/Composer/Installers/Installer.php:136
### Environment

- PHP Version: 8.4
- Package Version: 1.12.0
### Suggested Fix
The constructor in src/Composer/Installers/Installer.php needs to be updated to include an explicit nullable type hint for the $binaryInstaller parameter.
**Current code:**
`public function __construct(PackageInterface $package, Composer $composer, IOInterface $io, BinaryInstaller $binaryInstaller = null)`
**Fixed code:**
`public function __construct(PackageInterface $package, Composer $composer, IOInterface $io, ?BinaryInstaller $binaryInstaller = null)`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.