facebookarchive / pfff

Tools for code analysis, visualizations, or style-preserving source transformation.
http://github.com/facebook/pfff/wiki/Main
Other
2.44k stars 204 forks source link

Static method calls vs. reading constants / prolog #69

Closed ghost closed 10 years ago

ghost commented 10 years ago

The following code registers in the prolog database as constant "use", but it's just a static method call.

The code:

<?php MyClass::myStaticMethod('myParam');

The generated prolog facts:

file('test.php', ['test.php']).
docall('__TOPSTMT__test.php', 'myStaticMethod', method).
docall('__TOPSTMT__test.php', ('MyClass','myStaticMethod'), method).
use('__TOPSTMT__test.php', ('MyClass','myStaticMethod'), constant, read).

The call is obviously not a "constant read" of the class, so the fourth line should be removed (I think).

Thanks! AK

ghost commented 10 years ago

Probably shouldn't recurse when it matches Call/ClassGet+args: database_prolog_php.ml:387

ghost commented 10 years ago

It matches database_prolog_php.ml:394 when it shouldn't:

(* the context should be anything except Call *)

It is a 'Call'!

aryx commented 10 years ago

Thx for the bug report!

This should fix it: https://github.com/facebook/pfff/commit/500a5d71eb13bcfc2b8fd1f417c0c51e92ffbec7