Skip to content

ArrayColumnMissingField ​

warning native off by default

Group: Probable bugs

Detect array_column on a literal array of literal rows when at least one row has the requested literal field and at least one lacks it.

Example ​

php
<?php
array_column([["id"=>1],["name"=>"Ada"]],"id");

Reported:

  • line 2: Handle rows missing the selected field explicitly.

Detection ​

  • Report array_column on a literal array of literal rows when at least one row has the requested literal field and at least one lacks it.
  • Resolve builtin calls and named arguments before checking the contract. Project-local callees are considered only when their bodies or immutable summaries establish the required facts. The default is disabled; enable only when the stated intent matches the application.
  • For flow-dependent conditions, require a reachable source-to-use path with no intervening invalidation. Unknown calls, ambiguous aliases or recursion cannot establish definite facts. When the proof is inconclusive, nothing is reported.

Exceptions (no report) ​

  • Do not report object rows, unknown keys, uniformly missing fields, or cases where field presence is unknown.
  • Unresolved targets, incomplete required facts, suppressed findings and PHP versions lacking the referenced API or language feature produce no report. User declarations shadowing builtin names are not builtin contracts.

Fix ​

No automatic fix: whether to omit, reject, or substitute missing rows is an application decision.

PHP versions ​

Apply only on PHP versions supporting the referenced APIs and syntax (within PHP 5.3–8.5). Builtin behavior and argument contracts follow the configured PHP version. Extension-specific calls require resolved extension API symbols; do not treat same-named application functions as extension calls.

Options ​

None. Enable or disable this rule through normal rule configuration.

Configure ​

In custos.json:

json
{
  "rules": {
    "ArrayColumnMissingField": {
      "enabled": true
    }
  }
}

Suppress ​

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

php
// @custos-ignore ArrayColumnMissingField

Released under the MIT License. Native rules and rules modeled on Php Inspections (EA Extended); independent clean-room implementation.