Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49216 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 458 invoked from network); 6 Aug 2010 14:50:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Aug 2010 14:50:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=ralph@smashlabs.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ralph@smashlabs.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain smashlabs.com from 67.15.58.61 cause and error) X-PHP-List-Original-Sender: ralph@smashlabs.com X-Host-Fingerprint: 67.15.58.61 openrce.org Linux 2.6 Received: from [67.15.58.61] ([67.15.58.61:45719] helo=users.smashlabs.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BB/E2-21239-C312C5C4 for ; Fri, 06 Aug 2010 10:50:37 -0400 Received: (qmail 24485 invoked from network); 6 Aug 2010 09:50:25 -0500 Received: from ip174-70-101-166.no.no.cox.net (HELO ralph-macbook.local) (174.70.101.166) by smashlabs.com with (DHE-RSA-AES256-SHA encrypted) SMTP; 6 Aug 2010 09:50:25 -0500 Message-ID: <4C5C2139.8040800@smashlabs.com> Date: Fri, 06 Aug 2010 09:50:33 -0500 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061207 Thunderbird/1.5.0.9 Mnenhy/0.7.4.666 MIME-Version: 1.0 To: Stas Malyshev CC: =?UTF-8?B?Sm9oYW5uZXMgU2NobMO8dGVy?= , Etienne Kneuss , internals Mailing List , derick@php.net References: <1272386738.870.32.camel@guybrush> <4C599C17.5050505@smashlabs.com> <4C5B3B1F.9090905@sugarcrm.com> <4C5C1AA6.2010902@smashlabs.com> In-Reply-To: <4C5C1AA6.2010902@smashlabs.com> Content-Type: multipart/mixed; boundary="------------060506020409020604020504" Subject: Re: [PHP-DEV] ArrayAccess::offsetGet not returning a ref From: ralph@smashlabs.com (Ralph Schindler) --------------060506020409020604020504 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit The attached patch is the suggested fix. I made this against master on github. -ralph Ralph Schindler wrote: > I can give 2 examples, one that triggers the problem, the other that is > a real world issue: > > --- > > Simple: > > > interface I { > public function foo($name); > } > > class C implements I { > public function & foo($name) {} > } > > $c = new Bar(); > > > running this produces: > > $ php -d error_reporting=32767 test-reference-in-signature.php > PHP Fatal error: Declaration of C::foo() must be compatible with that > of I::foo() in path/to/test-reference-in-signature.php on line 8 > > ---- > > Real world issue with ArrayAccess: > > > > class SomeContainer implements ArrayAccess { > protected $_data = array('foo' => array(1,2,3)); > public function & offsetGet($name) { > $r = & $this->_data['foo']; > return $r; > } > public function offsetSet($name, $value) {} > public function offsetExists($name) {} > public function offsetUnset($name) {} > } > > $b = new Bar(); > $b['foo'][3] = 4; // implies Bar::offsetGet() happens before assign > > > running this produces: > > $ php -d error_reporting=32767 test-reference-in-arrayaccess.php > PHP Fatal error: Declaration of SomeContainer::offsetGet() must be > compatible with that of ArrayAccess::offsetGet() in > path/to/test-reference-in-arrayaccess.php on line 3 > > > -ralph > > Stas Malyshev wrote: >> Hi! >> >>> I'd opt for option (d) for all prototype/signature checking. Here's >>> why: >> >> I think relaxing the check may make sense. Do you have some code >> example that doesn't work and you want it to work? > > --------------060506020409020604020504 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="fix-return-ref.diff" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="fix-return-ref.diff" ZGlmZiAtLWdpdCBhL1plbmQvemVuZF9jb21waWxlLmMgYi9aZW5kL3plbmRfY29tcGlsZS5j CmluZGV4IDZhNmI1OTcuLjUyZGVjYWEgMTAwNjQ0Ci0tLSBhL1plbmQvemVuZF9jb21waWxl LmMKKysrIGIvWmVuZC96ZW5kX2NvbXBpbGUuYwpAQCAtMjkzMiwxMCArMjkzMiw2IEBAIHN0 YXRpYyB6ZW5kX2Jvb2wgemVuZF9kb19wZXJmb3JtX2ltcGxlbWVudGF0aW9uX2NoZWNrKGNv bnN0IHplbmRfZnVuY3Rpb24gKmZlLCBjCiAJCXJldHVybiAwOwogCX0KIAotCWlmIChmZS0+ Y29tbW9uLnJldHVybl9yZWZlcmVuY2UgIT0gcHJvdG8tPmNvbW1vbi5yZXR1cm5fcmVmZXJl bmNlKSB7Ci0JCXJldHVybiAwOwotCX0KLQogCWZvciAoaT0wOyBpIDwgcHJvdG8tPmNvbW1v bi5udW1fYXJnczsgaSsrKSB7CiAJCWlmIChaRU5EX0xPR19YT1IoZmUtPmNvbW1vbi5hcmdf aW5mb1tpXS5jbGFzc19uYW1lLCBwcm90by0+Y29tbW9uLmFyZ19pbmZvW2ldLmNsYXNzX25h bWUpKSB7CiAJCQkvKiBPbmx5IG9uZSBoYXMgYSB0eXBlIGhpbnQgYW5kIHRoZSBvdGhlciBv bmUgZG9lc24ndCAqLwo= --------------060506020409020604020504--