Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129936 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 B69661A00BC for ; Tue, 27 Jan 2026 08:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769503072; bh=p57AihbDGRW/1djORwC2BhVmi6CaGz6x4hWWu/JjvsM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=fAvAyI/MXRUUVlwWESEJbcR/pqpM7Cy04HYe2OTZmPUJGfXjNojbQ4fYEHwxsR0+z DRilfrFQ921eSE7zVLiXIJ7csPrPmy50XzGWEPSdcxGU6UXh/vpZF7ATVvzpX1wOIf wbptsUMMJt1f1JsCoh5XIJ1hjGji5bZstACHIuvGyp2+3UXX/03ulI1BdzKVS9n6Jo PlNFlVv3hVW2EM8ItqCydbhIM2zDqhf61bbToQ3GpjX9WSt7i2Hl46xnOkoZLCLodT sI5K1Vh2qXVMff/+TTpJOzb2d8Ebn3jolnfsshZTonRsy0zfa3uy7dAf1Rje7ClDTI 0lB8ZE0ALg8Ag== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 49A00180050 for ; Tue, 27 Jan 2026 08:37:51 +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_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (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 ; Tue, 27 Jan 2026 08:37:51 +0000 (UTC) Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-4042cd2a336so1342960fac.0 for ; Tue, 27 Jan 2026 00:37:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769503065; cv=none; d=google.com; s=arc-20240605; b=ToK86zkcQ4MiCTERg+SI5phjgPgoHcTtIMqaBCx5uYTnOaujrP0d6F2a84dVWe24l9 kgnPhFoTwg2p+Og8kwN9ULi8G1L4R+HLOaXxmOrnEXeQMhaOJHg6sKm/jH9Wr4zX2Wmw lEDHr/rNWHi/KlhR71bbxPIR2EJUaQiC9knAjjd1J/jx8glOE3/uC37KCc7PXr6sGEG5 pXL1f4/t1t6LhCuO671BmgSgo5pcyUt4Fh30kJCpPSFz90TcjeWxPg2tEDzw5Aaf3s0/ 6COYSurJThKk+sd1l33tKUNmBGzT4GqJBCgukxCKx9Eolea72ap3Mqk/UyqVkUGgsVqx cexQ== 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=lTw0k7LTIXrMe/yeIHueBKv+sJPE83sIjtFc9pADWQ0=; fh=0un1hNQkIQnxRVmSrptHpYePKulyS9pFxhu85Wb7djM=; b=bOpxfkMdbkDYqBRkRJq4blV2xfkoIZ+chQsdyMpdD8g8VrGP1T2kOH//B/ULdLIFwG Su2coMD0paeBzCZQp4JUW7C35WWNOSNC6BIQo/k/IUsC6m1bJQJJvhzZMmh2BYwjs94Z isiyt57GEPjMJTXbYK/AHPpLIy8NDoQ1XR1tC/vCHhV+bz3uJEDzWOBebWR8QUcdrCSA Q8aOD/TQia3e1EEDCjGPfeNVk1ZknpK31RcnRkxZ+iESt8Z2Ip29CT+z5wZfV9lTFxSE nogsc9q9dhcpEY+yKdz7aWs7QOW+p70Dc3LZPh6fF/tTetyQ+yKyDtnHBVEhpwCtH68S qq8Q==; 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=1769503065; x=1770107865; 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=lTw0k7LTIXrMe/yeIHueBKv+sJPE83sIjtFc9pADWQ0=; b=fb4yGV3rT3ywzMVeEGr4oPZW844LQ3ItoaziDFh9VxIpXnGDG/cB0Kjh850WhpnQqR TeiDIrsii1CHpxg9IRX8qrx4rYIJSbvq9LtPAaqRhvVUeahpN8GS1woWur8Z2EYz6Q9n U/6pI5OZpSE3ta8Ga1wGJv0k/duW95alzzGyfb8nxREXRhw9vIz0MdOc1hxuZo34jm58 J/IOfhrK9Wfh5JeLJhiQJptYW9LPplHkS8AB9ID+eneXe9vWWmPDJy1gj5nnZpmcPYc1 XYiOfMy4tWDIlGMkXHvkyOkDrTyCtd3mRHlTI/hgG8qvRRG8P9FC8Cetku/Q+CL01ywM oWCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769503065; x=1770107865; 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=lTw0k7LTIXrMe/yeIHueBKv+sJPE83sIjtFc9pADWQ0=; b=QDli8tjxsrJ8h5k7shCAH4LKi4O+YzpdtksEIvElvGB5IszM9aN+6WPGt5sWzKaLCT uBrvHp+tLlzXq/mvNX9nRHTJ6jadmdDYXdXLV5TjuRaWtr6srspT5EfTWXdwq1Yc0ZWA PE6KNYKVfkMmE1nU6qclEbCcM3OsezQ1f5grJPpsIxlW5R/uRMLlL6V/mx/fAtP5nWi7 6GTH9oy7sjkSmiLlNWOMUOfoEShCyxYmAfqptpjFyebjL09rUcb+yrWJVEcbF+C56mrH AHgvPthLyqSWuvvoyk+gPxeyZXImtXH7e9DR4RBcEl6nNh1VWUjggwPUFzs/BBDdUAuL 4X5A== X-Gm-Message-State: AOJu0Yy7uOb1owtiSL3EPHp/xX1gKjBbEl3qF2bexbBRVFWxTZM/7lMP m6ezHxvXk52KG96Dm0tQHx2mg73fkvHtgdmv9jaJ8X+yJ7YnImURdHROkdFIKuR6HDYXUaUNpfG mjVZ/yQJMc39qZepoWC64EOcdwCX8pOEBjVrh X-Gm-Gg: AZuq6aKsHcP1ftV1lcuIUTh8ThLQMIfWuTfuJLZDI3ijRQUxFwHpApK7iF+zEEJvxsF sPAZwB7y8DZb2oMcGqBxlMBfLfW1xcK6OO61zXYteI3bOICI1c0Kb9sijkGnOrqHxAGN97liplO JTXGo9e1L9KpaWtTVjNwaqwLzfnxW7Fpm9yKRJlGF3Nd7hGpNn1bO1EXpJxCkUUwLN1kaWb3dpx 9ufHmgMOao52jQcOt9hmfB5UgsjhPtopanPBzcKIqC2ml+tAAqUQmUjhgWpL5VHPHuuIQA1pFQS pzCmW3OAmIvmyRooqPjBie4F+a5fmQ== X-Received: by 2002:a05:6820:228c:b0:659:9a49:8f1f with SMTP id 006d021491bc7-662f21284d1mr623156eaf.48.1769503065270; Tue, 27 Jan 2026 00:37:45 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <31563ed1-ac44-47ef-9fca-3ebbfc567ba5@sandfox.me> <8A9F3BDD-1C65-4E6F-BD65-C43F017D52E2@rwec.co.uk> <85c420f7-38ba-46f6-b434-addb733d023d@rwec.co.uk> In-Reply-To: <85c420f7-38ba-46f6-b434-addb733d023d@rwec.co.uk> Date: Tue, 27 Jan 2026 15:37:34 +0700 X-Gm-Features: AZwV_Qiclr08BFSRaiZSI6CZ-SDz4dtIfCv8b25_A0HT8JYU8rmhHvwl-t8fQZI Message-ID: Subject: Re: [PHP-DEV] [RFC] Deprecate Fuzzy Type Casts and Allow Stringable in Strict Mode To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: pierre.php@gmail.com (Pierre Joye) Hello Rowan, Alexandre, and all :) On Tue, Jan 27, 2026 at 1:45=E2=80=AFAM Rowan Tommins [IMSoP] wrote: > > On 26/01/2026 08:46, Alexandre Daubois wrote: > > Le ven. 23 janv. 2026 =C3=A0 18:46, Rowan Tommins [IMSoP] > a =C3=A9crit : > > I don't think we should repurpose widely-used syntax for a different use = case. If we want new functionality, with new semantics, we should add new s= yntax for that. > > The rules/semantics proposed in this RFC are not new. > > > Hi Alexandre, > > In my mind, cast / type conversion behaviour can be described in two part= s: > > > The first part is the rules of which input values count as "valid". > > In the case of string to integer casts: can it include a leading '+'? lea= ding space? trailing space? leading zeroes? trailing zero decimal part? tra= iling non-zero decimal part? other trailing characters? > > PHP has a bunch of different versions of these rules used in different co= ntexts, and it would certainly be nice to make them all more consistent. I would even say it is almost a must at this stage. The introduction of declare strict_type somehow helps a bit in the context where it is used, but overall, the cognitive weight of dealing with the casts/conversions happens is beyond any level that could make sense, no matter how I look at it. And to anyone working in the engine, runtime parts can triple that cognitive weight to carry. > In the case of parameter types and return types, this is to throw a TypeE= rror. But that's not the only reasonable option - you might just a boolean = (true=3Dvalid, false=3Dinvalid); or you might want to substitute a default = value. > > In the case of the "(int)" syntax, I would argue that the established beh= aviour is that an invalid value *returns a default value* - for an integer,= zero. The implicit cast is the only one I would not change, if one chooses it, we can assume the use case is clear and the person knows what's happening. The classic example you gave with a _GET expected to be an int is one of them. And if not, well, we can't prevent anyone from shooting themselves in the knee(s). It has been mentioned in various recent RFCs that one or another operations, conversions, casts, syntax is related to another similar but should be separated RFCs. I think for a few cases, it is the case. But operations like the ones discussed here, or anything related to automatic casts/conversions, may end in a way better state if they are handled once and together. We have different paradigms in the language, and communities adopt different ones. A growing part of our users, do explicitly decide to go full typed, going beyond what php does, to avoid all these pitfalls. I do think that the amount of projects going this way will increase and that's something PHP should not ignore. Maybe it is a good time to have an actual mind-friendly, I would say, sane, typing mode across the board in an actual strong type mode for the/a next php major version? Best, --=20 Pierre