Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116739 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 48747 invoked from network); 29 Dec 2021 16:37:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Dec 2021 16:37:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9388A180545 for ; Wed, 29 Dec 2021 09:43:18 -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-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) (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 09:43:18 -0800 (PST) Received: by mail-ua1-f52.google.com with SMTP id o63so38561385uao.5 for ; Wed, 29 Dec 2021 09:43:18 -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; bh=ovSXv5h67KgVcC+lvMZMT0ABDsHpJKKOX11LFv6RfU4=; b=kVc7ZDRvRYQ3o1J8iCHTQcyGwVnZOmMsHhQIYET8+08hufXDR9Kxf3q8ofsmJYQhpA 02GovUsGkI+w8HefGR03cpDOLEI+Zrnq9SgHTNJtKZWKPz7m3eSNou+IgnqBwKj0yvOD RN89yDpQcbNJFBTOq+q5tshMFB9g+4qSRMuOzbcqrUcru6ozDFrIbqGpUSoGG4cEU7/h CA0LX6WXMkL9eZNKfjdjncIfqDUCpqgYKKrXlAnSfLUQRoGkSWdBSWRCPX4x0pwJRbBx WikvvpSGw39VCZuguBp1Frxrj6UgMyEQ4M19Jlbre/eNGtqU6ZL054BOybrlmx408A/s Lq6w== 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; bh=ovSXv5h67KgVcC+lvMZMT0ABDsHpJKKOX11LFv6RfU4=; b=mLEDkM+7m3W1/39H6FrouQUhweaxNhlQvAqp29BCmO7xLBUQjqjs0z25Tvcm2xdU/X jUwwt0o5wWfFzvCHvBqhrg37zdsnGghyI6aDR3vStO/lSDFln1CgK4KVX0CbbpcEQGdp 30/jAARgWMI30TO/lTUtymwsWqaRihHhRrrCWCcT53IyEVlIvb56ST4qNQCLq+1JrBTL 5JjGMpc/lGjR7cJKjf5t73epnjQWfgsj8Hj4Yqw/bvr6wCRtajeC7vz2iMJ1kdHu6PrF NdtCIiwwC1TQrGrGGGNdZvU5bwah8eYzDrkk5QlcaRDWiZM6mpkmpsKSBcF7nwRHNuxg JfCA== X-Gm-Message-State: AOAM5304Xpw6/0SkxF4e9bOAVYCoEPjgzQ9GxyqPDBj4C/1mnAy/1lTL IwDILqkeozPeSd3V4eZFhVTikcBJblHzHObd6X0zgAapNhc= X-Google-Smtp-Source: ABdhPJzk4u0X19zRExt/A6oCHnk8HMc4ZKT4fkSoyl0KQMKBCd2SWjwF02y5leKWBbt+i3Qy/XOCMYMMeEVkOh/3jp0= X-Received: by 2002:a05:6102:e8f:: with SMTP id l15mr7764828vst.30.1640799796986; Wed, 29 Dec 2021 09:43:16 -0800 (PST) MIME-Version: 1.0 References: <5ca1c05f-273e-d1f9-5be0-32eee68a6fe1@gmail.com> In-Reply-To: <5ca1c05f-273e-d1f9-5be0-32eee68a6fe1@gmail.com> Date: Wed, 29 Dec 2021 18:43:05 +0100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000000c0b1205d44c79e5" 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) --0000000000000c0b1205d44c79e5 Content-Type: text/plain; charset="UTF-8" > On 29/12/2021 16:58, Lynn wrote: > > While I'd love for this inconsistency to go away, I also know that this > is > > most likely such a big change that it causes months of work and broken > code > > because it relies on this behavior. It wouldn't surprise me if this > > singular change would cause more work than all previous BC breaks > combined. > > > I was about to say the same thing - this is one of those ingrained > behaviours that is very hard to analyse use of without running the code, > so only someone with an extraordinarily good test suite would detect > that their code was affected before it went live. > > I encounter this issue with an array of zipcode as key, and let's say some delay as int: ['00001' => 2, '00002' => 5, ..., '10000' => 4, ... ]; If I want all the zipcode with a delay superior to 3, combining array_keys and array_filter will give me an array of string and int, instead of an array of only string ; like I would have expected. Maybe a way to reduce the BC-break would be to say that - The type of the key won't change anymore i.e. array_search(0, ['10' => 0]) will be '10' and not 10. - $array[10] will return $array[10] ?? $array['10'] - $array['10'] will return $array['10'] ?? $array[10] This would avoid the issue with $products[$_GET['id']] VS $products[(int)$_GET['id']] and still be a first step in the improvement of this situation. --0000000000000c0b1205d44c79e5--