Re: by-ref return & inheritance

From: Date: Fri, 08 Aug 2008 23:48:41 +0000
Subject: Re: by-ref return & inheritance
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-39786@lists.php.net to get a copy of this message
Hi!
What makes you think there won't be a problem with the reverse. The caller does not expect a reference but the calle returns one? In OOP the return
Well, I don't know any case where $a = foo() would work in a substantially different way for the user if foo() returns by-ref and not by-val. If you are aware of any such case - please tell, that's exactly why I ask.
value of the derived class' method must be an instance of the class defined by the base class' method or a subclasse of that. And so far we tream them different, rather than a reference is a subclass of a normal value or vice versa.
Err... I'm afraid I don't understand what you mean here. By-ref return is not a subclass of anything - not only PHP has no type control of return values, by-ref is a zval flag and not a type - so I don't think there are any subclasses here per se. What is relevant that value returned by-ref can be used in by-val context. The question is very simple - can you (or anybody else) think of any scenario that such override would lead to any problem LSP-wise? Any code that wouldn't work with such override? -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

« previous php.internals (#39786) next »