FiberReturnBeforeTermination
error native on by default PHP ≥ 8.1Group: Probable bugs
Identify getReturn on a locally allocated Fiber after start of a callback proven to suspend before termination, without a subsequent completion-proving resume.
Detection
- Report getReturn on a locally allocated Fiber after start of a callback proven to suspend before termination, when nothing can have completed the fiber before the read. The proof requires that the receiver variable is named only by its allocation, by start calls that dominate the read, and by the read itself in all code that can run before the read: everything textually before it in the same variable scope, plus the whole outermost enclosing loop when the read sits in one.
- 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.
Exceptions (no report)
- Exclude unresolved required symbols, user-defined lookalikes, incomplete syntax, unknown required values and unsupported versions.
- Any other mention of the receiver variable before the read abandons the proof, wherever it sits: a resume or throw inside a loop, branch, try block or arrow function, a state query such as isTerminated or isSuspended guarding the read, an alias assignment, an array or callable holding the fiber, or the fiber passed as an argument. Variable variables and calls to compact, extract or get_defined_vars in that code abandon it too. Nested functions, methods, property hooks and closures have their own variables and are not searched.
- Both
@custos-ignore FiberReturnBeforeTerminationand@noinspection FiberReturnBeforeTerminationsuppress this native rule.
Fix
None. A repair requires a semantic decision or application error-handling policy.
PHP versions
Requires PHP 8.1 or later. 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": {
"FiberReturnBeforeTermination": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file):
php
// @custos-ignore FiberReturnBeforeTermination