phanalist

E0047: Resource Lifecycle Leak

E0047 reports function-scoped resources that are opened and never closed or transferred to another owner. It complements the verification rule E0043, which reports use-after-close and double-close on tracked streams.

What it checks

The rule scans each function, method, interface method, trait method, and enum method independently. A finding is reported only when the handle is used and stays local to that body: it is not closed, returned, stored in a property or array, passed to a constructor, or passed to a call whose behavior is unknown. Handles that are opened but never used as resources are ignored, because they may be placeholder or discarded results.

Common stream operations such as fread(), fwrite(), fgets(), feof(), fseek(), stream_get_contents(), readdir(), and proc_get_status() are treated as consumers, not ownership transfers. This allows the rule to report a forgotten close even when the handle was used for I/O first.

Model limits

The rule is intentionally conservative and does not perform alias or reference analysis:

Configuration

E0047 has no configuration options and is enabled by default.