Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129902 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 D06BC1A00BC for ; Fri, 23 Jan 2026 17:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769187922; bh=WJqqSCFmanfcjOU7GfyFrNIOYOLuAvKg5GKxMivTDrg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=hAV0hQTHaay5+ZBXNEralBTp3I5eC0Mz0Kr72EI012SJ+XRRANH2ZyoJZAU0Fyn6w Z/HmzjLKRkWtFQQd8vqVE/UwJYyrxcR5pa+foM6DlqH1jjUWUclxctDH4Gse5yTKIN u0dRC2TZYeiVlapXtL3U82by4PFCyvsMGQVO0+Jf4S6DgboYlyOHL0IIDLNxlJvT2p 7MFAkj7XxzqFVKFXzwyGB+yAT/H8J1YWDwxhaz2xxKFYs+NYPeFy79dy9ZcgY2gNga U1sAmsp7pPQIJprf2IYS1/Uvtl2OEnjliiQxOZpgV/s/Od1vQUkFfAIY17hxaHdjWF bX8sNUWHRHT0A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 925071806B4 for ; Fri, 23 Jan 2026 17:05:21 +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=0.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,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-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 17:05:21 +0000 (UTC) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-6582e8831aeso3793639a12.1 for ; Fri, 23 Jan 2026 09:05:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769187915; cv=none; d=google.com; s=arc-20240605; b=gZbpG3apZmwt+qRrgEvlhmY3NBvavkpXGCSKwLkat5iM5cKHZl5PUL+IcUJxiRY/gu zmHXi+5RlRJw1hRxN2RKUH+ZXp20LrgDCpt+vunHeps1yyEI61QeecFsuMx2anz7/eOM TeYmgSHC2yRKn9niF4M5WnQyESmX14eLqdDlvxuEXSNae0wO9tOK0e+X+XnOfYYRB+PI JL5RDoS3W0NTwJJPt6AO7c1YSY4xoXJtDjx6dy4xJ6MaXo6T8t0ywYTpeosvsrIgXnXB VabtR/me/ckrzWE4H0kiU0LvDdAdL9IytFG+xCeTXNnZaKJVHd/ILmZ8H758aQO9RtJk wufA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=WJqqSCFmanfcjOU7GfyFrNIOYOLuAvKg5GKxMivTDrg=; fh=qs8Tjj25iZaxRiWpSFFOHEqeGRtVbi1bbCNxxihmjTg=; b=KZze0T/lo3AbdOzf5EddlCkcY1PBNs//sgfNWbcgtjsSuMeM/Uz1miFF+gyB9s0kub Hm8fsXjSnWVWqVRE+g+L5lH6Jl82jSauSsanApUU7XjMXCM774dGeW3hhFFQhZsS0rGD mfIVZmcJyvrhWrdCMawaCggiT9Et940fNSpMkESxyAQaK3HPdcfyXwkjBFqW701ugEt4 xGoncPPsJhbNqWulrk+q+ZRY1h/cpa6vY8SMnK27kcTXbeBSGkyivZKSzLg7AP4UlwTr 1LxdewfyAMKb7dECAtW4j8QAzwsQuaW/fgBFISMCogUc6LAbcQ4ra7h8LDbi43/3nOY5 eFJg==; 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=1769187915; x=1769792715; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WJqqSCFmanfcjOU7GfyFrNIOYOLuAvKg5GKxMivTDrg=; b=lmWLYvwjmVDDUn3oJn7Zi1xa6+rNWh37Ac7dCBFWNoTIr9PGdbgsy4ElFoicHGmdFD 1xDnkz+B9capV2QNLBeotxY0qKZgeb6NxjfuRvpZgkdfbZytIV0JgEZ954L5sFBiGbpd csUu+w9j0H5WeosfZMlkjhJLix1UroAjHlSNpd6YBGXZb2nvVV2N3oK3kRQBZfFEUYQU hvyDPabzbP2u6Wc0qASCOqGKwzONDvcE45eBTow2MQ3wiFiRh/Q5hlIGLl4A5s+3cf5N Q3qjo5aHKBx2/BVZzB7so77u3D8IzTWY2GUOD/ttZebRXnXapNeFHlVbu51ZyrO2+KAe QLbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769187915; x=1769792715; h=content-transfer-encoding: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=WJqqSCFmanfcjOU7GfyFrNIOYOLuAvKg5GKxMivTDrg=; b=HnpglHd3TXfDNJ6Z41solLa14m8Udw0dAMvpMYyztmJ8eEzk/b/fQ0t/ef1/UOPCcG MI2itAgLgZf8NhC0mGn7c9+vvmk7JQf9aqeDQpqvZMC5Qh9ql8zSLm91rV1pvMaD9Fd/ dKYbixKdJTCXHTaFwnYoI7/MtgWshtPiW9ylxZBNGJOcEPNwdPFW5+KQF7OHNp3YHPtu ME8Rn7iXoU0Z190SORyxgu6UfSTxkMG9aJw+SURYUe8uQX1j68zeKcwndWHZT+OtTg+I zwCUUrqYCVu5lCpL5DicMNu05OM37SHcOLQAJzLdRZr5NltDGGXnlOTVtVPXUkCo5aWl 6Yag== X-Gm-Message-State: AOJu0Yz7dWiShjRK1ufmjMyy9l4TrDPO8fkrkd4Kkgq1X50cxPic1b7Z nTv0gKs08ql2ArKZWJQ3QlkO+z0+VA8RCZtZiO67Z5ittTBowv8O0OId68rOaOPOzpP/uvhFx9x JLUie8aCiRx8A1zQzjXsyb4ocGlJqUQA5ID5s X-Gm-Gg: AZuq6aIooQ0VoDW7MacQZ9ttTzG6/Av7ysaQXxuW4dKlEr5MgPVrCw4sZvXcw74+gK0 UDT3OVr8NVnq31Y6EjT4iGhXa4SxIXvlsWGP3sw+I0JjY3ORZIjecUImlHhs+t0WbY1XZwTWzC4 GJTGetK3Zpee/ZcYF5KpkJy3BkV90bZzzk48s/IIHnQ7pW+Cld0HSfomH9+4iKAVx3LCbrxA961 ySlaqtbFji8szlN2+Orn/dzfaYwPtmZRJ/GkH+HuAwSMnnDuGIItyi2Zem0oYBLhJmJ4BbuKU98 ewIBGV3J2QU85QDVzDEIj45w X-Received: by 2002:a05:6402:3590:b0:658:3652:a0d1 with SMTP id 4fb4d7f45d1cf-658487b1a0bmr2308074a12.23.1769187914753; Fri, 23 Jan 2026 09:05:14 -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 18:05:02 +0100 X-Gm-Features: AZwV_QgsMqdZzTMD4ES8fwMkNIoz-QnfhEGB5_0GzPU0E0g2IowLqaYGvKiOkwM Message-ID: Subject: Re: [PHP-DEV] [RFC] Deprecate Fuzzy Type Casts and Allow Stringable in Strict Mode To: "Rowan Tommins [IMSoP]" Cc: PHP internals list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: alex.daubois+php@gmail.com (Alexandre Daubois) Hi Rowan, Le ven. 23 janv. 2026 =C3=A0 15:55, Rowan Tommins [IMSoP] a =C3=A9crit : > I am strongly against the Stringable part of this. > > It would mean users who have explicitly asked for no type coercion would = get silent type coercion. It would mean that a string parameter in mode 1 w= ould still reject an integer 42, but would *accept* new BcMath\Number(42). = I can't see how that makes sense. Stringable is an explicit contract that an object can be safely converted to a string. If an application breaks because of such a cast, this means the implementation of the `__toString()` method is buggy and does not respect the contract. Currently, non-strict and strict modes differ on Stringable handling, and I'm not aware of this non-strict behavior causing bugs in production applications - though I'd genuinely welcome counterexamples if you're aware of any. Regarding your BcMath\Number example: I see the distinction you're making, but I think the key difference is the *explicit opt-in*. An integer doesn't choose to be convertible to string - that's a built-in coercion. A class implementing Stringable explicitly declares "I have a canonical string representation". The parallel would be: strict mode rejects int -> string coercion (implicit), but should accept Stringable -> string because it's an explicit contract, much like it accepts objects implementing ArrayAccess for array operations in certain contexts. As mentioned by Larry, Stringable changes would deserve another RFC. We're considering creating a second RFC just for the Stringable part, so I propose to continue this discussion in the coming thread if that suits you, so we can keep things organised. > As I've said elsewhere, I think the right approach to this is to design a= new set of cast operations, with a more extendable syntax. They can have m= ore clearly defined rules for "int-like string" etc, and different modes/va= riants for use cases like "error on failure" vs "default value on failure". Our goal is to make things more consistent and simple, and I'm afraid creating a new set of casts would just overcomplexify things. The fundamental problem would be shifted to somewhere else, not solved. Adding new cast operators would create a third set of rules alongside type coercion and type declarations. Aligning existing casts with the type checking semantics that have been standard since PHP 7.0 seems simpler and more maintainable long-term. =E2=80=94 Alexandre Daubois