Magic __get getter for static properties in PHP

No, it is not possible.

Quoting the manual page of __get :

Member overloading only works in
object context. These magic methods
will not be triggered in static
context. Therefore these methods can
not be declared static.

In PHP 5.3, __callStatic has been added ; but there is no __getStatic nor __setStatic yet ; even if the idea of having/coding them often comes back on the php internals@ mailling-list.

There is even a Request for Comments: Static classes for PHP

But, still, not implemented (yet ? )

Leave a Comment