Skip to content

PHP 8.4: Implicitly marking parameters as nullable is deprecated #195

Open
@jamieburchell

Description

@jamieburchell

A couple of function argument tweaks are required for PHP 8.4 compatibility. Specifically:

    /**
     * Create a new temperature object.
     *
     * @param Unit $now The current temperature.
     * @param Unit $min The minimal temperature.
     * @param Unit $max The maximal temperature.
     * @param Unit $day The day temperature. Might not be null.
     * @param Unit $morning The morning temperature. Might not be null.
     * @param Unit $evening The evening temperature. Might not be null.
     * @param Unit $night The night temperature. Might not be null.
     *
     * @internal
     */
     public function __construct(Unit $now, Unit $min, Unit $max, Unit $day = null, Unit $morning = null, Unit $evening = null, Unit $night = null)

becomes:

public function __construct(Unit $now, Unit $min, Unit $max, Unit $day = null, ?Unit $morning = null, ?Unit $evening = null, ?Unit $night = null)

and

    /**
     * Create a new wind object.
     *
     * @param Unit $speed     The wind speed.
     * @param Unit $direction The wind direction.
     *
     * @internal
     */
    public function __construct(Unit $speed, Unit $direction = null)

becomes

public function __construct(Unit $speed, ?Unit $direction = null)

The ability to mark parameters as nullable was introduced in PHP 7.1. I note your composer.json requires PHP >= 7.0

Happy to open a PR too

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions