Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116845 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52656 invoked from network); 7 Jan 2022 09:27:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Jan 2022 09:27:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 334971804E3 for ; Fri, 7 Jan 2022 02:35:30 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f47.google.com (mail-ua1-f47.google.com [209.85.222.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 7 Jan 2022 02:35:29 -0800 (PST) Received: by mail-ua1-f47.google.com with SMTP id p1so9363272uap.9 for ; Fri, 07 Jan 2022 02:35:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1Wi+UAkI8J4ntKv1Y9+SIE2TFDMgFObspv0s659Z0pI=; b=PSgBNXXX9c0AYqmQvJKE1wnoJhYrAwcy1N28HnG1k5/d1Wq/o3bwMNsVgMmr8GXwQ8 u1JLv39ONFCG3xkEv5N8vT/r0bKGVOv1h7k/WPlGrQ1riUJnoCcXYQbV4CXED7sr1Y/W JAdEnX//ixfCa/2wmDQOox2Zg91CCp8uGsepcxZ4kMyMIG7IwDeeGSMrnC0S40ntQYz9 EJvLmCvyMQfBoYY3TTNwCDVKFkZW+iXP3QoaxvTUML70GT1fV29hF9irKiP3+ojtX2LN /p8usdh879Gmkf8YgC7JWR9fRCjj0yhoMkKXACso4EkaACnPEFAYVVFAC2fVPaYBpzTB kpgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1Wi+UAkI8J4ntKv1Y9+SIE2TFDMgFObspv0s659Z0pI=; b=DUhkR0Miyb2ofGHkfqIjpE6PS+D7s2L2sby/y3PoTan0T1Pzj9lpfMN6IKznOSt/Og NpnkK4eyvmc1xGCYJ+d4vUlQrrbipny8rLAhmQYGi5U3GQ/ia+vss6H99RIzP/b3kgCa s9eZYPWx9aVAxdIlEQimz3p7+O2e+/kVEFXQBZmCELjFlfVoq/ww2elAzuAKvDOKUxse YbiDKwKyp6rynmyu37fFWgw8CXsX5I7Dx9Y+1iRRyqhIxStpQfdV1JZEhz546Xupinu8 KSJMg24b9ABcgkTYgm6EGxD46B5Tc/GYQVkK33aiAC2KS9H8LP5xhAnYzkiVxxjo63/x TSqw== X-Gm-Message-State: AOAM531M9enDcsziNBMCoVbIi0qir8HT2rLnmsABpwtNFU5pfds0nb8B dGPl9Iv+BuT3hvfIMax4+eRX4J0xQSPOUeA0Q/o= X-Google-Smtp-Source: ABdhPJwcbqbpn7vL9JD/cFprec7FmF72utPRGBKE2/s5dEKWupLgNyQBLR3kuzT4oMfKfjNXGyv2SkJQb/KdmlHA6NU= X-Received: by 2002:ab0:4d5a:: with SMTP id k26mr13060463uag.122.1641551729137; Fri, 07 Jan 2022 02:35:29 -0800 (PST) MIME-Version: 1.0 References: <3BC1462F-BC9D-43AF-B4C9-8D988067A5B6@gmail.com> In-Reply-To: <3BC1462F-BC9D-43AF-B4C9-8D988067A5B6@gmail.com> Date: Fri, 7 Jan 2022 11:35:18 +0100 Message-ID: To: Rowan Tommins Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000b224cf05d4fb8bf8" Subject: Re: [PHP-DEV] RFC: Stop to automatically cast numeric-string to int when using them as array-key From: mr.vincent.langlet@gmail.com (Vincent Langlet) --000000000000b224cf05d4fb8bf8 Content-Type: text/plain; charset="UTF-8" > On 6 January 2022 07:29:58 GMT, James Titcumb wrote: > >Just thinking out loud, being able to identify an array type might be a > way > >forward here (using "syntax" already in use by static analysis tools in > >docblocks, for familiarity), e.g. > > > >private array $property; > > > >This might "turn off" the automatic type juggling behaviour, for example. > >If the existing strict_types=1 mode is on, this might fail: > > > >$this->property[3] = "hi"; > > > >If strict_types=0 or not declared, the key would be cast to a string. > > > Yes, something similar occurred to me earlier, and I honestly think that > some new types like this are the only way this can practically be solved. > > So a solution, which doesn't require generics, would be to introduce something new like a `dict` as a way to create an `array`. `{}` could be used instead of `[]`. $dict = {'1' => '1', 'key' => 'value'}; \is_array($dict); // true --000000000000b224cf05d4fb8bf8--