Reported automatically by a code-commandments agent.
|
|
| Prophet |
StringsThatShouldBeEnumsProphet |
| Location |
src/Support/ValueBag.php:82 |
What's wrong
False positive on a generic value-bag accessor. ValueBag::asFloat(string $key) is a typed getter over an open string-keyed bag (port-name lookup, like array access / Fluent->get). The prophet flags $key as a closed set ['a','b','compareTo','value'] purely because asFloat currently has only 4 call sites; the sibling asString()/asInt()/asBool() take the identical $key param but are NOT flagged because they have more varied callers. The key space is open (any port name) — enum-ifying it would be wrong. Accessor methods whose $key is a free-form bag key should be exempt (e.g. exclude Illuminate\Support\Fluent subclasses, or methods named get/string/int/float/bool/asX on such).
Flagged code
public function asFloat(string $key, float $default = T_Float::ZERO): float
For the fixer
Decide whether this is a false positive (tighten/guard the prophet), a wrong rule (adjust the rule or its config), or correct-but-unclear (improve the message/scripture). Add a fixture from the flagged code above.
Reported automatically by a code-commandments agent.
StringsThatShouldBeEnumsProphetsrc/Support/ValueBag.php:82What's wrong
False positive on a generic value-bag accessor. ValueBag::asFloat(string $key) is a typed getter over an open string-keyed bag (port-name lookup, like array access / Fluent->get). The prophet flags $key as a closed set ['a','b','compareTo','value'] purely because asFloat currently has only 4 call sites; the sibling asString()/asInt()/asBool() take the identical $key param but are NOT flagged because they have more varied callers. The key space is open (any port name) — enum-ifying it would be wrong. Accessor methods whose $key is a free-form bag key should be exempt (e.g. exclude Illuminate\Support\Fluent subclasses, or methods named get/string/int/float/bool/asX on such).
Flagged code
For the fixer
Decide whether this is a false positive (tighten/guard the prophet), a wrong rule (adjust the rule or its config), or correct-but-unclear (improve the message/scripture). Add a fixture from the flagged code above.