Re: Json.php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



# chris.boget@xxxxxxxx / 2007-04-18 04:59:48 -0400:
> >So only one of these is "kosher"
> >static:
> >return Services_JSON::decode($data);
> >
> >class:
> >$json = new Services_JSON;
> >return $json->decode($data);
> >but not both.
> 
> I'm not trying to start (or further add fuel to) any kind of war but 
> instead an earnest question: why not both?

If you don't declare the method static, you might be using $this inside,
possibly indirectly.

class c
{
    function f()
    {
        if (its_second_friday_this_year()) {
            return get_class($this);
        }
        return 'mostly harmless';
    }
    function g()
    {
        return self::f();
    }
}

c::g();

That's an incident waiting to happen, and forbidding static calls of
instance methods is an (intended) anti-footshooting measure.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux