Skip to content

No deprecation warning is triggered for nullable optional parameters before required ones #8024

Closed
@m-vo

Description

@m-vo

Description

The following code:

<?php

function foo(int $param_optional = null, int $param_required) {}

Resulted in this output:

(no deprecation warning triggered)

But I expected this output instead:

Deprecated: Optional parameter $param_optional declared before required parameter $param_required is implicitly treated as a required parameter in […]```

It seems having a nullable parameter will prevent the deprecation from being triggered. See https://3v4l.org/biVG1#v8.1.2 for a comparison.

PHP Version

>=PHP8.0

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions