Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116735 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 38686 invoked from network); 29 Dec 2021 14:36:21 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Dec 2021 14:36:21 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3F22B1804E3 for ; Wed, 29 Dec 2021 07:42:04 -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.1 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, HTML_OBFUSCATE_05_10,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-f43.google.com (mail-ua1-f43.google.com [209.85.222.43]) (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 ; Wed, 29 Dec 2021 07:42:02 -0800 (PST) Received: by mail-ua1-f43.google.com with SMTP id o1so37997288uap.4 for ; Wed, 29 Dec 2021 07:42:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=g67iZ9B/Q0a8SSRcXUWe9YTjBuGbjIwo5TlcMONPApI=; b=oDVso2NdulKisB1wrmXEPtn2i+9FMiwo9AFtpBjxcAZ64vvETbFE+O0KSMTwKJrq57 f0uX9n7zDUZ72cG5D+LhaX83kMQhNfOj+4BQFzD/81ontauxxm6A4BZZJmTSgud5RHG4 G7Ob19FAdsdqmNmPxW0F5zL5ricyF5i6N2TEZLfRneDR5x8Z/xa8hzqFpfuq6ai/cTDV g3I1MZKpY7jHYS7eJmTxu4VkGocXz295ezQHoEQzEIqAAm9D091kII7W+DTlI7POsv/j oQYJTzDX5DNpSPhCE2APNHl9DX2FMUw0i/L2P2JRN+gaamQP2fJFWHDi6KsN/9H0aHVi 5Y7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=g67iZ9B/Q0a8SSRcXUWe9YTjBuGbjIwo5TlcMONPApI=; b=BU0atjirxRQ3H2ByCiqy5z5ev9DIYBYNBmRrL0LXfNs0A96lidmu/quOVnyjpfUk8T CKRIH57BkvW2Wy34/hG9QiyOvMUyHaXiICnxOOWbzVHThmVACofc7F050OL0BUbhvDIS 84POn5eSDqQUg7ZIPvXdcVq9YnSMhaoIzyKqjKjAhEdOOFICncE76utvsxFYlXLF9NPV n52fHek6T7PpII4a0vMY8q2mzqhOLSQ14wdYhBZ4BuNPucSN24L0UHB/zgIom04wIKaY Pm+RnJplVIJz7zXtmWhr54vr4K3onJu7pesd1FsKLzdEM7bqRBb52symjpAamgilIIJh 91vw== X-Gm-Message-State: AOAM530vLFCaHHmiGeJjAfNF/q9Kl/zO5oLgrGuyer9GFlHjeLQUtBxT zhjMEcHKBlkj4k699g/em2JiMvpqPDZ/3OqSXoW8woi8X3A= X-Google-Smtp-Source: ABdhPJzad3UxsmnwBFHeI+HwNANGlPjmdfEX7gXwCwqTudbQGDJ4H/0X//OvGY2EW2EIV2+ioi5wVcydwOnR8AQOllU= X-Received: by 2002:ab0:15a1:: with SMTP id i30mr8572371uae.122.1640792522078; Wed, 29 Dec 2021 07:42:02 -0800 (PST) MIME-Version: 1.0 Date: Wed, 29 Dec 2021 16:41:51 +0100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000006dbc0005d44ac758" Subject: RFC: Stop to automatically cast numeric-string to int when using them as array-key From: misterdeviling@gmail.com (Vincent Langlet) --0000000000006dbc0005d44ac758 Content-Type: text/plain; charset="UTF-8" Hi, I recently discovered that an array was automatically casting numeric-string keys to int if it was possible. For instance, the following array: $a = ['01' => '01', '10' => '10']; Is not an array with the key '01' and '10' but instead consider the second key as an int. This has some implications like the fact that - array_flip(array_flip($a)) !== $a - array_search('10', $a) is an int when array_search('01', $a) is still a string. Someone using strict types and passing the result to a function expecting a string could end with an unexpected crash. I've created an issue about this https://github.com/php/php-src/issues/7845 but it was recommended to me to send a mail to this mailing list instead. I don't think this behavior should be considered as "normal" and would like to propose to change this for PHP 9, as it's a BC-break. To me it can and be considered as a follow-up of https://wiki.php.net/rfc/string_to_number_comparison and ttps://wiki.php.net/rfc/saner-numeric-strings . This is still a "concept" since I never code with C and know nothing about the PHP implementation and if this change would be possible. Any help is welcome then. Thanks --0000000000006dbc0005d44ac758--