Skip to content

SocketReadZeroRejected ​

warning native on by default

Group: Probable bugs

Identify socket_read in PHP_BINARY_READ mode tested by negation or loose false equality in a branch throwing or returning false. Strict false and explicit empty string checks exclude.

Detection ​

  • Report socket_read in PHP_BINARY_READ mode tested by negation or loose false equality in a branch throwing or returning false. Strict false and explicit empty string checks exclude.

  • The mode is PHP_BINARY_READ when the builtin constant is passed as the third or mode argument, and also when no mode argument is passed at all, because that is the parameter default. Any other mode expression is unknown.

  • Resolve builtin functions, classes, constants and methods, including imports and supported named arguments. Follow only bounded local facts within one lexical scope. Receiver and argument provenance must establish the specific API contract; variable names and comments never prove intent.

  • Report one finding per violating operation. A reachable path, unchanged value identity and applicable API behavior are required. Intervening mutation, unknown calls involving tracked values, escaped aliases or exhausted analysis budgets invalidate proof.

  • A failure test must select a falsy result: count negation and loose equality with literal false, on either side, by parity. Parentheses, error suppression and the right-hand value of a plain non-reference assignment preserve the test. Compound assignments and assignment targets do not.

  • Require every supported path through the failure body to throw or return literal false. A conditional rejection alone is insufficient. Structured blocks and conditional branches are bounded; suspension, jumps, unsupported control flow and budget exhaustion establish no rejection proof.

Exceptions (no report) ​

  • Exclude unresolved required symbols, user-defined lookalikes, incomplete syntax, unknown required values and unsupported versions.
  • No report when the call spreads arguments (...$args) or is a first-class callable (socket_read(...)): the mode binding cannot be established.
  • Both @custos-ignore SocketReadZeroRejected and @noinspection SocketReadZeroRejected suppress this native rule.

Fix ​

None. A repair requires a semantic decision or application error-handling policy.

PHP versions ​

Available in PHP 5.3–8.5 where the referenced API exists. Do not apply extension contracts when the resolved API is unavailable. Gate syntax and version-specific behavior to the configured target.

Configure ​

In custos.json:

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

Suppress ​

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

php
// @custos-ignore SocketReadZeroRejected

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