rfc concepts

From: Date: Fri, 14 Apr 2017 01:40:18 +0000
Subject: rfc concepts
Groups: php.internals 
Request: Send a blank email to internals+get-98794@lists.php.net to get a copy of this message
Hi everybody, I've been using php for many years now and it really is a great language. My friend and I were talking about additional things we would want in php - sort of like a wishlist. I came up with 3 things that I think would make php even more awesome and I wanted to share these concepts with this list and I'd love to get feedback. I haven't done any c programming in years but I'd be open to working on these concepts if enough people wanted them. 1. use strict mode ``` class Bar { } class Foo { use strict; } $bar = new Bar; $bar->thing = 1; // no problem $foo = new Foo; $foo->thing = 1; // throws error because thing attribute does not exists ``` 2. type hinting class properties ``` class Foo { public $thing : int; } $foo = new Foo; $foo->thing = 1; // works fine $foo->thing = 'string'; // throws Typehint ``` 3. auto properties ``` class Foo { private $thing1 { get, set }; private $thing2 { get }; private $thing3 { set }; } $foo = new Foo; $foo->thing1 = 'asdf'; echo $foo->thing1; // echos 'asdf' $foo->thing2 = 'asdf'; // throws error because no setter $foo->thing3 = ''asdf'; // sets thing3 echo $foo->thing3; // throws error because no getter ``` I'd love to hear what you all have to say about these things. Thanks in advance for your feedback and time! - Kelt

« previous php.internals (#98794) next »