Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127528 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 C2AC71A00BC for ; Mon, 2 Jun 2025 08:21:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748852336; bh=/FpqasdoYWJzkGB5G8YaoRdbdXNVFeOcBROtVko/eJ8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=n2DZeiVVnu5qSrxlqJgWrdV+C6gQ1WjyuW7lDlTPMmrwiDRB+ZnS6Jsvakql47B1T 8NRrmUAlh8KE6bXm//0BDVawetxxogAvoq8Y92TVdpqO+HfR1FihyurYk0qk4vSfUs 7+2g0RTeWOHQPko5ABa9BYN8r3MybCI5JDxsWpZJW83EFv3NvLxA36NK8By/XDhvsT 9bRTA7V3vfa999sihvmuvlo3sUHC/LyP5x+ZYGuYY9RaOz7dOm+PCzakiY3Lu4aCFJ ukvnmzGr/g8wfCjECmjqlswpgCN5ijJhfA/+pmcaneZD5Ma7kHTkUJB+oA+ICbpwbx ZwI6dQgJ95A6w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 47D701801D4 for ; Mon, 2 Jun 2025 08:18:56 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.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 ; Mon, 2 Jun 2025 08:18:55 +0000 (UTC) Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-604f26055c6so9884344a12.1 for ; Mon, 02 Jun 2025 01:21:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748852459; x=1749457259; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YSYqSiDFpiNzpFFXUBxLKVncYA6puvkZJB4NjzC6vcY=; b=Hu9S0sHM9XeRh//q/roNzC/Vm3Shqy8r2zpCedpGFTdhlNtdF4QqMX6xwj+PtFZ4m8 B7To5blPcTAFRcKdykrKTPck++j2BEwsmWnLBOFd6xWFU3jV7glKb5AfWNIwttg9qEd1 L0+29g7cn7IOluwWcCparElmVNr/W2zmQj0O6FChwHNuQTpHCZHyJWwP9BBZ3HMETll8 zmB8F03h3qXYSIr8ALpBk1JHJbeM1yOev/9C+6E6WFaPuioFXvAR/MBYOuKdVp7C7uiR iiuV7uqAz7RUfkkWx1isyHB52c2Hab5u9ZYb9myAME49O/EQfNDZuRD9h6IG2yX0uw0Z KS3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748852459; x=1749457259; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YSYqSiDFpiNzpFFXUBxLKVncYA6puvkZJB4NjzC6vcY=; b=jHLwBWsbEmEzy/J1Y39Ufv6lzYrYD2dk/d5GRdYPS0jfwZaESxDrNReQyUa4GJdjg+ OvumZ/+M3KLqECpkD8m33o7yRFpRUS0AzYiEjlu9FQj6iSY0pSmRyjp8gsjWBbuUXK33 o9PcvANEHz+Ov3gh+6SfMiLJMyuDZtuu+O/alg6Vrayvif6xk/3+f6yTDUBtK1g+OFei 0QyzitgaUDWKe8SyRHVyhezdrlkuIZYCn7ddMzHbQ+HSUeGI+89sUiaeQlv0JmzTOBPw 332DaPQAGnfu4Z3Y4rKYAAftngDqemh4cxWwC5/5VdGOlEtQhyQ0npxW19lninacEQCv r5zg== X-Gm-Message-State: AOJu0Yz/dYpp5qg/9jcsM+DdOLU5PrYFVd6vWvUHnsKPNs6xIMONZQ0h 00N+lOPEAAGt9C4sePSzemcvYQlJs7bbEkC+hJEJwab+c/vsGYVb9j1FYHK58kufSwJuPrtpAca 31heguIyPBh868bQOTaLZ6018c2bCQKfl8Bzmm8w= X-Gm-Gg: ASbGncskjhmm+Ask6xPmlCKFhNpIPzJvwYUwwc0SxDR65DJzHVhtacBm0sOGRa8WgA/ LLS0cBQnGW9t+zAzOTFgrfYbJux433/N7uE9roddhTeLuJUxZJbrXwepYAoQ3cpinaT8CUBWXXY fHldGwO8g8SHzteGCsycQqZ6E808Cqo0zQcmMPQg== X-Google-Smtp-Source: AGHT+IHGct0XVQEzrnVISnZP0Z9se1APE1E3aJo1vrhi6TSQOGsRPnQ2RKES8mApm6AvvXDEzwIc5fshQKI8GaJWkx4= X-Received: by 2002:a17:907:7206:b0:ad5:5a7e:bcd with SMTP id a640c23a62f3a-ad8b0a47cdbmr1570700266b.8.1748852459104; Mon, 02 Jun 2025 01:20:59 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <78B00771-EAA7-4191-8B34-C6FAA53B6B66@rwec.co.uk> In-Reply-To: <78B00771-EAA7-4191-8B34-C6FAA53B6B66@rwec.co.uk> Date: Mon, 2 Jun 2025 16:20:54 +0800 X-Gm-Features: AX0GCFu0NiCy0hqrSrZvcvBstnm85To3YYTo9dqKL9_l4l1X07h7JYEY50BvEso Message-ID: Subject: Re: [PHP-DEV] [RFC] Add preserve_key_types to array_keys() to prevent unintended int conversion To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="00000000000096ee78063692714d" From: a766650827@gmail.com (=?UTF-8?B?6ams5q2j5by6?=) --00000000000096ee78063692714d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Rowan, Thank you for the clear technical guidance. I agree we've reached a consensus that implementing a native Map type would be the proper solution to this long-standing issue. To move forward, I'd like to clarify a few practical aspects: 1. **RFC Proposal** - Should I initiate an RFC draft at this stage? - If yes, would you recommend starting with an "idea" thread on internals@lists.php.net first? 2. **Implementation Resources** - Given my limited experience with PHP core development: - What would be the minimal viable prototype to demonstrate feasibility? - Are there active contributors you could refer who might be interested in collaborating? 3. **Interim Steps** - Would it help to: - Compile real-world use cases from major frameworks? - Benchmark existing userland implementations (e.g., DS\Map)? I'm committed to driving this improvement and willing to coordinate non-code efforts. Your advice on the most effective next steps would be invaluable. Best regards, [xiaoma] Rowan Tommins [IMSoP] =E4=BA=8E2025=E5=B9=B45=E6=9C= =8829=E6=97=A5=E5=91=A8=E5=9B=9B 00:43=E5=86=99=E9=81=93=EF=BC=9A > > > On 28 May 2025 14:42:01 BST, "=E9=A9=AC=E6=AD=A3=E5=BC=BA" wrote: > > > First, we could add a parameter like preserve_key_types to array > > functions such as array_keys()/array_search() to temporarily handle t= he > > implicit conversion issue. > > > This will not help. The keys are changed when they are *written* to the > array, not when they are read back out. No option to array_keys can tell > you whether the key 42 was originally set as '42', because that informati= on > is not stored anywhere. > > > > > Alternatively, we could introduce a new data type "Map" > > Yes, I think this was suggested a couple of times on the previous thread. > It would be a useful feature, but probably not easy to implement > efficiently and integrate thoroughly into the language. > > > Regards, > Rowan Tommins > [IMSoP] > --00000000000096ee78063692714d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Rowan, =C2=A0

Thank you for the clear technical = guidance. I agree we've reached a consensus that implementing a native = Map type would be the proper solution to this long-standing issue. =C2=A0
To move forward, I'd like to clarify a few practical aspects: =C2= =A0

1. **RFC Proposal** =C2=A0
=C2=A0 =C2=A0- Should I initiate a= n RFC draft at this stage? =C2=A0
=C2=A0 =C2=A0- If yes, would you recom= mend starting with an "idea" thread on internals@lists.php.net first? =C2=A0

2. **Impl= ementation Resources** =C2=A0
=C2=A0 =C2=A0- Given my limited experience= with PHP core development: =C2=A0
=C2=A0 =C2=A0 =C2=A0- What would be t= he minimal viable prototype to demonstrate feasibility? =C2=A0
=C2=A0 = =C2=A0 =C2=A0- Are there active contributors you could refer who might be i= nterested in collaborating? =C2=A0

3. **Interim Steps** =C2=A0
= =C2=A0 =C2=A0- Would it help to: =C2=A0
=C2=A0 =C2=A0 =C2=A0- Compile re= al-world use cases from major frameworks? =C2=A0
=C2=A0 =C2=A0 =C2=A0- B= enchmark existing userland implementations (e.g., DS\Map)? =C2=A0

I&= #39;m committed to driving this improvement and willing to coordinate non-c= ode efforts. Your advice on the most effective next steps would be invaluab= le. =C2=A0

Best regards, =C2=A0
[xiaoma]=C2=A0

Rowan Tommins [IMSoP] <imsop.= php@rwec.co.uk> =E4=BA=8E2025=E5=B9=B45=E6=9C=8829=E6=97=A5=E5=91=A8= =E5=9B=9B 00:43=E5=86=99=E9=81=93=EF=BC=9A


On 28 May 2025 14:42:01 BST, "=E9=A9=AC=E6=AD=A3=E5=BC=BA" <a766650827@gmail.co= m> wrote:

>=C2=A0 =C2=A0First, we could add a parameter like preserve_key_types to= array
>=C2=A0 =C2=A0functions such as array_keys()/array_search() to temporari= ly handle the
>=C2=A0 =C2=A0implicit conversion issue.


This will not help. The keys are changed when they are *written* to the arr= ay, not when they are read back out. No option to array_keys can tell you w= hether the key 42 was originally set as '42', because that informat= ion is not stored anywhere.



>=C2=A0 =C2=A0Alternatively, we could introduce a new data type "Ma= p"

Yes, I think this was suggested a couple of times on the previous thread. I= t would be a useful feature, but probably not easy to implement efficiently= and integrate thoroughly into the language.


Regards,
Rowan Tommins
[IMSoP]
--00000000000096ee78063692714d--