Archive for August, 2010

PHP Static Instantiation – The Underscore Method

Lets make this underscore method a standard for static instantiation.

_() reads as “instance”

class Foo {
 
    public static function _() { return new self(); }
 
    public $n = 100;
 
    function bar() {
        $this->n--;
        return $this;
    }
 
    function __toString() {
        return $this->n." bottles of beer on the wall";
    }
 
}
 
echo Foo::_()->bar()->bar()->bar()->bar()->bar();
 
/* Reads
echo Foo  ^instance bar, bar, bar,  bar,   bar.
 
Output
95 bottles of beer on the wall
 
*/

Facebook Connfuse

I’m finding Facebook Connect to be very difficult to grok.

The documentation is disparate and circular.
The 1 example app I found does not function properly and its source code is not available as best I can tell.
Some tutorials contain links to Facebook SVN repositories that don’t exist anymore.
Every doc is long and obtuse.
Someone should write a good intro and organize their fucking shit.
I guess that someone is me since I’m the one complaining.

Stay tuned.