Skip to content

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

@wesolydexter

Description

@wesolydexter

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions