Skip to content

PHP 7.4: New ParameterValues/RemovedImplodeFlexibleParamOrder sniff#846

Merged
wimg merged 1 commit intomasterfrom
php-7.4/deprecations/new-removedimplodeflexibleparamorder-sniff
Jul 22, 2019
Merged

PHP 7.4: New ParameterValues/RemovedImplodeFlexibleParamOrder sniff#846
wimg merged 1 commit intomasterfrom
php-7.4/deprecations/new-removedimplodeflexibleparamorder-sniff

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Jul 22, 2019

For historical reasons, the implode() function supports passing the $glue and $pieces parameters in reverse order from the documented order of arguments. This is inconsistent and makes the argument handling non-standard (for example, strict types are not respected). This also affects the alias join().

Proposal: Emit a deprecation warning when calling implode($pieces, $glue) or join($pieces, $glue). Calling the function with just an array continues to be allowed: implode($pieces) does not generate a deprecation warning.

The tolerance for the reverse order is expected to be removed completely in PHP 8.0.

Refs:

The new sniff tries to be quite comprehensive and to catch as much as is reliably sniffable.

Some test runs over well-known PHP projects have fine-tuned the sniff as it is now.

Includes unit tests.

Related to #808

>  For historical reasons, the `implode()` function supports passing the `$glue` and `$pieces` parameters in reverse order from the documented order of arguments. This is inconsistent and makes the argument handling non-standard (for example, strict types are not respected). This also affects the alias `join()`.
>
> Proposal: Emit a deprecation warning when calling `implode($pieces, $glue)` or `join($pieces, $glue)`. Calling the function with just an array continues to be allowed: `implode($pieces)` does not generate a deprecation warning.

The tolerance for the reverse order is expected to be removed completely in PHP 8.0.

Refs:
* https://wiki.php.net/rfc/deprecations_php_7_4#implode_parameter_order_mix
* https://php.net/manual/en/function.implode.php
* php/php-src@46b9824

The new sniff tries to be quite comprehensive and to catch as much as is reliably sniffable.

Some test runs over well-known PHP projects have fine-tuned the sniff as it is now.

Includes unit tests.

Related to 808
@jrfnl jrfnl force-pushed the php-7.4/deprecations/new-removedimplodeflexibleparamorder-sniff branch from e40c3e7 to 2231be6 Compare July 22, 2019 11:32
@wimg wimg merged commit a8d222f into master Jul 22, 2019
@delete-merged-branch delete-merged-branch bot deleted the php-7.4/deprecations/new-removedimplodeflexibleparamorder-sniff branch July 22, 2019 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants