On Fri, 2006-07-21 at 17:46, Michael Wallner wrote:
> Andi Gutmans wrote:
> > There's a big difference. Inherited classes should adhere to the
> > instanceof operator. Meaning that if you get an object you can check
> > if it's an instance of another class and if so, you can call it
> > *exactly* the way you could the parent class. This allows for good
> > polymorphic design in applications. Allowing subclasses to change a
> > function's signature to be incompatible with its parent would break 
> > this rule (you can use default arguments to resolve some of these
> > cases as instanceof remains). For constructors it actually makes
> > sense because at the time of instantiaton, you know what the concrete
> > class is. It is very common for constructors to be very much
> > different in polymorphic classes.
> 
> This is only partly true.  In languages where you can be sure to call A::f()
> this is useful.  You suggest to change PHP, which doesn't have any other means
> for decent overloading, in a way that completely removes this freedom.
> Using interfaces is IMHO the way to enforce method signature in PHP.

I'd have to agree. PHP4 had the nice flexibility of allowing subclasses
to override the method signature without incurring the wrath of an
error. PHP 5 and all it's OOP sugar said screw that, we're going to give
you interfaces AND we're going to tie your hands behind your back, even
when you choose not to use an interface, and make you do redundant
things like re-iterate all the default values the subclass declared when
overriding it... and depending on the level of inheritance this
redundancy travels all the way up the ancestry... YUCK. Seriously, the
name interface implies a forced pattern... if you want to force a
signature, force it when an interface is implemented.

So anyways, while we're all chatting :) How about prototype style
override support *cackles, ducks, and runs*.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

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

Reply via email to