Re: [RFC Discussion] Typed Properties
| From: | Ryan Pallas | Date: | Wed, 30 Mar 2016 00:59:39 +0000 |
| Subject: | Re: [RFC Discussion] Typed Properties | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92001@lists.php.net to get a copy of this message | ||
On Tue, Mar 29, 2016 at 5:16 PM, Levi Morrison <levim@php.net> wrote:
> > 2) The handling of multiple properties in the same declaration statement
> is inconsistent.
> >
> > public int $bar, string $qux; // this works
> >
> > public int $bar, $qux; //this emits error: Untyped property
> A::$qux must not be mixed with typed properties
> >
> > It's better to allow type only before first property in the list and
> apply them to all of them (like C, Java and others).
> > Is this just an implementation issue?
>
> I'm actually glad this is prevented because it's confusing. Is
>
$qux
> typed or untyped?
>
I think its very obviously typed int. This would allow you to list a bunch
of things of the same type in a single declaration, meaning only a single
visibility and type for the line, instead of having to repeat the type for
each property (whilst not having to repeat the visibility, this feels
inconsistent).
public string $firstName, $middleInitial, $lastName, $nickName;
vs
public string $firstName, string $middleInitial, string $lastName, string
$nickName;
I like the first much better personally. The second feels inconsistent, why
would the visibility carry to all properties but not the type?
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>