Re: [RFC] Deprecate Invalid Filter Options
| From: | Tim Düsterhus | Date: | Fri, 09 Oct 2026 12:22:17 +0000 |
| Subject: | Re: [RFC] Deprecate Invalid Filter Options | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-132852@lists.php.net to get a copy of this message | ||
Hi
On 2026-10-09 10:21, Muhammed Arshid KV wrote:
I understand the concern about type safety. However, the real-world usage of filter_var() is worth considering too. Many use cases only require a filter ID, without any flags. Sourcegraph search: https://sourcegraph.com/search?q=context:global+lang:php+filter_var%5C%28&patternType=regexp&sm=0 If combined bitmasks are uncommon in practice, a Filter\Flag enum could still improve the API for individual flags. I agree that we should weigh this benefit against the loss of type safety when combining flags.An enum would slightly improve the API for the
filter_var() use case without any flags. But for filter_var_array() it already would no longer work and for filter_var() with flags, it would result in a weird mixture of a strong enum with “free form” options field.
I believe that introducing enums right now is not doing enough to meaningfully improve the developer experience. As an example, if we already had Tagged Unions (https://wiki.php.net/rfc/tagged_unions), the per-filter options could be provided directly with the union case:
filter_var($foo, Filter\Int(allowOctal: true, allowHex: true));Introducing the enum right now likely would block off that path. Best regards Tim Düsterhus