IMO we are trying to force a strict programming here that is 
incompatible with PHP's loose character.

The following example for instance is very common in Java AVT 
programming:

<?php

class Window {
    function __construct($title)
    {
    }
}

class MyApplicationWindow extends Window
{
    const VERSION = "1.1";

    function __construct()
    {
        parent::__construct("My Application v." . self::VERSION");
    }
}
?>

Furthermore with the new implementation we disallow "the PHP way 
for overloaded methods" using a variable parameter count:

<?php

class Base
{
    function doSomething(MyClass $obj)
    {
    }
}

class Extended extends Base
{
    function doSomething()
    {
        $args = func_get_args();

        switch (count($args)) {
            case 0:
                return parent::doSomething(new MyClass());

            case 1:
                if ($args[0] instanceof MyClass) {
                    return parent::doSomething($args[0]);
                }
                return parent::doSomething(new MyClass($args[0]));

            default:
                throw new IllegalArgumentException();
        }
    }
}

?>

-- 
Ferdinand Beyer
<[EMAIL PROTECTED]>

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

Reply via email to