Greetings, Internals!

This is my first try to input the proposal, please don't be strict )

All the years with PHP I hate writing classes. The need to prefix EVERY
property and method use looks horrible and writes horrible. So, the
proposal:

Lets introduce directive
declare(simple_classes=1);

This directive will switch interpreter mode, where class declared
properties and methods are accessible as regular variables and functions at
class code.

So, such a fragment

public function __construct() {
   $this->get = $this->clean($_GET);
   $this->post = $this->clean($_POST);
   $this->request = $this->clean($_REQUEST);
   $this->cookie = $this->clean($_COOKIE);
   $this->files = $this->clean($_FILES);
   $this->server = $this->clean($_SERVER);
}

will look so with the proposed directive:

public function __construct() {
   $get = clean($_GET);
   $post = clean($_POST);
   $request = clean($_REQUEST);
   $cookie = clean($_COOKIE);
   $files = clean($_FILES);
   $server = clean($_SERVER);
}

What do we lose with such an approach? The ability to use local variables
named as class properties and the ability to call regular functions, called
as class methods. Both things are super-rarely used and programmers have
the ability to change naming to achieve them.

For static properties/methods, dynamic ones will have an advantage if
naming matches.
Of course, the ability to use usual prefixes will be preserved.

I'm not going to implement this, hoping someone will volunteer if the
reaction is positive.
Also I have some more proposals I will post if this one goes nice.

With best regards,
MaxD

Reply via email to