Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78054 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73547 invoked from network); 14 Oct 2014 19:44:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Oct 2014 19:44:32 -0000 Authentication-Results: pb1.pair.com header.from=php@mabe.berlin; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@mabe.berlin; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mabe.berlin from 80.237.132.167 cause and error) X-PHP-List-Original-Sender: php@mabe.berlin X-Host-Fingerprint: 80.237.132.167 wp160.webpack.hosteurope.de Received: from [80.237.132.167] ([80.237.132.167:49996] helo=wp160.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A4/A2-18603-C1D7D345 for ; Tue, 14 Oct 2014 15:44:29 -0400 Received: from dslb-178-012-112-159.178.012.pools.vodafone-ip.de ([178.12.112.159] helo=[192.168.178.30]); authenticated by wp160.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) id 1Xe81B-0000cS-Q8; Tue, 14 Oct 2014 21:44:25 +0200 Message-ID: <543D7D18.9010100@mabe.berlin> Date: Tue, 14 Oct 2014 21:44:24 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Stas Malyshev , PHP Internals List References: <543C9E9F.80804@mabe.berlin> <543CCFEA.2080908@sugarcrm.com> In-Reply-To: <543CCFEA.2080908@sugarcrm.com> Content-Type: multipart/alternative; boundary="------------090301090604070907050505" X-bounce-key: webpack.hosteurope.de;php@mabe.berlin;1413315869;0f2e7c4c; Subject: Re: [PHP-DEV] Possibilities to fix some really poor behaviors in PHP7 From: php@mabe.berlin (Marc Bennewitz) --------------090301090604070907050505 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 14.10.2014 09:25, Stas Malyshev wrote: > Hi! > >> ... like the hidden array element: http://3v4l.org/6uFqf >> ... like the hidden object property: http://3v4l.org/RPJXH > The issue seems to be that array lookup always looks for numeric results > when looking for numeric-like keys. But when adding property, the > numeric check is not done since properties are not supposed to be > numeric. Thus, when converting the object to array, the property named > "123" becomes inaccessible, because in array it is supposed to be under > number 123. > > We could, of course, add numeric checks to properties, but it would slow > things down only to serve very narrow use case with hardly any legit > uses. We could also rewrite hashtable with numeric keys instead of > string keys when doing conversion, but again that would be significant > slowdown for a very rare use case. Not sure it's worth it. Please correct me if I'm wrong but object properties should be strings in all cases. So all properties set should be converted to string means the following should be equal but isn't and I don't see any performance issues forcing strings here: |$obj = (object)array('123' => '456'); var_dump($obj); var_dump($obj->{'123'}); // ||Notice: Undefined property: stdClass::$123| |var_dump($obj->{123});| |// ||Notice: Undefined property: stdClass::$123| For the case of object to array conversion a numeric check could be very improved by simply check if the first character between 0-9 before starting the complete numeric check. That would be very fest and it produces right results. It's poor to say "... very narrow use case with hardly any legit uses ..." in programming languages. In my opinion the right result have to be the first goal and performance optimization is something to keep in mind but should never produce wrong results. Marc --------------090301090604070907050505--