• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

What is $null in canStartConversations in Visitor.php?

LPH

Well-known member
#1
I'm just trying to dissect different parts of XenForo and figure out what is happening. While trying to see how classes were called and instantiated ... I ran across a $null in canStartConversations.

PHP:
    public function canStartConversations()
    {
        return XenForo_Model::create('XenForo_Model_User')->canStartConversations($null, $this->_user);
    }
phpStorm is showing that $null is undefined. In looking at the User.php in XenForo/Model ... there is

PHP:
public function canStartConversations(&$errorPhraseKey = '', array $viewingUser = null)
What is the $null doing at this point?
 

LPH

Well-known member
#3
It essentially is just passing a variable into the function with the intention of never using it.
Does this mean the undefined $null (different from setting $null = NULL) is simply passed to the $errorPhraseKey? Is there a reason not to just state $errorPhraseKey = '' ? Or am I really lost on this? ;)
 

Jeremy

Well-known member
#4
The notion of that is the value is set within the function and accessed globally. The $null setting just happens to stateit won't be used in that scope for readability.