Skip to content

SqliteNullBindingDiscardsValue ​

warning native on by default

Group: Probable bugs

Pass null when using the SQLite null binding type.

Example ​

php
<?php
function f(SQLite3Stmt $s) { $s->bindValue(1, 'ready', SQLITE3_NULL); }

Reported:

  • line 2: Pass null when using the SQLite null binding type.

Detection ​

  • SQLite3Stmt bindValue has explicit SQLITE3_NULL type and a proven nonnull scalar value. Unknown values and actual null are excluded; bindParam is excluded because later mutations change its value.
  • Resolve builtin functions, extension classes, constants and method receivers, including aliases and supported named arguments. Inspect reachable operations in one lexical scope with bounded local flow.
  • Emit one finding per violating operation. Never infer policy from names or comments. When the proof is inconclusive, nothing is reported.

Exceptions (no report) ​

  • Exclude shadowed or unresolved symbols, incomplete code, unknown required constants, ambiguous receiver identity and unsupported versions. Reassignment, escaping aliases, and unknown calls invalidate dependent flow facts.
  • Both @custos-ignore SqliteNullBindingDiscardsValue and @noinspection SqliteNullBindingDiscardsValue suppress this native rule.
  • A variable value is not trusted when the same lexical scope captures that variable by reference in a closure (use (&$value)) or stores it by reference in an array literal ([&$value]), wherever that happens in the scope: the alias can set it to null without a visible assignment. By-value captures and arrow functions do not count.

Fix ​

None. A safe repair requires choosing values, error handling, or application behavior.

PHP versions ​

Apply throughout PHP 5.3–8.5 only where the extension API and syntax exist. Do not flag API unavailability through this rule.

Options ​

None. Use normal rule configuration to enable or disable the inspection.

Configure ​

In custos.json:

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

Suppress ​

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

php
// @custos-ignore SqliteNullBindingDiscardsValue

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