Skip to content

AliasFunctionsUsage ​

warning on by default quick-fix

Group: Language level migration · PhpStorm name: AliasFunctionsUsageInspection

Several built-in PHP functions exist only as alternative names for another built-in (sizeof for count, join for implode, …), and a few of those alternative names were deprecated or removed. Calling the canonical function keeps code consistent and avoids relying on legacy names.

Example ​

php
<?php
$total = sizeof($rows);
$csv   = \join(';', $cells);
$ok    = is_long($port) && is_writeable($dir);
magic_quotes_runtime(0);
$n = SizeOf($rows);
$s = $builder->join(',');  // E3
php
<?php
$total = count($rows);
$csv   = \implode(';', $cells);
$ok    = is_int($port) && is_writable($dir);
magic_quotes_runtime(0);
$n = count($rows);
$s = $builder->join(',');  // E3

Reported:

  • line 2: Use 'count(...)' instead of the alias 'sizeof(...)'.
  • line 3: Use 'implode(...)' instead of the alias 'join(...)'.
  • line 4: Use 'is_int(...)' instead of the alias 'is_long(...)'.
  • line 4: Use 'is_writable(...)' instead of the alias 'is_writeable(...)'.
  • line 5: 'magic_quotes_runtime(...)' is a legacy alias (deprecated 5.3, removed 7.0); stop relying on it.
  • line 6: Use 'count(...)' instead of the alias 'SizeOf(...)'.

Configure ​

In custos.json:

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

Suppress ​

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

php
// @custos-ignore AliasFunctionsUsage

/**
 * @noinspection AliasFunctionsUsageInspection
 */

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