On 17 September 2011 15:52, Ferenc Kovacs <tyr...@gmail.com> wrote:
> maybe Richard referring to https://bugs.php.net/bug.php?id=55085 ?
> but those change only affects the abstract classes.
>
> Tyrael
>
> On Sat, Sep 17, 2011 at 3:43 PM, Nikita Popov <nikita....@googlemail.com> 
> wrote:
>> Hi Richard!
>>
>> Which change are you talking about? I just tried doing:
>>    <?php
>>    class A           { public function __construct($a)     { } }
>>    class B extends A { public function __construct($a, $b) { } }
>> And it worked on 5.4 Beta 1 without errors.
>>
>> Nikita
>>
>> On Sat, Sep 17, 2011 at 3:27 PM, Richard Quadling <rquadl...@gmail.com> 
>> wrote:
>>> Hi.
>>>
>>> With the recent BC with regard the locking of the constructor's
>>> signature for subclasses, what is the expected mechanism for allowing
>>> a subclass to have additional parameters?
>>>
>>> You can always supply them and use func_get_args() / func_num_args() /
>>> etc. to read them.
>>>
>>> It would seem that the limitation restricts the capabilities. I'm not
>>> a purist. Software development is a compromise between purity and
>>> getting the job done in an efficient and understandable manner.
>>>
>>> By allowing undocumented parameters to the constructor (due to the
>>> enforced signature), this would seem to break things on a different
>>> front (I can't docblock non defined parameters for examples).

My question was due to the documentation commit
http://news.php.net/php.doc.cvs/8818 and
http://news.php.net/php.doc.cvs/8819.

Not being an expert, so I don't know all the theory, but it would seem
an abstract class defines the idea and the concrete class defines it
more - I need a better grasp of words here.

An interface is the absolute here. Sub classes (the super class being
abstract or otherwise), should be able to define MORE parameters (with
or without default values). Otherwise they aren't extending, but
implementing - and for me that's the role of an interface.

It is only interfaces that guarantee things because the interface IS
the guarantee.

A class isn't beholden to anything it inherits. You can override
methods, completely obscuring the super class if you so want.

A subclass can completely divorce itself from the superclass.

But not with an interface.


PHP has always been a very very flexible language. I feel that if a
developer absolutely must enforce a method's signature, then an
interface is going to do that 100% and is a relatively easy way to do
things. Enforcing method signatures in subclasses (I don't know why
abstract classes are treated differently) does sort of make the
interface redundant.

Unless there is a real issue with the internal engine, then the method
signatures should be flexible. Unless an interface is used.

Richard.
-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to