-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
Description
Scope of Change
Make classes have a static initializer to be able to initialize static
member variables to a class.
Rationale
Static members of a class can only be initialized to scalars in a class
definition.
Functionality
The static initializer will, if existant for a class, be called by uses().
Implementation:
<?php
// Call static initializer
if (is_callable(array($class, '__static'))) {
call_user_func(array($class, '__static'));
}
?>Example:
<?php
final class Console {
public static $out, $err= NULL;
public static function __static() {
self::$out= new OutputStream(STDOUT);
self::$err= new OutputStream(STDERR);
}
}
?>Dependencies
PHP5
XP2
Changes to uses() functionality.
Related documents
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#39245
http://www.developer.com/java/other/article.php/2238491