Re: [RFC] Deprecate Fuzzy Type Casts and Allow Stringable in Strict Mode

From: Date: Fri, 23 Jan 2026 17:33:05 +0000
Subject: Re: [RFC] Deprecate Fuzzy Type Casts and Allow Stringable in Strict Mode
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-129905@lists.php.net to get a copy of this message
On Fri, Jan 23, 2026, 15:17 Alexandre Daubois <alex.daubois+php@gmail.com> wrote: > Hi Lynn, thank you for sharing your thoughts. > > Le ven. 23 janv. 2026 à 12:44, Lynn <kjarli@gmail.com> a écrit : > > What's the expected behavior of (int) '001' > > and (int) 1.? I would > expect both to still be valid integers, but I can't tell from this RFC if > those scenarios would be affected. The first scenario is common with > "ZEROFILL" database columns, and the latter is a scenario I recently found > being used to get a valid int from user input if considered number-ish and > switch between whole number vs decimal behavior. > > They will be indeed valid integers. There is no lossy cast here: "001" > and "1." are valid integers and expected. > According to whose definition of "lossy" is that not a lossy conversion? The only non lossy conversion is when (string) (int) $value === $value Everything else *is* lossy. The number of zeroes in front is information, so is the whitespace around the number. Your interpretation of lossy seems completely arbitrary to me. My opinion is that the BC break of this proposal in its current form would be insane and unreasonable.

« previous php.internals (#129905) next »