Re: AW: [PHP-DEV] Types on the right or on the left
| From: | Andrea Faulds | Date: | Tue, 04 Nov 2014 10:32:41 +0000 |
| Subject: | Re: AW: [PHP-DEV] Types on the right or on the left | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78624@lists.php.net to get a copy of this message | ||
> On 4 Nov 2014, at 08:51, Stas Malyshev <smalyshev@sugarcrm.com> wrote:
>
> I agree, this is not a very good situation. It would be much better to
> take a systematic approach to this, but this is impossible since there
> is no systematic approach to strict typing in PHP, just some pieces here
> and there. I think this is not right, but obviously many people here
> disagree and are happy to have the inconsistent syntax. I don't see why
> "public Foo function bar()" would be so much worse than "public function
> bar() : Foo" but for some reason this possibility wasn't even
> considered as far as I can see.
I thought it was inconsistent, but after discussions on StackOverflow, I don't think it
actually is. Return types describe the return type of a function, not the type of a function. So
there's no reason they have to go before the function name like parameter types do.
Also, it's worth bearing in mind that
public Foo function was rejected previously.
--
Andrea Faulds
http://ajf.me/