ovr / phpsa

Smart/Static Analyzer(sis) for PHP :bowtie::neckbeard:
Other
637 stars 77 forks source link

[Bug] False positive ArrayDimFetch for SplObjectStorage #307

Closed algo13 closed 7 years ago

algo13 commented 7 years ago

ArrayDimFetch.php

function f()
{
    $o = new \stdClass;
    $obj = new \SplObjectStorage;
    $obj[$o] = 1;
    echo $obj[$o]; //< Notice:  It's not possible to fetch an array element on a non array [language_error]
}
ddmler commented 7 years ago

when checking this code i also get:

Unimplemented PhpParser\Node\Stmt\Echo_

Notice: Illegal array offset type object for key $o. in x on 9 [array.illegal_offset_type] $obj[$o] = 1;

algo13 commented 7 years ago

@ddmler Thanks for comment.

[array.illegal_offset_type] is false positive too.

https://3v4l.org/v5l8f http://php.net/manual/class.splobjectstorage.php

algo13 commented 7 years ago

@ovr Thanks for commit ([ControlFlowGraph] Dont use echo, use debug from Context)

echo 'Unimplemented' (ControlFlowGraph.php#L109)

overlook?

ovr commented 7 years ago

Sure, I fixed this notice

Unimplemented PhpParser\Node\Stmt\Echo_

Because CFG in initial state and it's not a good idea to write it without debug check

overlook?

Sure, I saw @ddmler message :)

algo13 commented 7 years ago

@ovr After your fixed, echo is left only ControlFlowGraph.php#L109.

Is not it $this->context->debug() ? ;)