I'm having a hard time understanding why I'm getting an Unexpected T_PAAMAYIM_NEKUDOTAYIM error in the following code, which seems perfecly valid to me...
class xpto
{
    public static $id = null;
    public function __construct()
    {
    }
    public static function getMyID()
    {
        return self::$id;
    }
}
function instance($xpto = null)
{
    static $result = null;
    if (is_null($result) === true)
    {
        $result = new xpto();
    }
    if (is_object($result) === true)
    {
        $result::$id = strval($xpto);
    }
    return $result;
}
Output in PHP 5.3+:
echo var_dump(instance()->getMyID()) . "\n"; // null
echo var_dump(instance('dev')->getMyID()) . "\n"; // dev
echo var_dump(instance('prod')->getMyID()) . "\n"; // prod
echo var_dump(instance()->getMyID()) . "\n"; // null
In prior versions however, I can't do $result::$id = strval($xpto);, does anyone know why?
Are there any workarounds for this problem?