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

No support for local variable in `codegraph`? #149

Open wweic opened 8 years ago

wweic commented 8 years ago

Hi, I'm running codegraph on this dummy code with command: ./codegraph -lang php -build -o "/workspace/tmp" "/php-sample/" .

<?php

namespace Valet;

class Brew
{
    var $cli, $files;

    function installed($formula)
    {
        return in_array($formula, explode($this->cli->run('brew list'.$formula)));
    }

    function foo()
    {
        $a = 1;
        return $a;
    }
}

I have patched pfff to dump the graph. And I'm seeing such result:

Find these files
    /Users/weichen/php-sample/brew.php

printing all nodes:

[Dir: .]
[Dir: PB]
[Dir: NOT_FOUND]
[Dir: DUPE]
[File: brew.php]
[Class: Valet\Brew]
[Field: Valet\Brew.$cli]
[Field: Valet\Brew.$files]
[Method: Valet\Brew.installed]
[Method: Valet\Brew.foo]
[Function: in_array]
[Function: explode]
[Constant: PHP_EOL]

printing all edges

Method: Valet\Brew.installed uses Field: Valet\Brew.$cli
Method: Valet\Brew.installed uses Function: in_array
Method: Valet\Brew.installed uses Function: explode
Method: Valet\Brew.installed uses Constant: PHP_EOL
nb nodes = 13, nb edges = 4
parse errors = 0
lookup fail = 3
unresolved method calls = 0
(resolved method calls = 0)
unresolved field access = 0
(resolved field access) = 1)
unresolved class access = 0
unresolved calls = 0

I don't see node created for local variable a, is this expected? I'm also reading through documentation . Seems like there was a tool called pfff_browser before which is supposed to have all the features that codegraph should include.