Related: #3145797: [META] Make Drupal 7 core compatible with PHP 8.0
PHP 8.0 issues deprecation notices when an optional parameter appears before the last required parameter of a function or a class method.
Adding preliminarily fixes to run in Drupal infra.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3156847-drupal7-php8-required-parameter-after-optional--2.patch | 5.73 KB | ayesh |
Issue fork drupal-3156847
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3156847-php-8-parameter
changes, plain diff MR !362
Comments
Comment #2
ayesh commentedComment #3
ayesh commentedComment #4
sjerdoWe shouldn't just make all subsequent parameters optional
Eg for SelectQuery, the parent class Query requires the $connection parameter, which was made optional in patch #2
https://3v4l.org/A3j9G
We should change this so $alias is required too (but allow null). Parameter $connection is required by the parent class.
See https://3v4l.org/A3j9G
Comment #5
ayesh commentedYou are right, thanks @sjerdo.
I updated the patch with that method now making `$alias` parameter a required one.
Comment #8
taran2lhi @Ayesh, I've made a few changes and opened an MR. Please review.
In general, I think optional params can safely be made required because when the corresponding code is being called they are always set anyway with a few exceptions. Please see my comments in MR
Comment #9
taran2lComment #10
fabianx commentedSetting to RTBC
Comment #13
mcdruid commentedThank you!
Comment #18
poker10 commentedAdded credits from the duplicate issue #3018815: Optional parameters must be at end of argument list.