CurlResponseZeroRejected
warning native on by defaultGroup: Probable bugs
Identify curl_exec result used in a truthiness-based failure branch when the same handle has RETURNTRANSFER proven true, and failure branch throws or returns false. Unknown response still merits this contract warning.
Detection
Report curl_exec result used in a truthiness-based failure branch when the same handle has RETURNTRANSFER proven true, and failure branch throws or returns false. Unknown response still merits this contract warning.
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 or escaped aliases invalidate proof. When the proof is inconclusive, nothing is reported.
D4. The RETURNTRANSFER proof is the result of replaying, in source order, every dominating
curl_setoptandcurl_setopt_arraywrite on the handle. A truthyCURLOPT_RETURNTRANSFERestablishes it; a falsy or unknown value clears it.CURLOPT_FILEandCURLOPT_WRITEFUNCTIONreplace the write sink, socurl_execreturns a boolean again: they clear the proof until a later truthyCURLOPT_RETURNTRANSFER. Any other option named by a builtin constant leaves it unchanged.The failure condition must negate the call an odd number of times, counting each
!and each loose== falsebetween the call and theif. Parentheses and assignments are transparent.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 a write on the handle cannot be read: a
curl_setoptwhose option is not a builtin constant (variable, class constant, user constant, number), or acurl_setopt_arraywhose options are not a literal array with builtin constant keys. Such a write may disable RETURNTRANSFER, so it clears the proof like D4's sink options. - No report for an even number of negations such as
!!curl_exec($ch); that branch runs when a body was received. - Both
@custos-ignore CurlResponseZeroRejectedand@noinspection CurlResponseZeroRejectedsuppress 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:
{
"rules": {
"CurlResponseZeroRejected": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file):
// @custos-ignore CurlResponseZeroRejected