Thread: Return self ?
View Single Post
Old 11-12-2008, 07:28 PM   #1 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default Return self ?

Hi!

You know when you want to use chains in regular classes, you return $this?

PHP Code:
public function smthng()
{

       
$this->somevar 'smthng';
       return 
$this;


My question regards how you do this when the whole class is static(it's a factory)?

PHP Code:
public static function smthng()
{

       
self::$somevar 'smthng';
       return 
self;


??

Also, if this is possible, how does the actual chaining work?
I mean.. do you use it like:
PHP Code:
FACTORY::smthng()::smthng()::smthng
??
__________________
Tanax is offline  
Reply With Quote