[wp-trac] [WordPress Trac] #50343: [PHP 8] Fix deprecation notices for optional function parameters declared before required parameter.

WordPress Trac noreply at wordpress.org
Tue Aug 11 17:23:18 UTC 2020


#50343: [PHP 8] Fix deprecation notices for optional function parameters declared
before required parameter.
-------------------------------------------+-------------------------------
 Reporter:  ayeshrajans                    |       Owner:  (none)
     Type:  enhancement                    |      Status:  new
 Priority:  normal                         |   Milestone:  5.6
Component:  General                        |     Version:
 Severity:  normal                         |  Resolution:
 Keywords:  has-patch php8 has-unit-tests  |     Focuses:  coding-standards
-------------------------------------------+-------------------------------

Comment (by jrf):

 I've reviewed the patch and for the most part, I would like to suggest an
 alternative approach.

 The original approach by @ayeshrajans was to make any parameters ''after''
 the optional parameter, also optional.

 Save for one specific case (rest api test), I propose doing the opposite:
 making the optional parameter declared before required parameters,
 required.

 As it already wasn't possible to pass the required parameters without also
 passing the optional one anyway, removing the default value for the (not
 so) optional parameters should not be regarded as a BC break.
 I've also updated the docblock `@param` tags with the expected value to
 "skip" the parameter.

 Other notes regarding this PHP 8 change:

 Both SimplePie as well as GetID3 also have (had) instances of this issue.
 I have opened PRs in both projects to fix this.

 The PR in GetID3 has been merged already and is expected to be included in
 the next release.

 * https://github.com/JamesHeinrich/getID3/pull/259
 * https://github.com/simplepie/simplepie/pull/656

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


More information about the wp-trac mailing list