Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129886 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 7CF371A00BC for ; Fri, 23 Jan 2026 11:44:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769168672; bh=M7aCVmm5guUSoPkqORGUAv3/dSHXtqhEOEnB1zVhXaU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=PAGM5tQC5h3kV0i/Ewf6rqeufYfZKxadRp2H3xlrRcpbL7NGyWeBMqUxL35QYv4Fe A0aCp7eEq4Cm071SgjkzUa0bErPb/ExSr2FS1jnbmepV8QXwcGMskSIgVcmyw1jvZl jmYHvrpBSxnIurpNt8vmyXGjDIXe21NwXJ/b1LvwAbAQ/NgfwzCoYGCcPRty4+H7BK P/ju9JapVI/ze5YObDOyA52J4mi+CP3H0z/Bc4ppOK0pLHJIsBdAtvrL7tnpGtJ9kj lWu4pBJFG8N4QBh+as20sWES6+8NZjqne/QBH8Pg6bREWSdhwCmNC3UwVbTXvOhyOj QwwCu2rulAeOw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B127B180039 for ; Fri, 23 Jan 2026 11:44:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_FROM,FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 23 Jan 2026 11:44:17 +0000 (UTC) Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-382fd45a1feso21714231fa.0 for ; Fri, 23 Jan 2026 03:44:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769168651; cv=none; d=google.com; s=arc-20240605; b=ZIT+XIQcGCT3sG0/aub2y+aQz9dmRBn+n6R2KJRnfH0JepI7vv2O/FQ6PhWAslIs19 yqh61cQdG6FqqNJe3j3xZ3dk8M5CXtHtS7/Pq36JVtRKdwGUs50ZR4ViCyVM1qHySc8U LvpOSExopDP2dI2VTQz34MRhTA9cWVH1XTr8GZw6TuDZ0vYzIfDsIaBZcRojCFLjh6jl 8qg6QwjYDD/Du4u+8wiQmrVhp+r7ySvtNjJS9Kv4XgDZc6aONOQGiyhsrjAmh0e42peo pZdL3Rv0j7e638NM938neTxdM7j2xhIBRDFdvxN/oBz2JwF5oTX5AFQwBpYNlYmNV9g0 TYzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=M7aCVmm5guUSoPkqORGUAv3/dSHXtqhEOEnB1zVhXaU=; fh=l07cGoIg3TRylNOf7lMYEJBLdTFa5KOl1A4mid5ExIM=; b=UbDiPI+eqDg0XyipO8RxkE0eh40ocAEO6notU012jTJvqqqvr8b19iwYs3yYdMz9lU 5iygDAGipOpCIng/zv1LWBcEaNldxbEBb+k7XYOqptscfHsm/vgMm0caVrHlH3r3MaQg fTmC4yeRfNVUojLOJYUYLd4/9T6GHmbSG9ia2qV/t9pLfJEoy4NAa2/Ch2tYEXpPNqn+ TKOvE5bfsUoKerIMnrlnt1kEmRrWgUuRalOf+aS0sfBOWI1jA83PHwrrlz06GgjW4wAN MMn1uA8uKYAYiQkXtt27D/CdrUEW/eRtXNkIVGDLDYLeUKwJN6xlko7e/o1z8kMjpuaH bmdQ==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769168651; x=1769773451; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=M7aCVmm5guUSoPkqORGUAv3/dSHXtqhEOEnB1zVhXaU=; b=OxuPli6DdQB6ldPOHIh3fL0rLoMoVUTORy81o98my0lAcWLPWWXZgiDOGY/xZohZrR AneHsU6/Yo/5aGwaj3J1BnODNT5wX4Xye3asGrvbEC5sDOLOvxrFeyJZ/mRExVxXx9F7 7IPfmQfl3iiXPfHbz7hIfgrfynDGvBMV1jnq5KbrjCELwzrB+sR1dRF3gUdgRUhEGqDj rc+FkbFHpe0LoRdOoWZMfAUc8Fu5ZSIUVobWBq7QWGuKX1Sv+4Oi96s54caEzuSvdDh+ YEZRKlYc8YmCaEEI75zT2h+ktQj4/kM6aZcw+dkc2srly19xG4XCwujxv0jS+8fGx619 HMoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769168651; x=1769773451; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=M7aCVmm5guUSoPkqORGUAv3/dSHXtqhEOEnB1zVhXaU=; b=APuCv4GWzbsNieYr/4hHnrz0CyE1XCfUX+zBVylYN4oEa9dT7ctH2FvbzlG1OElCDb mH55C7r25Y7CwD35L7qTZLuvcXAZr05M6ZsHC1dDgo72ulx4My6MLgywaCFUbyz15keR D6cno7sihdKxmUL/sxTpHQC4ZNUpQeDgU7FUwSEOqhbP5u7P75I/tgfcNd183xdA8lL/ 7/DEJH0fZz2phwlJnThAl5Oics1QAe8GfSsiwykT9Wj8fWEG1rb2u6x3WD3R9yC7q803 AFHKotMre6L1+M63JiJPZ6qT8KR5GJ/eyfE8Zs/RX2RKeFBzOwaDcYlpQ+ic+tk7b+QQ 06Yw== X-Gm-Message-State: AOJu0YyGosyfoUPqzRofaqflivNEDXiVO3iETlraBbv750t427VInlGC sGeyYUoy7leEjZ+9sQCHFw7ciyalC3ntdR9E2wLFOjq6r0Vyfd5XvfmuaK9kLS8NYIQR8e8Bmil yXs6XrXcelzl7Sn8zJsgPIbzXSTXKTTsiNQ== X-Gm-Gg: AZuq6aIvlMoH0nlxq8crx1OFaJRK7tLL50p1xlup4WLNkvS6nXDltorhjZOGXIH4KfT ZNJHGDc+XYdlXfYcoWTqzTWPlEQkVGngGuobMLOrb0VcqH9gTpm4xx8mYagYDoG8VVN/yb7QWCA UyhjtoqzGZPAtKEm0N7p9SXlgtyQ7hvSUOhcFXm6Xmu6fCY5gDWD9FUJpSgzb0fM46kFbWmTUvc 8X8oHJP+fg3XKNRFjKKyZ8SXgqLo/VxYlGYBtRmAfPrBDc6rL3sn1UXAoMO3uf95WUXxtnL8zVb Y7Cqg29XbTv09NWIAL3Dz/DBpKIc3t7O6syICiNOjlIlb3epQhmqsEFiPMOKshVxlkIxc6Vjmok EYP7vFA== X-Received: by 2002:a05:651c:2110:b0:382:4fcd:66a3 with SMTP id 38308e7fff4ca-385d9e7153fmr8663191fa.12.1769168650298; Fri, 23 Jan 2026 03:44:10 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 23 Jan 2026 12:43:43 +0100 X-Gm-Features: AZwV_QhpzyUs-zQp28Pz0vCdafl23YWL8NbyglG0tb0Zh9oONCZcMMZdJWkMTJ8 Message-ID: Subject: Re: [PHP-DEV] [RFC] Deprecate Fuzzy Type Casts and Allow Stringable in Strict Mode To: Alexandre Daubois Cc: PHP internals list Content-Type: multipart/alternative; boundary="000000000000f2e93206490cacca" From: kjarli@gmail.com (Lynn) --000000000000f2e93206490cacca Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 23, 2026 at 11:51=E2=80=AFAM Alexandre Daubois < alex.daubois+php@gmail.com> wrote: > Hello everyone, > > Before going further with our already under discussion RFC about > nullable casts, Nicolas Grekas and I would like to present this new > RFC about deprecating fuzzy casts, and adding support for Stringable > in string parameters when using strict mode. > > RFC: https://wiki.php.net/rfc/deprecate-fuzzy-casts > > Thanks, > > =E2=80=94 Alexandre Daubois > 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. I'm afraid that deprecating and eventually erroring these casts will break a lot of hard to trace legacy code, where a cast "solved" most problems, or at least did not crash things. I'm talking about values that come from automated import systems, go through dozens of layers of code that haven't been touched since php 5.2 or earlier, and eventually end up in a part where we do a cast. It was also not unthinkable that these casts were used _because_ it truncated the invalid parts, and while we could replace this with a preg_match to extract the number, I don't particularly feel like going through nearly 5k int casts in this codebase and figure out if it should change or not. Does this behavior als affect parameters being passed in a non-strict fashion? Because then I don't see a realistic migration path within the next decade for this application. On the subject of strings, I'm very afraid this will cause hidden issues. The Stringable value isn't always the value I want from an object, and with this change my IDE will no longer give an error that it's the wrong type. I foresee people throwing stringable objects into string parameters and silently causing the wrong values to be used. Especially when the __toString implementation is not within our control this will be a dangerous thing to miss. This will also silently break values being passed if the __toString implementation changes, which is going to be extremely hard to trace back like with `(string) $object`. This change also makes reviewing code more difficult as I have to know the parameter type, variable type, and what the __toString function does in order to find out if it's correct, or another value had to be passed. I feel like these 2 changes will cause big problems, way more than it's worth having them be correct. Perhaps my worries are unjustified? --000000000000f2e93206490cacca Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Fri, Jan 23,= 2026 at 11:51=E2=80=AFAM Alexandre Daubois <alex.daubois+php@gmail.com> wrote:
Hello everyone,

Before going further with our already under discussion RFC about
nullable casts, Nicolas Grekas and I would like to present this new
RFC about deprecating fuzzy casts, and adding support for Stringable
in string parameters when using strict mode.

RFC: https://wiki.php.net/rfc/deprecate-fuzzy-casts

Thanks,

=E2=80=94 Alexandre Daubois


<= div>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 fro= m this RFC if those scenarios would be affected. The first scenario is comm= on with "ZEROFILL" database columns, and the latter is a scenario= I recently found being used to get a valid int from user input if consider= ed number-ish and switch between whole number vs decimal behavior.

I= 'm afraid that deprecating and eventually erroring these casts will bre= ak a lot of hard to trace legacy code, where a cast "solved" most= problems, or at least did not crash things. I'm talking about values t= hat come from automated import systems, go through dozens of layers of code= that haven't been touched since php 5.2 or earlier, and eventually end= up in a part where we do a cast. It was also not unthinkable that these ca= sts were used _because_ it truncated the invalid parts, and while we could = replace this with a preg_match to extract the number, I don't particula= rly feel like going through nearly 5k int casts in this codebase and figure= out if it should change or not.=C2=A0

Does this behavior als affect= parameters being passed in a non-strict fashion? Because then I don't = see a realistic migration path within the next decade for this application.=

On the subject of strings, I'm very afraid th= is will cause=C2=A0hidden=C2=A0issues. The Stringable value isn't alway= s the value I want from an object, and with this change my IDE will no long= er give an error that it's the wrong type. I foresee people throwing st= ringable objects into string parameters and silently causing the wrong valu= es to be used. Especially when the __toString implementation is not within = our control this will be a dangerous thing to miss. This will also silently= break values being passed if the __toString implementation changes, which = is going to be extremely hard to trace back like with `(string) $object`. T= his change also makes reviewing code more difficult as I have to know the p= arameter type, variable type, and what the __toString function does in orde= r to find out if it's correct, or another value had to be passed.
=

I feel like these 2 changes will cause big problems, wa= y more than it's worth having them be correct. Perhaps my worries are u= njustified?
--000000000000f2e93206490cacca--