Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112850 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 74154 invoked from network); 12 Jan 2021 16:40:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Jan 2021 16:40:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EA72B1804E2 for ; Tue, 12 Jan 2021 08:18:42 -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=-2.1 required=5.0 tests=BAYES_00,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-Virus: No X-Envelope-From: Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (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 ; Tue, 12 Jan 2021 08:18:42 -0800 (PST) Received: by mail-io1-f45.google.com with SMTP id 81so5173869ioc.13 for ; Tue, 12 Jan 2021 08:18:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+vaqlLc9F8te9eEi7Yx9Prmj09Hi0a3qYAe3k/IV7gM=; b=db6JCFHLMXE6VgEBn6dxtJRN0MZUjly7Rh5obo5bJ51irrtQDE/yK55I1jHbTnzSjH e3/S1jtmGmVSVzmvIHqxUI1CnizdAJtKWuJRoS9I/zsc6w1GoUpQBSeXXg11kpjwuCCV wMEBzc7eZl/uPAes+ToqVHrwYTmb02JBZj2IefsehXPJ14CIgUAJRZtmosVzbMuUi0Wn eeaMdE7HLNrU6qX3mA/0YfTvJ0Zskuw/sQoTNJiSLWEBGVrv6VN3nH7f8kNRk36yFvLj xhAI4NtB1QAifHgZd8h+SC1nG9k3s3WxBFqRc2KmhI2iCxxIvbqe+ZhpETszioYZkF3h O57w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+vaqlLc9F8te9eEi7Yx9Prmj09Hi0a3qYAe3k/IV7gM=; b=iPJlHT5myUzTaWmSnuBVNgsnMhp7m1Ev5ZGH2XD3E3VJGFNg4eyFV2ZN6AH2oa5Y+t EZ9Xge31+68FA/U5GgQVYHAdIYenQrWK6PBPpX9TPM9Y7dH2IDqEIfIkLzAgjJFsT0/C WFs+XNr3kn9YGGc42yabmpOkGMjwrGknapALA8sBHB9eIpAwEZVIObaJLWY82kr/ZKt5 Xsrfqzt7Ufmh9MpM+IoMNme1MO15mpNQGpuWZFJyMWMkBLnjT9ANRdOrIcNYZj4Str8M q/FtE4ONCJPw3ZjLLZp1l5+NUEgMmIRc2D/4ddIAkiEruRBdFP3UPzroGtOLGfLnTnFZ 8hwg== X-Gm-Message-State: AOAM530hvLxx0yYub00WGl5Y2aYCn3F1kcIzTPH5+kAbCy6rhkfae7z4 tmCUiORa++4cLwCaQVb25oXOyRUUyrxaV8dNvG0= X-Google-Smtp-Source: ABdhPJykSKJ7AsB783FCdHF9U+q+GQy42icBE5HGgWzkqih6fEbuqaLsYhrM8Ix3Lr6FkqG9tOZn5NJdlAYk3kKi/Os= X-Received: by 2002:a05:6638:3006:: with SMTP id r6mr132861jak.72.1610468321190; Tue, 12 Jan 2021 08:18:41 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 12 Jan 2021 17:18:28 +0100 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000034e89405b8b660f2" Subject: Re: [PHP-DEV] [RFC] Allow object keys in arrays From: ocramius@gmail.com (Marco Pivetta) --00000000000034e89405b8b660f2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Nikita, On Mon, Jan 11, 2021, 15:29 Nikita Popov wrote: > Hi internals, > > I would like to present a draft RFC for allowing object keys in arrays: > https://wiki.php.net/rfc/object_keys_in_arrays > > The specification in the RFC is incomplete, and primarily focussed on wha= t > impact this has from an internal perspective. > https://github.com/php/php-src/pull/6588 is a draft implementation that > illustrates the necessary changes. > > The primary motivation, and reason why I am looking into this now, is tha= t > the current enum proposal is based on objects, and I consider it somewhat > important that enum values can also work as array keys. > > From a technical perspective, this also lays the groundwork for supportin= g > other key types in the future, e.g. if we wish to switch PHP to use > arbitrary-precision integers. > Overall, this is something I always wanted, but adding it means that the type of all array functions returning keys widens, which is quite the BC hell =F0=9F=A4=94 The basic assumption is that, when an `array` is given, `foreach ($array as $key =3D> )` produces a `$key` if type `string|int`. While this assumption does not hold true for `iterable` (notably `SplObjectStorage`, `Generator`), it's still quite a jump to break it here, so it would probably require scheduling such a feature for 9.0. > --00000000000034e89405b8b660f2--