Skip to content

ImplodeArgumentsOrder ​

info on by default quick-fix

Group: Code style · PhpStorm name: ImplodeArgumentsOrderInspection

implode() historically accepted its separator in either position; passing the pieces first and the separator second is deprecated (7.4) and removed (8.0). When the second argument is clearly the separator (a string literal), the arguments are swapped.

Example ​

php
<?php

$csv   = implode($cells, ';');
$path  = \implode( $segments ,  "/" );
$ok1   = implode(' | ', $labels);
$ok2   = implode($labels, $sep);
$ok3   = implode($labels);
$ok4   = join($labels, '-');
php
<?php

$csv   = implode(';', $cells);
$path  = \implode("/", $segments);
$ok1   = implode(' | ', $labels);
$ok2   = implode($labels, $sep);
$ok3   = implode($labels);
$ok4   = join($labels, '-');

Reported:

  • line 3: Pass the separator as the first argument of implode().
  • line 4: Pass the separator as the first argument of implode().

Options ​

OptionTypeDefaultEffect

Configure ​

In custos.json:

json
{
  "rules": {
    "ImplodeArgumentsOrder": {
      "enabled": false
    }
  }
}

Suppress ​

Before the statement or declaration (or the first statement of the file), either of:

php
// @custos-ignore ImplodeArgumentsOrder

/**
 * @noinspection ImplodeArgumentsOrderInspection
 */

Released under the MIT License. Rule catalogue modelled on Php Inspections (EA Extended); independent clean-room implementation.