Skip to content

UnnecessaryIssetArguments ​

info on by default quick-fix

Group: Unused · PhpStorm name: UnnecessaryIssetArgumentsInspection

isset($m['a']['b']) already implies that $m and $m['a'] are set, so listing those containers as extra isset() arguments next to the deeper access is redundant. Drop them.

Example ​

php
<?php
function has_city(array $order, $customer)
{
    $a = isset($order, $order['ship']['city']);
    $b = isset($order['ship']['city'], $order['ship']);
    $c = isset(
        $customer->tags,
        $customer->tags[0],
        $customer
    );
    $d = isset($order['ship'], $order['ship']);
    $e = isset($order['bill']['zip'], $order['ship']);
    $f = isset($order);
    return [$a, $b, $c, $d, $e, $f];
}
php
<?php
function has_city(array $order, $customer)
{
    $a = isset($order['ship']['city']);
    $b = isset($order['ship']['city']);
    $c = isset(
        $customer->tags[0],
        $customer
    );
    $d = isset($order['ship'], $order['ship']);
    $e = isset($order['bill']['zip'], $order['ship']);
    $f = isset($order);
    return [$a, $b, $c, $d, $e, $f];
}

Reported:

  • line 4: Redundant isset() argument: a deeper array access already covers it.
  • line 5: Redundant isset() argument: a deeper array access already covers it.
  • line 7: Redundant isset() argument: a deeper array access already covers it.

Configure ​

In custos.json:

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

Suppress ​

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

php
// @custos-ignore UnnecessaryIssetArguments

/**
 * @noinspection UnnecessaryIssetArgumentsInspection
 */

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