> -----Original Message-----
> From: Pete Boere [mailto:p...@the-echoplex.net] 
> Sent: 22 January 2013 12:30
> To: internals@lists.php.net
> Subject: [PHP-DEV] __init magic method
> 
> Has there ever been any discussion on an __init magic method 
> for bootstraping static properties on class load?
> 
> The usual solution I come up with is manually calling an init 
> method post class definition, which works, though I'd call it 
> slighly less than elegant:
> 
> class Foo {
>     static $bar;
>     static function init () {
>         // Create $bar with expressions...
>         self::$bar = $bar;
>     }
> }
> Foo:init();
> 
> A custom autoloader could of course anticipate this but with 
> systems like composer that have a shared autoload, it'd be 
> nicer to use those than rely on a custom loader.
> 

I'd say, that using static at all isn't elegant. There is always a way
to avoid it.

Jared


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

Reply via email to