There's definitely use cases, every now and then. For example, using XenForo_Model_Alert::alert() is a lot more convenient then usingThough, the argument could then be made... why have that method in that class in the first place?
/* @var XenForo_Model_Alert $alertModel */
$alertModel = XenForo_Model::create('XenForo_Model_Alert'); // You could use $this->getModelFromCache('XenForo_Model_Alert') if you're in a file that supports it.
$alertModel->alertUser();
/**
* getter method, basically same as offsetGet().
*
* This method can be called from an object of type Zend_Registry, or it
* can be called statically. In the latter case, it uses the default
* static instance stored in the class.
*
* @param string $index - get the value associated with $index
* @return mixed
* @throws Zend_Exception if no entry is registerd for $index.
*/
public static function get($index)
Thank you for all the responses. I digged deeper into static method and referred few books. It turns out that labeling any method static is purely based on coding 'style'. Then I looked into XF code and checked the method I've used frequently; 'get'
The description reads -
PHP:/** * getter method, basically same as offsetGet(). * * This method can be called from an object of type Zend_Registry, or it * can be called statically. In the latter case, it uses the default * static instance stored in the class. * * @param string $index - get the value associated with $index * @return mixed * @throws Zend_Exception if no entry is registerd for $index. */ public static function get($index)
The description still does not give me any clue as to why the devs decided to mark it static. Maybe it's got something to do with Zend Framework? Would really appreciate if @Mike could spare a moment to explain.
Thanks again for all the help!
Maybe it's got something to do with Zend Framework?
We use essential cookies to make this site work, and optional cookies to enhance your experience.