Re: Consensus on argument validation for built-in functions

From: Date: Tue, 11 Mar 2025 11:22:23 +0000
Subject: Re: Consensus on argument validation for built-in functions
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 11/03/2025 06:32, Gina P. Banyard wrote:
And if not a ValueError then it should be an E_WARNING. Raising a deprecation is frankly non-sensical. Validation errors exist to inform the person programing that there is an error with the call site that is preventable very easily. If we start emitting E_DEPRECATED instead of E_WARNING/throwing a ValueError, we are incentivising people to add throwing error handlers for E_DEPRECATED, something that I (and I know others too) lament constantly, as a deprecation is not an error.
I dedicated a whole section in a previous RFC to making essentially this same argument: https://wiki.php.net/rfc/deprecate-bareword-strings#e_warning_vs_e_deprecated The underlying problem is that "deprecation" isn't really a "severity", it's more a "category" of messages. It should maybe be a separate flag combined with the severity, so that E_DEPRECATION_NOTICE=E_NOTICE|E_DEPRECATED, and E_DEPRECATION_WARNING=E_WARNING|E_DEPRECATED That way we could signal the difference between "this is bad, but the behaviour will remain well-defined" (e.g. file I/O warnings, which would require a completely new API to eliminate) and "this is bad, and there are concrete plans to change it" (e.g. it will become an error, or start doing something different, in the next major version). -- Rowan Tommins [IMSoP]

Thread (16 messages)

« previous php.internals (#126715) next »