You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?php
class Test {
protected $capture;
function foo($command, &$bar = null) {
$this->capture = count(func_get_args()) > 1;
if ($this->capture && !is_callable($bar)) {
$bar = 'bar';
}
}
function foo2(&$bar) {}
}
(new Test)->foo('cmd', $undef);
var_dump($undef);
(new Test)->foo2($undef2);
var_dump($undef2);
Phan outputs:
test.php:17 VarError Variable $undef is not defined
test.php:20 VarError Variable $undef2 is not defined
However, php executes this just fine and outputs 'bar' & NULL. Passing the variables by reference defines them even if they are not assigned by the callee. get_defined_vars() also confirms that.
The text was updated successfully, but these errors were encountered:
Seldaek
changed the title
Invalid VarError with complex usage of references
Invalid VarError with usage of references
Dec 10, 2015
morria
added
the
bug
A crash in Phan, a recent change causing incorrect analysis results, etc.
label
Dec 10, 2015
Cool thanks for the quick turnaround, I'll try to do another pass over the weekend and look at the less common errors to see if I find any other false positives :)
I got a minimal repro case for this:
Phan outputs:
However, php executes this just fine and outputs
'bar'
&NULL
. Passing the variables by reference defines them even if they are not assigned by the callee.get_defined_vars()
also confirms that.The text was updated successfully, but these errors were encountered: