Skip to content

PgAsyncDispatchAssumedQuerySuccess ​

warning native off by default

Group: Probable bugs

Inspect the asynchronous PostgreSQL result status.

Example ​

php
<?php
function f($c) { if(pg_send_query($c,'SELECT 7')){ return true; } return false; }
function g($c) { if (pg_send_query($c, 'SELECT 8')) return true; return false; }

Reported:

  • line 2: Inspect the asynchronous PostgreSQL result status.
  • line 3: Inspect the asynchronous PostgreSQL result status.

Detection ​

This is an opt-in policy. Truthiness, previous-state checks, raw wait-status comparisons and dispatch acknowledgements can be intentional; enabling this rule requests explicit handling of the contract described below.

  • D1. A pg_send_query or pg_send_query_params boolean success condition directly returns true, a literal success string, or calls a success-output sink without retrieving pg_get_result and checking pg_result_status first. Initial sinks are return true and echo literal text. Ordinary queue bookkeeping is excluded. The sink is the first statement the condition guards, whatever the branch syntax: a braced body, an alternative-syntax body (if: ... endif;) or a single statement without braces are equivalent.
  • 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.
  • An empty guarded body, or one whose first statement is anything other than an initial sink of D1, is not reported.
  • Both @custos-ignore PgAsyncDispatchAssumedQuerySuccess and @noinspection PgAsyncDispatchAssumedQuerySuccess suppress this native rule.

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": {
    "PgAsyncDispatchAssumedQuerySuccess": {
      "enabled": true
    }
  }
}

Suppress ​

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

php
// @custos-ignore PgAsyncDispatchAssumedQuerySuccess

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