Welcome! Log In Create A New Profile

Advanced

[PHP-DEV] [RFC] Typed Properties

Posted by Nikita Popov 
Nikita Popov
[PHP-DEV] [RFC] Typed Properties
June 21, 2018 12:10AM
Hi internals,

Bob and I would like to present a new typed properties proposal for your
consideration:

https://wiki.php.net/rfc/typed_properties_v2

The proposal allows you to annotate properties with types, which are
enforced at runtime. Unlike the previous RFC on this topic, the new
proposal also supports typed static properties and references to typed
properties.

Please note that next to the main body, the RFC also contains an
"Alternatives" section, which explores the problem space and considers
trade-offs of different behaviors in some detail.

Finally, while this RFC currently targets PHP 7.3, this is a large and
complex proposal and we may not be able to meet the deadline, in which case
this feature will go into the next PHP version.

Regards,
Nikita
Marco Pivetta
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 01:20AM
Hi Nikita, Bob,

On Wed, 20 Jun 2018, 23:59 Nikita Popov, <[email protected]> wrote:

> Hi internals,
>
> Bob and I would like to present a new typed properties proposal for your
> consideration:
>
> https://wiki.php.net/rfc/typed_properties_v2
>
> The proposal allows you to annotate properties with types, which are
> enforced at runtime. Unlike the previous RFC on this topic, the new
> proposal also supports typed static properties and references to typed
> properties.
>
> Please note that next to the main body, the RFC also contains an
> "Alternatives" section, which explores the problem space and considers
> trade-offs of different behaviors in some detail.
>
> Finally, while this RFC currently targets PHP 7.3, this is a large and
> complex proposal and we may not be able to meet the deadline, in which case
> this feature will go into the next PHP version.
>
> Regards,
> Nikita
>

This is awesome news! I skimmed over the proposal and it is extremely well
thought out, and almost everything that was causing a -1 on the previous
RFC is gone: kudos!

The last bit that is missing is the `__get` kink, mostly because `__get()`
is "squishy by design". Still, the fact that references are properly typed
mitigates the issue for my shady use-cases (I've got a reputation there),
so I'm quite happy with an implicit magic type check. One thing I couldn't
find is whether this magic check is also enforced when calling `__get()`
explicitly, and not via the guards in the engine.

Is the current development branch usable for testing something locally? I
can't see any obvious mistakes here, but I just wanted to try this out with
some of the more obscure libraries that touch property state at the level
that is covered by this RFC.

>
Bob Weinand
RE: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 01:50AM
> From: Marco Pivetta <[email protected]>
> Sent: Thursday, June 21, 2018 01:10
> To: Nikita Popov <[email protected]>
> Cc: PHP Internals List <[email protected]>
> Subject: Re: [PHP-DEV] [RFC] Typed Properties
>
> Hi Nikita, Bob,
>
> On Wed, 20 Jun 2018, 23:59 Nikita Popov, <[email protected]> wrote:
>
> > Hi internals,
> >
> > Bob and I would like to present a new typed properties proposal for
> > your
> > consideration:
> >
> >
> >
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki
> >
> .php.net%2Frfc%2Ftyped_properties_v2&data=02%7C01%7C%7Ca414560298
> 8f413
> >
> 3a54808d5d7031564%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C6
> 366513
> >
> 30591392793&sdata=M70Asi8WqXbP6icXeVsdsBuI1GiK9UjgHj9EoZHX4%2Bg
> %3D&res
> > erved=0
> >
> > The proposal allows you to annotate properties with types, which are
> > enforced at runtime. Unlike the previous RFC on this topic, the new
> > proposal also supports typed static properties and references to typed
> > properties.
> >
> > Please note that next to the main body, the RFC also contains an
> > "Alternatives" section, which explores the problem space and considers
> > trade-offs of different behaviors in some detail.
> >
> > Finally, while this RFC currently targets PHP 7.3, this is a large and
> > complex proposal and we may not be able to meet the deadline, in which
> > case this feature will go into the next PHP version.
> >
> > Regards,
> > Nikita
> >
>
> This is awesome news! I skimmed over the proposal and it is extremely well
> thought out, and almost everything that was causing a -1 on the previous RFC
> is gone: kudos!
>
> The last bit that is missing is the `__get` kink, mostly because `__get()` is
> "squishy by design". Still, the fact that references are properly typed
> mitigates the issue for my shady use-cases (I've got a reputation there), so
> I'm quite happy with an implicit magic type check. One thing I couldn't find is
> whether this magic check is also enforced when calling `__get()` explicitly,
> and not via the guards in the engine.
>
> Is the current development branch usable for testing something locally? I
> can't see any obvious mistakes here, but I just wanted to try this out with
> some of the more obscure libraries that touch property state at the level that
> is covered by this RFC.

__get() is a very normal function - the special semantics are generally only applied if called for overloaded properties. So obviously, there is no check applied if you call it directly.

The dev branch is stable for testing, yes. Would appreciate reports about any bugs you find.

Bob
Marco Pivetta
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 09:50AM
Hi Bob,

On Thu, Jun 21, 2018 at 1:42 AM, Bob Weinand <[email protected]> wrote:

> __get() is a very normal function - the special semantics are generally
> only applied if called for overloaded properties. So obviously, there is no
> check applied if you call it directly.
>

Thanks!

The dev branch is stable for testing, yes. Would appreciate reports about
> any bugs you find.
>

That shall be my weekend task. I'll stress this stuff in the ProxyManager
test suite: if it passes there, it really is rock-solid.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/
Gabriel Caruso
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 03:20PM
Nikita, Bob

I'd love to thank you and everyone involved on this one. Types properties
on PHP is something that we tried before, but due to a number of issues, we
didn't make it. Unfortunately, I don't have the knowledge to help in the
implementation, but I'd like to drop some comments about the syntax.

As described in https://wiki.php.net/rfc/typed_properties_v2#syntax, I
think we should only allow
class Example {
public int $num;
public string $name;
}

Allow the `:` variant (`public $num: int;`) would bring a lot of doubts for
new users, and the `{visibility} {type} {name}` is prett consistence in
other languages.

Again, thanks for this amazing work, and let's make for the next PHP
version :)
--
Gabriel Caruso
Sara Golemon
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 03:50PM
On Wed, Jun 20, 2018 at 4:59 PM, Nikita Popov <[email protected]> wrote:
> Bob and I would like to present a new typed properties proposal for your
> consideration:
>
> https://wiki.php.net/rfc/typed_properties_v2
>
At a glance, yes please. Will dig in deeper when I'm not busy moving.

> Finally, while this RFC currently targets PHP 7.3, this is a large and
> complex proposal and we may not be able to meet the deadline, in which case
> this feature will go into the next PHP version.
>
IMO it's already too late for something of this size to realistically
make 7.3. If a vote comes up targeting 7.3 I intend to vote no purely
on procedural grounds. A 7.4 target will quite probably see a yes from
me, however.

-Sara

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Nicolas Grekas
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 04:10PM
Hi Nikita, Bob,

https://wiki.php.net/rfc/typed_properties_v2
>

This is really well thought and written, sounds really primising.
I agree that "References without intrinsic type" look the best.

I anticipate one case on Symfony VarDumper that will break on typed
references:

the only way to detect references is by injecting cookies in arrays, e.g.:
$a = (array) $someObjectOrArray;
$cookie = new stdClass();
$b = $a;
$b[$k] = $cookie;
if ($a[$k] === $cookie) {
// Here we have a reference
}

I'd need to wrap the assignation in a try/catch now:
try {
$b[$k] = $cookie;
} catch (TypeError $e) {
// Here we have a typed reference that doesn't accept stdclass
}

So far so good I suppose. I just wanted to raise the point if it matters at
all.

Thank you,
Nicolas
Bob Weinand
RE: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 04:20PM
Hey Sara,

> From: php@golemon.com <[email protected]> On Behalf Of Sara Golemon
> Sent: Thursday, June 21, 2018 15:43
> To: Nikita Popov <[email protected]>
> Cc: PHP internals <[email protected]>
> Subject: Re: [PHP-DEV] [RFC] Typed Properties
>
> On Wed, Jun 20, 2018 at 4:59 PM, Nikita Popov <[email protected]>
> wrote:
> > Finally, while this RFC currently targets PHP 7.3, this is a large and
> > complex proposal and we may not be able to meet the deadline, in which
> > case this feature will go into the next PHP version.
> >
> IMO it's already too late for something of this size to realistically make 7.3. If a
> vote comes up targeting 7.3 I intend to vote no purely on procedural
> grounds. A 7.4 target will quite probably see a yes from me, however.
>
> -Sara

I agree that we're pretty late to the party, however I see typed properties being a pretty central feature to the PHP 7.3 feature set then, just because of its size.
I think it may be worth pushing the release of 7.3 a few weeks back instead, if we decide to have this feature make it into PHP 7.3.

The current feature set of PHP 7.3 is pretty small, and I consider it a good idea to see how typed properties play out in 7.3 before we consider other typesystem improvements.
Waiting a year more would give us less insight into what people are still missing and wishing for.

Thus I don't consider it a very good idea to be too conservative here.

An other option would be though, to include a secondary vote "7.3, 7.3 and a little delay or 7.4".

Bob
Bob Weinand
RE: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 04:30PM
> From: nicolas.grekas@gmail.com <[email protected]> On Behalf Of
> Nicolas Grekas
> Sent: Thursday, June 21, 2018 16:08
> To: Nikita Popov <[email protected]>
> Cc: PHP internals <[email protected]>
> Subject: Re: [PHP-DEV] [RFC] Typed Properties
>
> Hi Nikita, Bob,
>
> I anticipate one case on Symfony VarDumper that will break on typed
> references:
>
> the only way to detect references is by injecting cookies in arrays, e.g.:
> $a = (array) $someObjectOrArray;
> $cookie = new stdClass();
> $b = $a;
> $b[$k] = $cookie;
> if ($a[$k] === $cookie) {
> // Here we have a reference
> }
>
> I'd need to wrap the assignation in a try/catch now:
> try {
> $b[$k] = $cookie;
> } catch (TypeError $e) {
> // Here we have a typed reference that doesn't accept stdclass }
>
> So far so good I suppose. I just wanted to raise the point if it matters at all.
>
> Thank you,
> Nicolas

We haven't implemented that (yet?), but I considered something like a ReflectionReference class, which will give you the referencing properties via ReflectionProperty instances.
The implementation easily allows for that as it tracks the referencing properties for calculating the allowed types.

I didn't consider it essential for the initial implementation in 7.3 and thus hadn't written it on the TODO list for that RFC.
But if you think it's important (it has real world needs), then we may consider extending the RFC to include that.

Bob
Sara Golemon
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 05:00PM
On Thu, Jun 21, 2018 at 9:13 AM, Bob Weinand <[email protected]> wrote:
> I agree that we're pretty late to the party, however I see typed properties being
> a pretty central feature to the PHP 7.3 feature set then, just because of its size.
> I think it may be worth pushing the release of 7.3 a few weeks back instead,
> if we decide to have this feature make it into PHP 7.3.
>
To quote Nikita: https://twitter.com/nikita_ppv/status/1009800042629271553
"Just to make sure we're on the same page: What I mean is that an
initial implementation *has* to land before branching, but has a lot
of time to bake afterwards. If the implementation is not good enough
to land before branching, then it can't go into 7.3."

I'm fine with that take on it. If we can get to consensus quickly
enough to get a vote closed by the end of July (which, incidentally,
allows for a bit past the feature freeze date), then I can get behind
it without a additional delay. If we CAN'T close the vote by then,
and we're not willing to push the dates out to accommodate, them
that's where my 'no' comes from.

Last year at this time, a certain new extension rolled right up to the
wire and bit beyond and it was a mess. Half the post-branch fixes and
API changes didn't even hit the 7.2 branch (without messy
cherry-picks) because the committer wasn't paying attention or
responding to attempts at communication. Yes, you and Niki are much
better plugged in, but other stuff comes up when you leave things for
the last minute, and I don't want to see 7.3 have issues as well.

-Sara

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Christoph M. Becker
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 05:20PM
On 21.06.2018 at 16:50, Sara Golemon wrote:

> On Thu, Jun 21, 2018 at 9:13 AM, Bob Weinand <[email protected]> wrote:
>
>> I agree that we're pretty late to the party, however I see typed properties being
>> a pretty central feature to the PHP 7.3 feature set then, just because of its size.
>> I think it may be worth pushing the release of 7.3 a few weeks back instead,
>> if we decide to have this feature make it into PHP 7.3.
>
> To quote Nikita: https://twitter.com/nikita_ppv/status/1009800042629271553
> "Just to make sure we're on the same page: What I mean is that an
> initial implementation *has* to land before branching, but has a lot
> of time to bake afterwards. If the implementation is not good enough
> to land before branching, then it can't go into 7.3."
>
> I'm fine with that take on it. If we can get to consensus quickly
> enough to get a vote closed by the end of July (which, incidentally,
> allows for a bit past the feature freeze date), then I can get behind
> it without a additional delay. If we CAN'T close the vote by then,
> and we're not willing to push the dates out to accommodate, them
> that's where my 'no' comes from.

Note that branching of PHP-7.3 is presently scheduled for July, 17th,
though, see https://wiki.php.net/todo/php73.

--
Christoph M. Becker

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Stephen Reay
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 05:40PM
> On 21 Jun 2018, at 4:59 am, Nikita Popov <[email protected]> wrote:
>
> Hi internals,
>
> Bob and I would like to present a new typed properties proposal for your
> consideration:
>
> https://wiki.php.net/rfc/typed_properties_v2
>
> The proposal allows you to annotate properties with types, which are
> enforced at runtime. Unlike the previous RFC on this topic, the new
> proposal also supports typed static properties and references to typed
> properties.
>
> Please note that next to the main body, the RFC also contains an
> "Alternatives" section, which explores the problem space and considers
> trade-offs of different behaviors in some detail.
>
> Finally, while this RFC currently targets PHP 7.3, this is a large and
> complex proposal and we may not be able to meet the deadline, in which case
> this feature will go into the next PHP version.
>
> Regards,
> Nikita

Hi Nikita/Bob,

I’m *really* happy to see someone taking another stab at this.

My only ‘input’ as such, is around the decision to omit `callable`. Given that we *have* Closures (thus allowing a developer to explicitly state that they want something they can invoke regardless of context, if they so wish), I think `callable` should be a valid type for properties too. The language doesn’t prevent floating point math because you might not get the result you expect - it simply documents and warns people that they need to be aware of some inherent attributes of the feature.


Whether that particular aspect of the RFC changes or not, again, thank you both for working on this!


Cheers

Stephen




--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Larry Garfield
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 06:20PM
On Wednesday, June 20, 2018 4:59:33 PM CDT Nikita Popov wrote:
> Hi internals,
>
> Bob and I would like to present a new typed properties proposal for your
> consideration:
>
> https://wiki.php.net/rfc/typed_properties_v2
>
> The proposal allows you to annotate properties with types, which are
> enforced at runtime. Unlike the previous RFC on this topic, the new
> proposal also supports typed static properties and references to typed
> properties.
>
> Please note that next to the main body, the RFC also contains an
> "Alternatives" section, which explores the problem space and considers
> trade-offs of different behaviors in some detail.
>
> Finally, while this RFC currently targets PHP 7.3, this is a large and
> complex proposal and we may not be able to meet the deadline, in which case
> this feature will go into the next PHP version.
>
> Regards,
> Nikita

I am in full squee-mode over this. I'd love to see it, in whichever version
is deemed appropriate. (7.3 would be nice, 7.4 would still be acceptable.)

Questions along the way:

* There was at one point in time a related RFC regarding property accessors
(dedicated getter/setter methods for each property that get called
automatically). That was rejected largely on performance grounds at the time.
Would this RFC 1) Hinder returning to property accessors in the future 2) Help
resolve some of the issues there indirectly 3) Have no effect on the viability
of accessors?

* How much compile time detection is possible? Eg, the following code would
clearly never work:

class Foo {
protected int $val;

public function setVal(string $val) : void {
$this->val = $val;
}

public function getVal() : string {
return $this->val;
}
}

(I suppose technically it might work in coercive mode, but not strict mode?)
Would this be a compile time error, or a runtime error when you first try to
run it? (I'm assuming IDE linters would be able to catch it, but if the
engine could too that's even better.)
Patrick ALLAERT
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 06:30PM
Le jeu. 21 juin 2018 à 00:00, Nikita Popov <[email protected]> a écrit :

> Hi internals,
>
> Bob and I would like to present a new typed properties proposal for your
> consideration:
>
> https://wiki.php.net/rfc/typed_prwould some benefitsoperties_v2
> https://wiki.php.net/rfc/typed_properties_v2
>
> The proposal allows you to annotate properties with types, which are
> enforced at runtime. Unlike the previous RFC on this topic, the new
> proposal also supports typed static properties and references to typed
> properties.
>
> Please note that next to the main body, the RFC also contains an
> "Alternatives" section, which explores the problem space and considers
> trade-offs of different behaviors in some detail.
>
> Finally, while this RFC currently targets PHP 7.3, this is a large and
> complex proposal and we may not be able to meet the deadline, in which case
> this feature will go into the next PHP version.
>
> Regards,
> Nikita
>

Hi Nikita, Bob,

Congrats for the awesome job! It looks very good.

My only concern is about regular variables, not bound to any classes. Isn't
that a little bit inconsistent that classes properties could be typed, but
not a regular variable in the middle of a function/method/plain "script"
file?

I would see some benefit doing something like:

string $content = file_get_contents("/foo/bar");

(Sorry if this has been raised already in the past)

Patrick
Bob Weinand
RE: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 06:30PM
Hey Larry,

> From: Larry Garfield <[email protected]>
> Sent: Thursday, June 21, 2018 18:17
> To: internals@lists.php.net
> Subject: Re: [PHP-DEV] [RFC] Typed Properties
> Questions along the way:
>
> * There was at one point in time a related RFC regarding property
accessors
> (dedicated getter/setter methods for each property that get called
> automatically). That was rejected largely on performance grounds at the
> time.
> Would this RFC 1) Hinder returning to property accessors in the future 2)
Help
> resolve some of the issues there indirectly 3) Have no effect on the
viability
> of accessors?

I don't think it'll hinder them, accessors are pretty orthogonal to this
feature. Sure they'll have to cast the returned value according to the
property type, but that's no different than a return type and just like
__get() works in this RFC. But that's already about the complete impact.
An accessor ultimately isn't really any more expensive than a __get() call
at a fundamental level.

> * How much compile time detection is possible? Eg, the following code
> would clearly never work:
>
> class Foo {
> protected int $val;
>
> public function setVal(string $val) : void {
> $this->val = $val;
> }
>
> public function getVal() : string {
> return $this->val;
> }
> }
>
> (I suppose technically it might work in coercive mode, but not strict
mode?)
> Would this be a compile time error, or a runtime error when you first try
to
> run it? (I'm assuming IDE linters would be able to catch it, but if the
engine
> could too that's even better.)

PHP core generally does no type analysis at all at compile-time. Any type
analysis is happening in opcache/Optimizer and until now opache/Optimizer
hasn't chosen to warn if it encounters impossible conditions. This may or
may not change in future, but isn't related here.
So it is a runtime error; any other behavior would be out of scope of this
RFC.

Bob


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Bob Weinand
RE: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 06:40PM
> From: Patrick ALLAERT <[email protected]>
> Sent: Thursday, June 21, 2018 18:25
> To: Nikita Popov <[email protected]>
> Cc: PHP internals <[email protected]>
> Subject: Re: [PHP-DEV] [RFC] Typed Properties
>
> My only concern is about regular variables, not bound to any classes. Isn't
> that a little bit inconsistent that classes properties could be typed, but not a
> regular variable in the middle of a function/method/plain "script"
> file?
>
> I would see some benefit doing something like:
>
> string $content = file_get_contents("/foo/bar");
>
> (Sorry if this has been raised already in the past)
>
> Patrick

Hey Patrick,

It is an option to allow this in future, but for now I consider this too far out of scope, possiv and it will, in particular also require greater changes to the engine - I guess it would about double the size of the patch again. (and this patch is already everything, but small.)

This feature would as well be possibly not uncontroversial, needs thinking about the scoping of the variable type (Lifetime until unset()? Lifetime until function end? etc.) - I definitely would not go too far with this RFC. The topic is typed properties and that's what the scope of the RFC shall also be.

Bob
Stanislav Malyshev
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 07:00PM
Hi!

> Finally, while this RFC currently targets PHP 7.3, this is a large and
> complex proposal and we may not be able to meet the deadline, in which case
> this feature will go into the next PHP version.

I haven't read the RFC yet, so I just want to address this point. I
think unless the RFC is exceptionally perfect and produces universal
acceptance instantly (may be exactly the case, as I said, I haven't read
it :), we should default to targeting 7.4. 7.3 release cycle has already
began, and we're pretty close to feature freeze. I think it's better not
to feel pressured by the deadline for 7.3 - especially given that summer
is a vacation season and some people may be slow to give feedback due to
that - and let it work through. Rushing with it may cause us (even
unconsciously) to cut corners, not have discussions that should be had,
not test it as thoroughly, etc. Especially on a thing of this magnitude.

Note I am not opposed to having it in 7.3 if it all works out better and
faster than my cautiously pessimistic assumptions - I just think we
should not presume it'd necessarily be the case and feel the pressure to
do it at the cost of more thorough work on it.

--
Stas Malyshev
smalyshev@gmail.com

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Nicolas Grekas
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 07:00PM
> something like a ReflectionReference class, which will give you the
> referencing properties via ReflectionProperty instances
>

I may not have the object when walking on data structures, but only the
reference (in an array.)
It could work this way I suppose: `ReflectionReference::fromArray(array
$array, string $key): ?ReflectionReference`,
returning `null` when `$array[$key]` is not a reference, and the instance
otherwise.
WDYT?
Bob Weinand
RE: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 07:30PM
From: nicolas.grekas@gmail.com <[email protected]> On Behalf Of Nicolas Grekas
Sent: Thursday, June 21, 2018 18:51
To: Bob Weinand <[email protected]>
Cc: Nikita Popov <[email protected]>; PHP internals <[email protected]>
Subject: Re: [PHP-DEV] [RFC] Typed Properties


something like a ReflectionReference class, which will give you the referencing properties via ReflectionProperty instances

I may not have the object when walking on data structures, but only the reference (in an array.)
It could work this way I suppose: `ReflectionReference::fromArray(array $array, string $key): ?ReflectionReference`,
returning `null` when `$array[$key]` is not a reference, and the instance otherwise.
WDYT?

I imagined a ReflectionReference::__construct(&$value), with methods getRefcount() : int and getReferencingProperties() : ReflectionProperty[]

To check whether it’s a reference at all, you’d use if ((new ReflectionReference($array[$key]))->getRefcount() > 2) { /* is ref */ } else { /* not a ref */ }, for computing the allowed types you’d intersect the types of the ReflectionProperties returned by getReferencingProperties().

Bob
Nicolas Grekas
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 07:40PM
>
> if ((new ReflectionReference($array[$key]))->getRefcount() > 2) { /* is
> ref */ } else { /* not a ref */ }, for computing the allowed types you’d
> intersect the types of the ReflectionProperties returned by
> getReferencingProperties().
>


Would work also I suppose, sounds good thanks for caring :)
Dan Ackroyd
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 08:00PM
On 21 June 2018 at 17:49, Stanislav Malyshev <[email protected]> wrote:
>
> I think it's better not
> to feel pressured by the deadline for 7.3

The deadline isn't a deadline - it's just the current consensus for
when we'd like to see 7.3 released.

If people thought this RFC needed more time but would make PHP 7.3 a
lot better, would there be any harm in moving the 7.3 release back a
few weeks?

cheers
Dan

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Sara Golemon
Re: [PHP-DEV] [RFC] Typed Properties
June 21, 2018 08:50PM
On Thu, Jun 21, 2018 at 12:57 PM, Dan Ackroyd <[email protected]> wrote:
> On 21 June 2018 at 17:49, Stanislav Malyshev <[email protected]> wrote:
>>
>> I think it's better not
>> to feel pressured by the deadline for 7.3
>
> The deadline isn't a deadline - it's just the current consensus for
> when we'd like to see 7.3 released.
>
> If people thought this RFC needed more time but would make PHP 7.3 a
> lot better, would there be any harm in moving the 7.3 release back a
> few weeks?
>
Sure. I would *far* prefer that over jamming this in without any
change in the GA date. We have to be careful about exactly when we
push it to. The current GA date wasn't chosen arbitrarily, but with
concern regarding the proximity to the holiday season.

-Sara

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Rowan Collins
Re: [PHP-DEV] [RFC] Typed Properties
June 24, 2018 11:10PM
On 20/06/2018 22:59, Nikita Popov wrote:
> Hi internals,
>
> Bob and I would like to present a new typed properties proposal for your
> consideration:
>
> https://wiki.php.net/rfc/typed_properties_v2


Hi Nikita, and Bob,

Thanks for the extremely thorough RFC. I think you've made a great case
for the decisions you've taken, and it's reassuring to see so many
edge-cases considered. In particular, the well-considered support for
references makes it feel like a complete feature. The lack of "callable"
is the only caveat that might surprise users, but I think it's
justified, because we can't actually guarantee that something that was
callable when it went in will be callable when it comes out.

One thing that I would be interested to hear, is whether any of the
groundwork laid here - particularly for typed references - would be
useful if we were to introduce typed local variables in future. I don't
want to derail the thread discussing exactly how this would work, but
does anyone have a general hunch of whether this "brings us closer", IF
we decided that was where we wanted to go?

Regards,

--
Rowan Collins
[IMSoP]


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Marco Pivetta
Re: [PHP-DEV] [RFC] Typed Properties
June 26, 2018 01:50PM
I'm not sure why the mailing list is not picking up my messages, but TL:DR;
is that I spent the weekend testing all of its corners, and the patch works
flawlessly and can be pushed forward IMO.

It works consistently with current PHP semantics and significantly improves
the language, so let's make this happen :-)


Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On Sun, Jun 24, 2018 at 11:05 PM, Rowan Collins <[email protected]>
wrote:

> On 20/06/2018 22:59, Nikita Popov wrote:
>
>> Hi internals,
>>
>> Bob and I would like to present a new typed properties proposal for your
>> consideration:
>>
>> https://wiki.php.net/rfc/typed_properties_v2
>>
>
>
> Hi Nikita, and Bob,
>
> Thanks for the extremely thorough RFC. I think you've made a great case
> for the decisions you've taken, and it's reassuring to see so many
> edge-cases considered. In particular, the well-considered support for
> references makes it feel like a complete feature. The lack of "callable" is
> the only caveat that might surprise users, but I think it's justified,
> because we can't actually guarantee that something that was callable when
> it went in will be callable when it comes out.
>
> One thing that I would be interested to hear, is whether any of the
> groundwork laid here - particularly for typed references - would be useful
> if we were to introduce typed local variables in future. I don't want to
> derail the thread discussing exactly how this would work, but does anyone
> have a general hunch of whether this "brings us closer", IF we decided that
> was where we wanted to go?
>
> Regards,
>
> --
> Rowan Collins
> [IMSoP]
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Björn Larsson
Re: [PHP-DEV] [RFC] Typed Properties
July 05, 2018 11:20AM
Den 2018-06-21 kl. 20:41, skrev Sara Golemon:

> On Thu, Jun 21, 2018 at 12:57 PM, Dan Ackroyd <[email protected]> wrote:
>> On 21 June 2018 at 17:49, Stanislav Malyshev <[email protected]> wrote:
>>> I think it's better not
>>> to feel pressured by the deadline for 7.3
>> The deadline isn't a deadline - it's just the current consensus for
>> when we'd like to see 7.3 released.
>>
>> If people thought this RFC needed more time but would make PHP 7.3 a
>> lot better, would there be any harm in moving the 7.3 release back a
>> few weeks?
>>
> Sure. I would *far* prefer that over jamming this in without any
> change in the GA date. We have to be careful about exactly when we
> push it to. The current GA date wasn't chosen arbitrarily, but with
> concern regarding the proximity to the holiday season.
>
> -Sara
>
Hi,

Any chance getting this into 7.3? I think it would be a
great addition. According to Marco Pivettas mail from
26/6 it works flawlessly.

Givven the current discussion about 8.0 it feels a bit
way off having this to wait for this feature until 2020.

r//Björn Larsson

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Marco Pivetta
Re: [PHP-DEV] [RFC] Typed Properties
July 05, 2018 11:50AM
On Thu, Jul 5, 2018 at 11:09 AM, Björn Larsson <[email protected]>
wrote:

> it feels a bit
> way off having this to wait for this feature until 2020.
>

I didn't realise this. Now that I did:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARGH!
Nikita Popov
Re: [PHP-DEV] [RFC] Typed Properties
July 05, 2018 12:20PM
On Thu, Jul 5, 2018 at 11:09 AM, Björn Larsson <[email protected]>
wrote:

> Den 2018-06-21 kl. 20:41, skrev Sara Golemon:
>
> On Thu, Jun 21, 2018 at 12:57 PM, Dan Ackroyd <[email protected]>
>> wrote:
>>
>>> On 21 June 2018 at 17:49, Stanislav Malyshev <[email protected]>
>>> wrote:
>>>
>>>> I think it's better not
>>>> to feel pressured by the deadline for 7.3
>>>>
>>> The deadline isn't a deadline - it's just the current consensus for
>>> when we'd like to see 7.3 released.
>>>
>>> If people thought this RFC needed more time but would make PHP 7.3 a
>>> lot better, would there be any harm in moving the 7.3 release back a
>>> few weeks?
>>>
>>> Sure. I would *far* prefer that over jamming this in without any
>> change in the GA date. We have to be careful about exactly when we
>> push it to. The current GA date wasn't chosen arbitrarily, but with
>> concern regarding the proximity to the holiday season.
>>
>> -Sara
>>
>> Hi,
>
> Any chance getting this into 7.3? I think it would be a
> great addition. According to Marco Pivettas mail from
> 26/6 it works flawlessly.
>
> Givven the current discussion about 8.0 it feels a bit
> way off having this to wait for this feature until 2020.
>

We have recently finished the last major change to the implementation
(switching to https://wiki.php.net/rfc/typed_properties_v2#
references_without_intrinsic_type -- the RFC still needs to be updated for
this change). However, there is still quite a bit of refactoring and polish
to be done. Unfortunately, we are running out of time. There are already
less than two weeks until the currently planned feature freeze, before
which the vote must be finished and the implementation merged. For such a
major feature, I don't like the idea of rushing the vote to such a degree.

As such, I think that this feature can only go into 7.3 if the release
schedule is adjusted. Extending the schedule by another 2-week alpha cycle
would be sufficient to land this proposal in PHP 7.3. Otherwise it will
just have to wait a few years for the next applicable release (based on
recent discussions, it's not entirely clear whether that would be PHP 7.4
or 8.0).

Regards,
Nikita
Sebastian Bergmann
Re: [PHP-DEV] [RFC] Typed Properties
July 05, 2018 12:30PM
> As such, I think that this feature can only go into 7.3 if the release
> schedule is adjusted. Extending the schedule by another 2-week alpha cycle
> would be sufficient to land this proposal in PHP 7.3.

+1

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Björn Larsson
Re: [PHP-DEV] [RFC] Typed Properties
July 05, 2018 01:10PM
Den 2018-07-05 kl. 12:17, skrev Nikita Popov:

> On Thu, Jul 5, 2018 at 11:09 AM, Björn Larsson <[email protected]>
> wrote:
>
>> Den 2018-06-21 kl. 20:41, skrev Sara Golemon:
>>
>> On Thu, Jun 21, 2018 at 12:57 PM, Dan Ackroyd <[email protected]>
>>> wrote:
>>>
>>>> On 21 June 2018 at 17:49, Stanislav Malyshev <[email protected]>
>>>> wrote:
>>>>
>>>>> I think it's better not
>>>>> to feel pressured by the deadline for 7.3
>>>>>
>>>> The deadline isn't a deadline - it's just the current consensus for
>>>> when we'd like to see 7.3 released.
>>>>
>>>> If people thought this RFC needed more time but would make PHP 7.3 a
>>>> lot better, would there be any harm in moving the 7.3 release back a
>>>> few weeks?
>>>>
>>>> Sure. I would *far* prefer that over jamming this in without any
>>> change in the GA date. We have to be careful about exactly when we
>>> push it to. The current GA date wasn't chosen arbitrarily, but with
>>> concern regarding the proximity to the holiday season.
>>>
>>> -Sara
>>>
>>> Hi,
>> Any chance getting this into 7.3? I think it would be a
>> great addition. According to Marco Pivettas mail from
>> 26/6 it works flawlessly.
>>
>> Givven the current discussion about 8.0 it feels a bit
>> way off having this to wait for this feature until 2020.
>>
> We have recently finished the last major change to the implementation
> (switching to https://wiki.php.net/rfc/typed_properties_v2#
> references_without_intrinsic_type -- the RFC still needs to be updated for
> this change). However, there is still quite a bit of refactoring and polish
> to be done. Unfortunately, we are running out of time. There are already
> less than two weeks until the currently planned feature freeze, before
> which the vote must be finished and the implementation merged. For such a
> major feature, I don't like the idea of rushing the vote to such a degree.
>
> As such, I think that this feature can only go into 7.3 if the release
> schedule is adjusted. Extending the schedule by another 2-week alpha cycle
> would be sufficient to land this proposal in PHP 7.3. Otherwise it will
> just have to wait a few years for the next applicable release (based on
> recent discussions, it's not entirely clear whether that would be PHP 7.4
> or 8.0).
>
> Regards,
> Nikita
>
Sounds like the RMs for 7.3 need to weigh in on this.
For me I think it's worthwhile delaying two weeks, +1.

I also think that now we have an implementation that
works. For 8.0 the changes are not known, so delaying
could imply that implementation needs to be reworked,
i.e. a bit of double work.

r//Björn Larsson

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Christoph M. Becker
Re: [PHP-DEV] [RFC] Typed Properties
July 05, 2018 01:30PM
On 05.07.2018 at 13:05, Björn Larsson wrote:

> Den 2018-07-05 kl. 12:17, skrev Nikita Popov:
>
>> On Thu, Jul 5, 2018 at 11:09 AM, Björn Larsson
>> <[email protected]>
>> wrote:
>>
>>> Den 2018-06-21 kl. 20:41, skrev Sara Golemon:
>>>
>>> On Thu, Jun 21, 2018 at 12:57 PM, Dan Ackroyd <[email protected]>
>>>> wrote:
>>>>
>>>>> On 21 June 2018 at 17:49, Stanislav Malyshev <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> I think it's better not
>>>>>> to feel pressured by the deadline for 7.3
>>>>>>
>>>>> The deadline isn't a deadline - it's just the current consensus for
>>>>> when we'd like to see 7.3 released.
>>>>>
>>>>> If people thought this RFC needed more time but would make PHP 7.3 a
>>>>> lot better, would there be any harm in moving the 7.3 release back a
>>>>> few weeks?
>>>>>
>>>>> Sure.  I would *far* prefer that over jamming this in without any
>>>> change in the GA date.  We have to be careful about exactly when we
>>>> push it to.  The current GA date wasn't chosen arbitrarily, but with
>>>> concern regarding the proximity to the holiday season.
>>>
>>> Any chance getting this into 7.3? I think it would be a
>>> great addition. According to Marco Pivettas mail from
>>> 26/6 it works flawlessly.
>>>
>>> Givven the current discussion about 8.0 it feels a bit
>>> way off having this to wait for this feature until 2020.
>>
>> We have recently finished the last major change to the implementation
>> (switching to https://wiki.php.net/rfc/typed_properties_v2#
>> references_without_intrinsic_type -- the RFC still needs to be updated
>> for
>> this change). However, there is still quite a bit of refactoring and
>> polish
>> to be done. Unfortunately, we are running out of time. There are already
>> less than two weeks until the currently planned feature freeze, before
>> which the vote must be finished and the implementation merged. For such a
>> major feature, I don't like the idea of rushing the vote to such a
>> degree.
>>
>> As such, I think that this feature can only go into 7.3 if the release
>> schedule is adjusted. Extending the schedule by another 2-week alpha
>> cycle
>> would be sufficient to land this proposal in PHP 7.3. Otherwise it will
>> just have to wait a few years for the next applicable release (based on
>> recent discussions, it's not entirely clear whether that would be PHP 7.4
>> or 8.0).
>
> Sounds like the RMs for 7.3 need to weigh in on this.
> For me I think it's worthwhile delaying two weeks, +1.

Is there any precendent for postponing feature freeze during the (late)
alpha stage?

--
Christoph M. Becker

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Sorry, only registered users may post in this forum.

Click here to login