phanalist

E0050: Position Check Used as Boolean

In plain English: strpos() returns 0 when the match is at the very start of the string. PHP treats 0 as false, so if (strpos(...)) treats a match at position zero as “not found.”

Why it matters: A valid match can silently take the “not found” branch.

Bad

if (strpos($path, '/')) {
    // A leading slash is at position 0, so this branch is skipped.
}

Good

if (strpos($path, '/') !== false) {
    // Found, including a match at position 0.
}

if (str_starts_with($path, '/')) {
    // Clearer when you only care about the prefix.
}

What the rule checks

A comparison makes the false result explicit. !== false, === 0, and >= 0 are accepted.

When it does not report

How to fix

Configuration

E0050 has no configuration options and is enabled by default.