If a static method returns an object .. can I in one line get one of the objects attributes? Something like this but in a single line :
$obj = Parser::GetFirstItem();
$strTitle = $obj->Title;
Have you actually tried it?
$strTitle = Parser::GetFirstItem()->Title;
That should work, provided you're using PHP5 and not still stuck on PHP4.
Sure. Just try it out:
$strTitle = Parser::GetFirstItem()->Title;
Not entirely sure when this was introduced. 5? 5.1? 5.2? Will have to check.
Update: Seems to have been a PHP 5 feature from the start.
Your GetFirstItem method should returns an object. Only virtual (not static methods) can do this:
return $this;
return self; in a static function returns an E_NOTICE that self is an undefined constant, assumes you meant 'self', and returns a string. (Note: PHP 5.3.2). If you want an object of the class that has the static function, then you should use return new self();