Re: Types on the right or on the left
| From: | Yasuo Ohgaki | Date: | Sat, 24 Jan 2015 18:33:47 +0000 |
| Subject: | Re: Types on the right or on the left | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-81094@lists.php.net to get a copy of this message | ||
Hi all,
On Tue, Nov 4, 2014 at 12:39 AM, Andrea Faulds <ajf@ajf.me> wrote:
> > On 3 Nov 2014, at 15:07, Robert Stoll <php@tutteli.ch> wrote:
> >
> > It adds the type hint on the right hand side of the function (of the
> identifier). In contrast to parameters where the
> > type hint is placed on the left hand side of the identifier.
> > Mixing both, having some types on the left and others on the right,
> seems like another inconsistency in the language
> > design to me.
>
> These inconsistencies exist for two reasons:
>
> - Opposition to doing it the other way
> - Hack already doing it this way
>
> I don’t think
function void foo(); will happen, since
> that’s been
> previously rejected as it breaks gripping for “function foo”. Similarly, I
> don’t think public $foo: Foo; will happen, given Hack does it
> as `public
> Foo $foo;`.
>
I agree with Andrea.
There are people who dislike syntax, and/or thinks PHP missing check(i.e.
array format, etc). These people should request DbC.
DbC is more powerful than simple type checks and have no performance
penalty in production. (I'm not saying type hinting is
useless. I'll use it where it is appropriate, too.)
I wish I have time for diving into Zend code, but it would not happen in
short term. Therefore, I'm hoping someone to implement DbC :)
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net