Hi !

> For one I do think that enforcing strictness, or as I see it, clean
> code and implementation, should be done in php. We did not do that in
> the past and it has created more issues than anything else in the long
> run.

+1.

> One solution to solve the need of having different methods or
> constructors signatures is to support multiple signature per method or
> constructor, as long as the signature of the parent class or interface
> is available. This is something becoming more and more common in other
> languages and is actually very handy. Having such things would have
> also avoided bad (per design while necessary) sutff like the recent
> reflection function to create objects without invoking the
> constructor.

+1.
The possibility to defined multiple signature per method will be a great 
improvement.

A class like this :

class foo
{
        function barForArray(array $array) {...}
        function barForACall(aCall $objectClass) {...}
        function barForCallable(Callable $callable) {...}
}

foreach ($arrayOfUndeterminedThings  as $data)
{
        switch (true)
        {
                case is_array($data):
                        $foo->barForArray($data);
                        break;

                case $data instanceof aCall:
                        $foo->barForACall($data);
                        break;

                case $data instanceof Callable:
                        $foo->barForCallable($data);
                        break;
        }
}

will become :

class foo
{
        function bar(array $array) {...}
        function bar(aCall $objectClass) {...}
        function bar(Callable $callable) {...}
}

foreach ($arrayOfUndeterminedThings  as $data)
{
        $foo->bar($data);
}

Best regards,
Fred
--
========================================================================
Frédéric Hardy : Architecte d'application/Admin. système/Ergonome
                     CV : http://blog.mageekbox.net/public/cv.frederic.hardy.pdf
                  Blog : http://blog.mageekbox.net
              Twitter : http://twitter.com/mageekguy
========================================================================


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

Reply via email to