dalecosp wrote: Practically, seems little difference between:
That's what I'm doing; going from
function foo($x, $y, $z)
{
global $bar, $baz;
//...
}
//...
foo($a, $b, $c);
to
function foo($x, $y, $z, &$bar, &$baz)
{
//...
}
//...
global $bar, $baz; // Rinse and repeat
foo($a, $b, $c, $bar, $baz);
And look to see how the variables clump together and where they like to hang out. Another step is to drop the reference if they're read-only, and to adjust the return value if they aren't:
function foo($x, $y, $z, $bar, $baz)
{
//...
return [$bar, $baz];
}
//...
global $bar, $baz;
list($bar, $baz) = foo($a, $b, $c, $bar, $baz); // '[$bar, $baz] = ...' would be cleaner, but that's not in the language yet.
And that gives a potential proto-object (let's see how often it shows up).