[wp-trac] [WordPress Trac] #60786: [PHP 8.4] Fix implicit nullable parameter type depcation

WordPress Trac noreply at wordpress.org
Wed May 1 17:29:02 UTC 2024


#60786: [PHP 8.4] Fix implicit nullable parameter type depcation
-----------------------------+--------------------------------
 Reporter:  ayeshrajans      |       Owner:  SergeyBiryukov
     Type:  defect (bug)     |      Status:  closed
 Priority:  normal           |   Milestone:  6.6
Component:  General          |     Version:
 Severity:  normal           |  Resolution:  fixed
 Keywords:  php84 has-patch  |     Focuses:  php-compatibility
-----------------------------+--------------------------------
Changes (by jrf):

 * status:  reopened => closed
 * resolution:   => fixed


Comment:

 Replying to [comment:10 GaryJ]:
 > @SergeyBiryukov The RFC gives an example code change, that drops the `=
 null` when the nullable type is present. Since the default value is `null`
 when another value is not assigned to a function parameter, could we
 update the entries you changed from (for example):
 >
 >
 > {{{
 > - function test( ?string $test = null ) {}
 > + function test( ?string $test ) {}
 > }}}


 @GaryJ Making a parameter nullable does not make it optional. Removing the
 default value is a signature change which will break code:
 https://3v4l.org/L9ZAP

 The only time this change can/should be made is when the "optional"
 (implicitly nullable) parameter was _before_ a required parameter.

 In all other cases, removing the default value is a breaking change.

 @SergeyBiryukov Please do NOT action this.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60786#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list