Conversation
…BeforeRequiredParam` sniff
PHP 8.0 will deprecated required function parameters being placed after optional ones.
> Declaring a required parameter after an optional one is deprecated. As an
> exception, declaring a parameter of the form "Type $param = null" before
> a required one continues to be allowed, because this pattern was sometimes
> used to achieve nullable types in older PHP versions.
> ```php
> function test($a = [], $b) {} // Deprecated
> function test(Foo $a = null, $b) {} // Allowed
> ```
Refs:
* https://github.com/php/php-src/blob/69888c3ff1f2301ead8e37b23ff8481d475e29d2/UPGRADING#L145-L151
* php/php-src@3b08f53
This new sniff detects this.
Includes unit tests.
063b620 to
a4e8486
Compare
|
Hi guys, I've downloaded the dev version of the PHPCompatibility library and installed all dependencies with the composer but it seems that the current rule doesn't work for me. |
|
@ShkiperMe This is a closed PR, so please don't use it to ask for help on an unrelated issue (installation issues). There is an issue open with some pointers on how to get the If that doesn't help and you have a genuine bug report, please open an issue with a code sample so we can try and reproduce the issue. P.S.: Please don't (mis)gender maintainers. Not a good look. |
|
@jrfnl |
|
@ShkiperMe Not an inappropriate question, just not the right place to ask it. |
PHP 8.0 will deprecate required function parameters being placed after optional ones.
Refs:
This new sniff detects this.
Includes unit tests.
Related to #809