Return reference to static variable from __callStatic?
<p>I'm trying to find a workaround for static variables not being copied over to extending classes (which doesn't play nicely with late static binding), here is what I thought might work, but gives me a "PHP Fatal error:  Can't use function return value in write context" :</p>

<pre><code>&lt;?php

class Person
{
    protected static $tlsb_names = ['name'];
    protected static $tlsb_vars  = [];

    public static function &amp; __callStatic($method,$args)
    {
        echo "call static " . $method . " on " . get_called_class() . "\n";
        if(in_array($method,static::$tlsb_names))
        {
            if(!array_key_exists(get_called_class(),static::$tlsb_vars))
            {
                static::$tlsb_vars[get_called_class()] = [];
            }
            if(!array_key_exists($method, static::$tlsb_vars[get_called_class()]))
            {
                echo "set var $method for " . get_called_class() . "\n";
                static::$tlsb_vars[get_called_class()] = null;
            }
            return static::$tlsb_vars[get_called_class()][$method];
        }
    }

    public static function show_name()
    {
        static::name() . "\n";
    }

    public static function call_me_al()
    {
        static::name() = "Al";
    }

    public static function call_me_joe()
    {
        static::name() = "Joe";
    }   
}

class Al extends Person{}
class Joe extends Person{}

Al::call_me_al();
Joe::call_me_joe();

Al::show_name();
Joe::show_name();
</code></pre>

<p>The problematic part is with the lines :</p>

<pre><code>public static function call_me_al()
{
    static::name() = "Al";
}
</code></pre>

<p>Apparently this is a compile-time error since non of my echo's are run.</p>

<p>What am I doing wrong here?</p>
