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

Analyze for PHP anonymous functions #75

Closed AndrewDryga closed 10 years ago

AndrewDryga commented 10 years ago

Hi,

This code throws warning:

function foo($bar) {
    return $baz;
}

This code don't throw warning:

some_function(function($bar) {
    return $baz;
});

Even since there are same mistakes in both examples.

aryx commented 10 years ago

master~/pfff/tests/php/scheck $ cat /tmp/test.php <?php

function foo($bar) { return $baz; }

function some_function($x) { }

some_function(function($bar) { return $baz; });

~/pfff/scheck /tmp/test.php

using / for php_root 1 / 1/tmp/test.php:5:11: CHECK: Use of undeclared variable $baz (did you mean $bar?). /tmp/test.php:14:13: CHECK: Use of undeclared variable $baz in lambda. See http://php.net/manual/en/functions.anonymous.php and the 'use' keyword.

It works for me. Do you have a recent version of pfff?

aryx commented 10 years ago

let me know if this still does not work for you