Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49205 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68926 invoked from network); 4 Aug 2010 16:58:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Aug 2010 16:58:05 -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:60008] helo=users.smashlabs.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F4/AD-19907-C1C995C4 for ; Wed, 04 Aug 2010 12:58:05 -0400 Received: (qmail 16186 invoked from network); 4 Aug 2010 11:57:53 -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; 4 Aug 2010 11:57:53 -0500 Message-ID: <4C599C17.5050505@smashlabs.com> Date: Wed, 04 Aug 2010 11:57:59 -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: =?UTF-8?B?Sm9oYW5uZXMgU2NobMO8dGVy?= CC: Etienne Kneuss , internals Mailing List References: <1272386738.870.32.camel@guybrush> In-Reply-To: <1272386738.870.32.camel@guybrush> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] ArrayAccess::offsetGet not returning a ref From: ralph@smashlabs.com (Ralph Schindler) Hey all, Was there any more discussion on this? I've been bit by this as well, several times over the past 3 years. I'd opt for option (d) for all prototype/signature checking. Here's why: I don't think the return "type" should be considered part of the signature when enforcing LSP. PHP (currently), does not care what the type of the return value is, much less if there is even one to be returned. Whether or not it is a reference or a value should not impact the conditions presented to the caller, in other words "the preconditions are not strengthened in a subtype." Since PHP does no enforcement of return values, postconditions don't seem to apply. Also, relaxing the checks would be backwards compatible. Since no code should currently exist that does this (its an E_FATAL currently if the signature originates in an interface, E_STRICT notice when the signature originates in an abstract/base class overridden in a subclass). Thoughts? Ralph Schindler Johannes Schlüter wrote: > Hi, > > On Tue, 2010-04-27 at 10:17 +0200, Etienne Kneuss wrote: >> it looks like the fact that ArrayAccess::offsetGet is not returning a >> reference is a recurrent problem, I see basically 4 options: > > The main use case is some nested structure like > > $o = new ArrayObject(); > /*...*/ > $o[23][42] = "foobar"; > > right? > >> a) Ignore the issue, change nothing >> >> b) Rewrite offsetGet to return a ref, breaking BC >> >> c) Create a new ArrayAccess interface where it does return a ref >> >> d) Relax prototype checks so that both are allowed. > > If the above case is correct and due to me not liking references I > wonder whether there is a way to for an option e) which adds support for > this in some way to the engine. > > johannes > > >