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.)

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to