So now I want to do my first own proposal for a new function in PHP and
I hope doing it right with starting a discussion here first.

The purpose of this suggestion is to introduce a static constructor,
which is called before the first call to class either static or
non-static to initialize some static properties which are needed by the
class.

I think about two different possible syntax to realize that purpose:

Version 1 (similar to Java):

class A {
    private static $var;

    static {
         //Do some code here to initialize self::$var;
    }

}

Version 2 (a new magic method):

class B {
    private static $var;

    private static function __static() {
        //Do some code here to initialize self::$var;
    }
}

My prefered code would be version 2 at the moment.

Looking forward to your feedback,

-- 
DerOetzi

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to