Menu

#439 PHPParser Warnings Function

closed-works-for-me
None
5
2011-11-12
2005-01-28
Archilles
No

I use PHPParser in 1.1.0 on jEdit 4.2.0. This warning
feature is nice, thanks for it. Keep up that good work.
But it needs some tweaking :)

First Example:

class foo{
function bar($onevar){
// some things

( 1 == 1 )
? $twovar = $onevar
: $twovar = $threevar;

$blabla = strpos($foo,$twovar);
// some things
}
}

This construct throws "Parameter $onevar seems to be
never used in your method" at the function line. If I
use $twovar later on, it it also warned, that "it is
unassigned yet" at strpos().

Another one:

preg_match_all("foobar",$findhere,$extract);
$foo = $extract[0];

$extract is warned at preg_match line with "unassigned
yet". Logically correct, because the parser does not
know $extract is output from preg_match_all() and is to
be used later on. I can live with it - need not being
fixed soon.

Last but not least:

I use double quotes as limiter in echo (yes, I know
that single quotes are recommended). Variables used in
those expressions seems not to be scanned.

function foo($bar){
echo "hahaha $bar hihihi";
}

This results in $bar is "not used in your method" at
function line. But

function foo($bar){
echo 'hahaha '.$bar.' hihihi';
}

works correctly. I can send screenshots or code
snippets, if you need some. Just contact me
(german/english).

Best wishes
archilles_sw

Discussion

  • Matthieu Casanova

    Logged In: YES
    user_id=285591

    Hi, the first problem will be fixed in the next release.
    The second, I'm thinking about it and how to solve that ...
    The last one need to reactivate the double quoted string
    parsing, but I have some work to do on it (the actual
    version is deactivated because of bugs)

     
  • Matthieu Casanova

    • assigned_to: nobody --> kpouer
     
  • Matthieu Casanova

    • status: open --> closed-works-for-me
     

Log in to post a comment.