Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111593 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 4194 invoked from network); 17 Aug 2020 18:29:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Aug 2020 18:29:24 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DD4B9180540 for ; Mon, 17 Aug 2020 10:30:21 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from coral.ash.relay.mailchannels.net (coral.ash.relay.mailchannels.net [23.83.222.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 17 Aug 2020 10:30:19 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|josh@joshbruce.dev Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A5625361EEF; Mon, 17 Aug 2020 17:30:16 +0000 (UTC) Received: from pdx1-sub0-mail-a87.g.dreamhost.com (100-96-8-55.trex.outbound.svc.cluster.local [100.96.8.55]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 8AD90361FDA; Mon, 17 Aug 2020 17:30:13 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|josh@joshbruce.dev Received: from pdx1-sub0-mail-a87.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.8); Mon, 17 Aug 2020 17:30:16 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|josh@joshbruce.dev X-MailChannels-Auth-Id: dreamhost X-Cellar-Stop: 5503ad73535baa2b_1597685416024_2365480128 X-MC-Loop-Signature: 1597685416023:2519911506 X-MC-Ingress-Time: 1597685416023 Received: from pdx1-sub0-mail-a87.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a87.g.dreamhost.com (Postfix) with ESMTP id 3E62880FD9; Mon, 17 Aug 2020 10:30:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=joshbruce.dev; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s= joshbruce.dev; bh=+wRaxx1qdZ3E7xi7GXmQqdKVYeo=; b=eCzpos07fF28LO ABPNqSIRWOlCi0NrYqxcJH+/EyDvjO4ebubtmD+L4QF3STAXR+ipkuWbiIhgNYZe yUEqzkFX8BN7W3EAar4a0bNPGU8gL9YbWm67cpImFaLhMpPMcMowMNOMO8uWvu3r vGm1JTmNFPFbmPKmLvU5HOFPYaE4E= Received: from joshs-mbp.lan (21.140.29.136.in-addr.arpa [136.29.140.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: josh@joshbruce.dev) by pdx1-sub0-mail-a87.g.dreamhost.com (Postfix) with ESMTPSA id 8512D80FDA; Mon, 17 Aug 2020 10:30:12 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) X-DH-BACKEND: pdx1-sub0-mail-a87 In-Reply-To: Date: Mon, 17 Aug 2020 12:30:10 -0500 Cc: Internals Content-Transfer-Encoding: quoted-printable Message-ID: <419877AD-FCC8-470C-8296-6A5FD975584D@joshbruce.dev> References: <747c6d622bbadebf32a8b7dec541c333eeb8776a6ab7ff0784a0b75c8895a646@mahalux.com> To: Rowan Tommins X-Mailer: Apple Mail (2.3608.120.23.2.1) X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 49 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduiedruddtgedgvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucgoufhushhpvggtthffohhmrghinhculdegledmnecujfgurheptggguffhjgffgffkfhfvofesthhqmhdthhdtjeenucfhrhhomheplfhoshhhuceurhhutggvuceojhhoshhhsehjohhshhgsrhhutggvrdguvghvqeenucggtffrrghtthgvrhhnpeduudduvedtkefftedvfefghfekjeeujeehleehueevteeutddugffhjeethfeggfenucffohhmrghinhepfehvgehlrdhorhhgpdhphhhprdhnvghtnecukfhppedufeeirddvledrudegtddrvddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhppdhhvghlohepjhhoshhhshdqmhgsphdrlhgrnhdpihhnvghtpedufeeirddvledrudegtddrvddupdhrvghtuhhrnhdqphgrthhhpeflohhshhcuuehruhgtvgcuoehjohhshhesjhhoshhhsghruhgtvgdruggvvheqpdhmrghilhhfrhhomhepjhhoshhhsehjohhshhgsrhhutggvrdguvghvpdhnrhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght Subject: Re: [PHP-DEV] [Concept] Don't cast keys in array to int From: josh@joshbruce.dev (Josh Bruce) Thanks Rowan. I can appreciate that rationale. Also let=E2=80=99s me in on why we might want to have an indexed array = that is not necessarily sequential - but are integers. Thanks again. Cheers, Josh > On Aug 17, 2020, at 4:17 AM, Rowan Tommins = wrote: >=20 > On Mon, 17 Aug 2020 at 05:19, Michael Vo=C5=99=C3=AD=C5=A1ek - =C4=8CVUT= FEL < > vorismi3@fel.cvut.cz> wrote: >=20 >> This seems almost as a bug, strict types should apply also for array = key >> which is currently not the case. >>=20 >> https://3v4l.org/epv5s >=20 >=20 >=20 > No, it really shouldn't. In hindsight, "strict_types" was a bad name = for > that directive; it is not a catch-all "make the type system stricter" = flag, > it changes one specific piece of logic: when passing a scalar value to = a > function parameter annotated with a different scalar type, should the = value > be automatically cast, or require a manual cast. There is no function = call > in that code example, so the directive has no effect. >=20 >=20 > The reason PHP treats $foo[42] as referring to the same element as > $foo['42'] is to support this straight-forwardly useful code: >=20 > $options =3D [ > 1 =3D> 'apple', > 2 =3D> 'orange', > 3 =3D> 'banana', > 4 =3D> 'caramel', > ]; > $selected_option =3D $options[ $_GET['id'] ] ?? 'vanilla'; >=20 >=20 > Casting between arrays and objects is a whole separate issue, and = changed > in PHP 7.2; the RFC explains the issues quite well: > https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts >=20 >=20 > Regards. > --=20 > Rowan Tommins > [IMSoP]