Re: AW: [PHP-DEV] Types on the right or on the left
| From: | Chris Wright | Date: | Tue, 04 Nov 2014 11:50:33 +0000 |
| Subject: | Re: AW: [PHP-DEV] Types on the right or on the left | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78629@lists.php.net to get a copy of this message | ||
On 4 November 2014 10:32, Andrea Faulds <ajf@ajf.me> wrote:
>
> > 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.
>
>
So, in a sentence:
In PHP, input types go on the left and output types go on the right.
This sounds like a convention that could be established and followed, and
no-one could reasonably call it inconsistent if it was adhered to.