Initializing a variable with a function reference (PHP) I'm working on an old PHP website, and NetBeans is complaining about an uninitialized variable. I'm seeing some code like this:

$app-&gt;soapAPIVersion($apiVersion);
$_SESSION['apiVersion'] = $apiVersion;


The function looks something like this:

function soapAPIVersion(&amp;$apiVersion)
{
    $apiVersion = '';
    $result = false;
    $soapResult = $client-&gt;call('getAPIVersion', array('sessionKey' =&gt; $sessionKey), $url);

    if (is_string($soapResult))
    {
        $apiVersion = $soapResult;
        $result = true;
    }

    return $result;    
}


I believe it's using this line to initialize the $apiVersion variable:

$app-&gt;soapAPIVersion($apiVersion);


For better coding practice, should that really be this:

$apiVersion = '';
$app-&gt;soapAPIVersion($apiVersion);


Or is it a valid trick?
Clean Code, Chapter 3. Functions has some guidance:


  Have No Side Effects
  
  Side effects are lies. Your function promises to do one thing, but it also does other hidden
  things.
  
  [...]
  
  Anything that forces you to check the function signature is equivalent to a double-take. It’s
  a cognitive break and should be avoided.


The side effect here is that the function changes the argument. A more readable approach would be returning the API version (instead of true/false) or throwing an exception in case of errors.


$app-&gt;soapAPIVersion($apiVersion);
$_SESSION['apiVersion'] = $apiVersion;


Note that the code should check the return value of soapAPIVersion and handle false somehow.
The soapAPIVersion name is unclear. What does it do with the API version? From Clean Code, Chapter 2: Meaningful Names:


  Method Names
  
  Methods should have verb or verb phrase names like postPayment, deletePage, or save.
  Accessors, mutators, and predicates should be named for their value and prefixed with get,
  set, and is according to the javabean standard.


I'd rename it to getApiVersion or fetchApiVersion. 

Note the camelCase too which is usually easier to read. From Effective Java, 2nd edition, Item 56: Adhere to generally accepted naming conventions: 


  While uppercase may be more common, 
  a strong argument can made in favor of capitalizing only the first 
  letter: even if multiple acronyms occur back-to-back, you can still 
  tell where one word starts and the next word ends. 
  Which class name would you rather see, HTTPURL or HttpUrl?