RecursiveTraversalOmitsDirectories
warning native off by default PHP ≥ 5.3Group: Probable bugs
Include parent nodes when traversing directories. This opt-in inspection applies the policy stated in Detection.
Example
Finding with the rule explicitly enabled:
php
<?php
$dir = new RecursiveDirectoryIterator("."); $it = new RecursiveIteratorIterator($dir);Reported:
- line 2: Include parent nodes when traversing directories.
Detection
- Enabled policy requires directory nodes as well as leaves. Report construction of RecursiveIteratorIterator wrapping a proven RecursiveDirectoryIterator, directly or through RecursiveCallbackFilterIterator, when mode is omitted or explicitly LEAVES_ONLY. Highlight constructor call.
- Emit one finding per violating operation. Flow facts require a reachable path with no intervening mutation, escaped alias, unknown call involving the tracked value or analysis-budget exhaustion. Uncertain facts cannot prove a violation.
Exceptions (no report)
- SELF_FIRST and CHILD_FIRST satisfy the policy. Unknown iterator source and arbitrary recursive iterators are excluded.
- Exclude shadowed builtin symbols, unresolved required types, incomplete syntax and unsupported PHP versions.
Fix
No automatic fix. Choosing a repair requires runtime information, error-handling policy or a semantic decision.
All edits use exact byte ranges, preserve comments and evaluation order, and require syntax supported by the target PHP version. A fix must never add an evaluation or silently change unrelated arguments.
PHP versions
Minimum PHP 5.3.
Options
None. Enabling the rule declares the policy stated in Detection; the rule is disabled by default.
Configure
In custos.json:
json
{
"rules": {
"RecursiveTraversalOmitsDirectories": {
"enabled": true
}
}
}Suppress
Before the statement or declaration (or the first statement of the file):
php
// @custos-ignore RecursiveTraversalOmitsDirectories