Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depreciated: Required parameter $x follows optional parameter $y #1343

Closed
3 tasks done
johnstray opened this issue Aug 26, 2021 · 3 comments
Closed
3 tasks done

Depreciated: Required parameter $x follows optional parameter $y #1343

johnstray opened this issue Aug 26, 2021 · 3 comments
Labels
Bug DEV PHP_D PHP version deprecation or fixup

Comments

@johnstray
Copy link

johnstray commented Aug 26, 2021

When declaring a function or a method, adding a required parameter after optional parameters is deprecated since PHP 8.0. If you have a require parameter (i.e. a parameter without a default value set in its signature) after an optional one (i.e. a parameter with a default value), it makes all parameters before it essentially required because the caller has to explicitly pass a value for optional parameters as well.

More information here: https://php.watch/versions/8.0/deprecate-required-param-after-optional

So far, I have seen this here... [ PHP 8.0.0, GS v3.4.0.9-alpha ]

  • Required $lang follows optional $plugin - /admin/inc/basic.php on line 1415
  • Required $globali18n follows optional $plugin - /admin/inc/basic.php on line 1415
  • Required $default follows optional $var - /admin/inc/basic.php on line 2504
@tablatronix
Copy link
Member

oh ffs php!
lol

@tablatronix tablatronix added Bug DEV PHP_D PHP version deprecation or fixup labels Aug 28, 2021
@webketje
Copy link
Contributor

webketje commented Oct 5, 2021

It is definitely best practice to put required params before optional ones, but with PHP8 also comes the ability to circumvent having to specify prior null args with named arguments

@tablatronix
Copy link
Member

These shouldn't even exist, must have added new args to these at some point, Let me know if this breaks anything...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug DEV PHP_D PHP version deprecation or fixup
Projects
None yet
Development

No branches or pull requests

3 participants