Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-25 Thread Rowan Collins
On Sun, 23 Sep 2018 at 22:48, Nikita Popov wrote: > > There might be a compromise here, which is to only perform a ctor > initialization check and forbid explicit unset()s if the class does not use > property accessors (i.e. does not define __get). This allows the lazy > initialization pattern bu

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-23 Thread Nikita Popov
On Sun, Sep 23, 2018 at 10:08 PM Rowan Collins wrote: > On 23/09/2018 19:41, Claude Pache wrote: > >> 3) Object properties may be type hinted and the class author has until > the end > >> of the constructor to make sure they're fulfilled, otherwise TypeError > on the > >> spot (what I'm proposing

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-23 Thread Rowan Collins
On 23/09/2018 21:50, Christoph M. Becker wrote: In my opinion, explicitly *declared* properties should not be unsettable. We don't allow to undefine constants, functions, classes etc. either. Adding and removing other properties could still be allowed. While I agree, I think that's a somewha

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-23 Thread Rowan Collins
On 23/09/2018 19:31, David Rodrigues wrote: Em dom, 23 de set de 2018 às 13:09, Larry Garfield escreveu: 3) Object properties may be type hinted and the class author has until the end of the constructor to make sure they're fulfilled, otherwise TypeError on the spot (what I'm proposing). Ite

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-23 Thread Christoph M. Becker
On 23.09.2018 at 22:07, Rowan Collins wrote: > On 23/09/2018 19:41, Claude Pache wrote: >> >>> 3) Object properties may be type hinted and the class author has >>> until the end >>> of the constructor to make sure they're fulfilled, otherwise >>> TypeError on the >>> spot (what I'm proposing). >>

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-23 Thread Robert Korulczyk
> Just to be sure you don’t miss the herd that this elephant is concealing: > > In addition, you *must* forbid unset() on those properties... Shouldn't we delegate the whole problem to object type resolving and make it more strict? Right now properties are not guaranteed at all - you can have `

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-23 Thread Rowan Collins
On 23/09/2018 19:41, Claude Pache wrote: 3) Object properties may be type hinted and the class author has until the end of the constructor to make sure they're fulfilled, otherwise TypeError on the spot (what I'm proposing). Just to be sure you don’t miss the herd that this elephant is concealin

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-23 Thread Lester Caine
Wrong reply button :( On 23/09/2018 07:18, Rasmus Schultz wrote: That is the entire point of the elephant analogy: that knowing what can get in doesn't necessarily mean knowing what is already inside - BUT, knowing what can get in may still useful in itself. I understood that, and I disagree -

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-23 Thread Claude Pache
> > 3) Object properties may be type hinted and the class author has until the > end > of the constructor to make sure they're fulfilled, otherwise TypeError on the > spot (what I'm proposing). Just to be sure you don’t miss the herd that this elephant is concealing: In addition, you *must* f

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-23 Thread David Rodrigues
Em dom, 23 de set de 2018 às 13:09, Larry Garfield escreveu: > 3) Object properties may be type hinted and the class author has until the > end > of the constructor to make sure they're fulfilled, otherwise TypeError on > the > spot (what I'm proposing). > Item 3 could not be enough, for instanc

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-23 Thread Larry Garfield
On Sunday, September 23, 2018 1:18:02 AM CDT Rasmus Schultz wrote: > > That is the entire point of the elephant analogy: that knowing what can > > get in doesn't necessarily mean knowing what is already inside - BUT, > knowing what can get in may still useful in itself. > > I understood that, and

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-22 Thread Rasmus Schultz
> That is the entire point of the elephant analogy: that knowing what can get in doesn't necessarily mean knowing what is already inside - BUT, knowing what can get in may still useful in itself. I understood that, and I disagree - just knowing what can get in is not useful or interesting in itsel

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-22 Thread Rowan Collins
On 22 September 2018 20:32:04 BST, Rasmus Schultz wrote: >if you read my last post (especially the last part) carefully, you'll >see >why this elephant analogy is incomplete. > >the issue is not whether or not something gets in - it's much more far >reaching than that. > >the issue is, once someth

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-22 Thread Larry Garfield
On Saturday, September 22, 2018 2:32:04 PM CDT Rasmus Schultz wrote: > Larry, > > this wasn't aimed at "you" personally, I'm just using the proverbial "you", > as in "not me". > > if you read my last post (especially the last part) carefully, you'll see > why this elephant analogy is incomplete.

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-22 Thread Rasmus Schultz
Larry, this wasn't aimed at "you" personally, I'm just using the proverbial "you", as in "not me". if you read my last post (especially the last part) carefully, you'll see why this elephant analogy is incomplete. the issue is not whether or not something gets in - it's much more far reaching th

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-22 Thread Larry Garfield
Rasmus: Please be careful when you refer to "you" as wanting or doing something. I had no part in the patch design or implementation beyond saying "yay!" a few times on the list/twitter. "I" don't want a particular engine pseudo-type (uninitialized); I honestly don't care about that level of

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-22 Thread Rowan Collins
On 22/09/2018 11:15, Rasmus Schultz wrote: That is, it doesn't assert that a value IS a given type, but that it can only be SET TO a given type. That is literally the same thing - if it can only be set to a given type, it can only BE a given type. Consider this analogy: if I build a house wit

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-22 Thread Rasmus Schultz
I apologize for the long posts, but Larry asked me to comment on this. On Thu, Sep 20, 2018 at 5:52 PM Larry Garfield wrote: > I think the distinction here is that one group is arguing for "state of the > data assertions" while the RFC as implemented is "setter assertion shorthand". The point o

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-21 Thread Larry Garfield
On Friday, September 21, 2018 10:25:50 AM CDT Rasmus Schultz wrote: > On Fri, Sep 21, 2018 at 10:24 AM Lester Caine wrote: > > Ignoring the debate on uninitialized/null ... not all objects ARE > > invariant > > hence nullable types. > > > and there are very good reasons for not setting values fo

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-21 Thread Christoph M. Becker
On 21.09.2018 at 17:25, Rasmus Schultz wrote: > this doesn't provide *any* additional guarantees: > > class Foo { > public int $bar; > } > > $foo = new Foo(); // invalid state allowed > > $foo->bar = 123; // valid state > > $foo->bar = null; // invalid state NOT allowed?! > > [snip] > > In

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-21 Thread Rasmus Schultz
On Fri, Sep 21, 2018 at 10:24 AM Lester Caine wrote: > Ignoring the debate on uninitialized/null ... not all objects ARE > invariant hence nullable types. > and there are very good reasons for not setting values for > everything, but it seems that these types of object are deemed to be > 'bad c

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-21 Thread Rowan Collins
On Fri, 21 Sep 2018 at 15:11, Larry Garfield wrote: > Perhaps another disconnect here is that, in practice, the consumer of an > object property is, in my experience, almost always "me". I almost never > have > public properties on my objects. On the rare occasion I do, it's for a > "struct obj

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-21 Thread Larry Garfield
On Friday, September 21, 2018 4:20:20 AM CDT Rowan Collins wrote: > On Thu, 20 Sep 2018 at 16:52, Larry Garfield wrote: > > I think the distinction here is that one group is arguing for "state of > > the > > data assertions" while the RFC as implemented is "setter assertion > > shorthand". > > Tha

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-21 Thread Rowan Collins
On Thu, 20 Sep 2018 at 16:52, Larry Garfield wrote: > I think the distinction here is that one group is arguing for "state of > the > data assertions" while the RFC as implemented is "setter assertion > shorthand". > That is, it doesn't assert that a value IS a given type, but that it can > only

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-21 Thread Lester Caine
On 21/09/2018 08:58, Rasmus Schultz wrote: No matter how you twist it, uninitialized is the new null. I'm fine with unintialized as an implementation detail that ensures you can't read from properties while the constructor is busy establishing the invariant. I'm not at all fine with unintialize

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-21 Thread Rasmus Schultz
On Thu, Sep 20, 2018 at 4:50 PM Levi Morrison wrote: > > This will be my last reply to this thread. Fundamentally: > > class User { > public ?int $id; > public ?string $preferred_name; > public ?string $username; > } > > ^ This permits null properties at all times. This is acceptab

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-20 Thread Larry Garfield
On Thursday, September 20, 2018 6:50:45 AM CDT Rowan Collins wrote: > On Thu, 20 Sep 2018 at 11:58, Nikita Popov wrote: > > I do not consider it advisable to require a null initialization as a > > "first iteration" of the proposal. Regardless of what our intention might > > be, the effect of such

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-20 Thread Pedro Magalhães
On Thu, Sep 20, 2018 at 12:50 PM Rowan Collins wrote: > Encouraging people to use them gives them a false guarantee, and allowing > them to do so prevents us adding a stricter version of the feature later. > What exactly would prevent us from enforcing it in the future? The way I see it, wheneve

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-20 Thread Sara Golemon
On Thu, Sep 20, 2018 at 9:50 AM, Levi Morrison wrote: > This will be my last reply to this thread. > This will be my first and, God willing, only reply to this thread. > Fundamentally: > > class User { > public int $id; > public string $preferred_name; > public string $username; >

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-20 Thread Levi Morrison
This will be my last reply to this thread. Fundamentally: class User { public ?int $id; public ?string $preferred_name; public ?string $username; } ^ This permits null properties at all times. This is acceptable behavior if null is valid for the domain. It is not valid for this do

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-20 Thread Rasmus Schultz
On Wed, Sep 19, 2018 at 10:04 PM Levi Morrison wrote: > I think this code should be allowed: > >class User { > public int $id; > public string $preferred_name; > public string $username; > } This code is broken - by making the properties non-nullable, you're liter

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-20 Thread Lester Caine
On 19/09/2018 22:58, Marco Pivetta wrote: Also, there are scenarios (discussed in typed properties v1) that make the uninitialized state actually favorable (every serializer ever, like every one, really). I still find a problem with this idea that everything must be initialized. If I am workin

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-20 Thread Rowan Collins
On Thu, 20 Sep 2018 at 11:58, Nikita Popov wrote: > I do not consider it advisable to require a null initialization as a > "first iteration" of the proposal. Regardless of what our intention might > be, the effect of such a restriction will not be "I'm not going to type > this property for now, b

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-20 Thread Nikita Popov
On Wed, Sep 19, 2018 at 2:38 PM Rowan Collins wrote: > On Tue, 11 Sep 2018 at 08:05, Bob Weinand wrote: > > > Hey, > > > > As announced, we are starting the vote on typed properties today. > > > > The voting period is two weeks, until sometime in the evening on Tuesday > > 25-09-2018. > > > > Pl

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-19 Thread Christian Stoller
> -Ursprüngliche Nachricht- > Von: Rowan Collins > Gesendet: Mittwoch, 19. September 2018 23:47 > An: PHP Internals List > Betreff: Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2 > > On 19/09/2018 22:30, Marco Pivetta wrote: > > > > At least the approach

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-19 Thread Marco Pivetta
On Wed, Sep 19, 2018 at 11:46 PM Rowan Collins wrote: > On 19/09/2018 22:30, Marco Pivetta wrote: > > > > At least the approach without nullable properties will lead to a > > Throwable when a read is attempted on an uninitialized object, which > > is still better than nullability checks all over

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-19 Thread Rowan Collins
On 19/09/2018 22:30, Marco Pivetta wrote: At least the approach without nullable properties will lead to a Throwable when a read is attempted on an uninitialized object, which is still better than nullability checks all over the place. Is it? Doesn't it just mean writing this: try {     so

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-19 Thread Marco Pivetta
On Wed, Sep 19, 2018 at 11:17 PM Rowan Collins wrote: > On 19/09/2018 21:04, Levi Morrison wrote: > > I think this code should be allowed: > > > > class User { > > public int $id; > > public string $preferred_name; > > public string $username; > > } > > Why? Wh

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-19 Thread Rowan Collins
On 19/09/2018 21:04, Levi Morrison wrote: I think this code should be allowed: class User { public int $id; public string $preferred_name; public string $username; } Why? What contract is being enforced by that class that is not enforced by this class?

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-19 Thread Levi Morrison
On Wed, Sep 19, 2018 at 1:06 PM Rasmus Schultz wrote: > > On Wed, Sep 19, 2018 at 7:43 PM Rowan Collins wrote: > > > I agree that this is a hard problem, but I don't agree that this decision > > is being made "for now". If we allow "non-nullable but uninitialized" > > properties now, it will be e

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-19 Thread Rasmus Schultz
On Wed, Sep 19, 2018 at 7:43 PM Rowan Collins wrote: > I agree that this is a hard problem, but I don't agree that this decision > is being made "for now". If we allow "non-nullable but uninitialized" > properties now, it will be extremely hard to change their behaviour in > future. I'm with Row

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-19 Thread Rowan Collins
On Wed, 19 Sep 2018 at 16:57, Levi Morrison wrote: > I posit that this code: > > class Foo { > public Foo $foo; > } > > Is superior to this code: > > class Foo { > public ?Foo $foo = null; > } > > If after "initialization" that `$foo` is guaranteed to always contai

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-19 Thread Levi Morrison
On Wed, Sep 19, 2018 at 6:38 AM Rowan Collins wrote: > > On Tue, 11 Sep 2018 at 08:05, Bob Weinand wrote: > > > Hey, > > > > As announced, we are starting the vote on typed properties today. > > > > The voting period is two weeks, until sometime in the evening on Tuesday > > 25-09-2018. > > > > P

Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-19 Thread Rowan Collins
On Tue, 11 Sep 2018 at 08:05, Bob Weinand wrote: > Hey, > > As announced, we are starting the vote on typed properties today. > > The voting period is two weeks, until sometime in the evening on Tuesday > 25-09-2018. > > Please find the RFC at https://wiki.php.net/rfc/typed_properties_v2. > For

[PHP-DEV] [RFC] [VOTE] Typed properties v2

2018-09-11 Thread Bob Weinand
Hey, As announced, we are starting the vote on typed properties today. The voting period is two weeks, until sometime in the evening on Tuesday 25-09-2018. Please find the RFC at https://wiki.php.net/rfc/typed_properties_v2. Bob and Nikita -- PHP Internals - PHP Runtime Development Mailing Lis