Hey All,
I'm really interested on this topic.

What would be the result of this?

function Foo foo($something) {
     if ( $something ) {
          return new Foo;
     }
     // no return implies return null
}

How do you force to return a Type with null allowed?

 Martin Scotta


On Thu, Apr 28, 2011 at 6:59 AM, Alain Williams <a...@phcomp.co.uk> wrote:

> On Thu, Apr 28, 2011 at 02:43:36AM -0700, Rasmus Lerdorf wrote:
>
> > >     function array foo() { .... }
> > >
> > >     $ret = foo();
> > >     foreach($ret as $val)
> > >         ....
> >
> > I don't see this being useful at all. All you are doing is duplicating a
> > runtime warning. We can't possibly know at compile-time whether this
> > return value is an array or not, so there is no compile-time benefit.
>
> The check is not done where foo() is called but within foo() itself, to
> ensure
> that it only returns an array.
>
> There will also be advantages for HipHop which can afford to spend the time
> to
> do static analysis of code -- I know that HipHop is not your baby
> but you now need to recognise that there is more than one PHP
> implementation
> and features that may not had much advantage with Zend may be useful
> elsewhere.
>
> --
> Alain Williams
> Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT
> Lecturer.
> +44 (0) 787 668 0256  http://www.phcomp.co.uk/
> Parliament Hill Computers Ltd. Registration Information:
> http://www.phcomp.co.uk/contact.php
> #include <std_disclaimer.h>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to