Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99819 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24211 invoked from network); 7 Jul 2017 23:31:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jul 2017 23:31:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=rudolf.theunissen@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rtheunissen@php.net; sender-id=unknown Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.46 as permitted sender) X-PHP-List-Original-Sender: rudolf.theunissen@gmail.com X-Host-Fingerprint: 209.85.218.46 mail-oi0-f46.google.com Received: from [209.85.218.46] ([209.85.218.46:36852] helo=mail-oi0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EF/E5-47109-3B910695 for ; Fri, 07 Jul 2017 19:30:59 -0400 Received: by mail-oi0-f46.google.com with SMTP id x187so39483840oig.3 for ; Fri, 07 Jul 2017 16:30:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=tbB/0DwAsK3/BrVpqNAD9gm9T0np1D0AsQeVemLdpBk=; b=hxJWQR2k2dER8h3//4PCrbXDZ6we9IkTkOZ7vCFASDnwioyJD9KQdyJSAUr8uGu1rA sRsfTZbAQYLAKIeJyBPu+6qnw67UaRvCPjPwDERSOGBkCAtyCrkdgMTSvqAHhinY599Z CCv5RGmxT3lN3BJftpp0LBaVh0Fm1XnLO+5mPDRydmgpadGwwgvBCltPeORCUZQJCRcm VY/QFUfUE58y35rXOVRunudYVly+5Mtpucx5E/9Hy8WOsuu0wOn7Ftn0keDFYlJWs3ov FWmn2kcnudSkeEYLpe3nVmmWroQ6OLxDuvkHsoow40dBRcV6G167wpTcXXV6JyWTtskP 8i8g== X-Gm-Message-State: AIVw111LKLXr4gTKlNp7rl6eDHe3bzwFpLwtuJlSXuYUkjPT8SKvJAgt kMr0L5gJb3mzu628IMgXWA== X-Received: by 10.202.96.67 with SMTP id u64mr2521830oib.62.1499470256293; Fri, 07 Jul 2017 16:30:56 -0700 (PDT) Received: from mail-oi0-f54.google.com (mail-oi0-f54.google.com. [209.85.218.54]) by smtp.gmail.com with ESMTPSA id h130sm5906468oic.37.2017.07.07.16.30.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Jul 2017 16:30:55 -0700 (PDT) Received: by mail-oi0-f54.google.com with SMTP id l130so39630905oib.1 for ; Fri, 07 Jul 2017 16:30:55 -0700 (PDT) X-Received: by 10.202.229.73 with SMTP id c70mr2007792oih.29.1499470255598; Fri, 07 Jul 2017 16:30:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.219.136 with HTTP; Fri, 7 Jul 2017 16:30:55 -0700 (PDT) Date: Sat, 8 Jul 2017 11:30:55 +1200 X-Gmail-Original-Message-ID: Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="001a11408616efb8630553c29f3e" Subject: ArrayAccess: Constant numeric string offsets become integers From: rtheunissen@php.net (Rudi Theunissen) --001a11408616efb8630553c29f3e Content-Type: text/plain; charset="UTF-8" Bug: https://bugs.php.net/bug.php?id=63217 PR: https://github.com/php/php-src/pull/2607 Demo: https://3v4l.org/dagUP I've heard mixed responses to this bug and the approach to fix it (or whether we should at all). The two common opinions are that ArrayAccess should behave exactly like an array, and the other is that it's up to the implementer to handle the offsets. I would like to propose that the aim of ArrayAccess is not to emulate the *behaviour* of an array, but instead only use its access *syntax*. The way an array handles numeric string keys, floats, booleans etc is specific to how an array works, and should not be forced on objects that implement ArrayAccess. In the demo linked above, you'll notice that ArrayAccess already allows any key type, but becomes inconsistent when a constant numeric string is used. Notice that the HHVM result shows the expected behaviour. We should either go full array behaviour, or full array syntax only. The numeric string optimisation that causes this bug is broken and should either be fixed or removed entirely. An important note is that *this does not affect arrays or object properties at all* - only ArrayAccess. --001a11408616efb8630553c29f3e--