0

I have been unable to think of or find a clean way to set a class static variables in php without setting them in each function. Is there anyway to have a setup like below.

class Foo{

    private static $bar;

    function __constructor(){
        self::$bar = new Object();
    }

    public static function test(){
        return self::$bar->call();
    }
}

Essential how can i set $bar to new Object() before every static call without setting it in test().

michael.schuett
  • 4,248
  • 4
  • 28
  • 39

0 Answers0