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