1. 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?

Discussion in 'XenForo Development Discussions' started by LPH, Dec 7, 2014.

  1. LPH

    LPH Well-Known Member

    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?
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    It essentially is just passing a variable into the function with the intention of never using it.
     
  3. LPH

    LPH Well-Known Member

    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? ;)
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    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.
     
    LPH likes this.

Share This Page