Or, alternatively put, is there any way to find the kind of problems in
foo2 & foo3 (below), at "*compile* time"?
,----[ lint-test.php ]
| <?php
|
| error_reporting(E_ALL | E_STRICT);
|
| function foo1()
| {
| $bar = 'cheese';
| echo $bar;
| }
|
| function foo2()
| {
| $bar = 'cheese';
| echo 'cheese';
| }
|
| function foo3()
| {
| // $bar = 'cheese';
| echo $bar;
| }
|
| foo1();
| foo2();
| foo3();
|
| ?>
`----
I only get errors displayed when code happens to pass down the code
path, i.e. at runtime:
,----
| /home/jg/work $ php -l lint-test.php
| No syntax errors detected in lint-test.php
| /home/jg/work $ php lint-test.php
| cheesecheese
| Notice: Undefined variable: bar in
| /home/jg/work/lint-test.php on line 20
|
| Call Stack:
| 1.0000 61488 1. {main}()
| /home/jg/work/lint-test.php:0
| 1.0000 61680 2. foo3()
| /home/jg/work/lint-test.php:25
`----
If foo3 never happens to be called when I am doing my testing (for
example if the call is in some "if" branch that is never exercised) then
it only gets found in production, so I would like to find this kind of
thing using a static analyser. The kind of problem in foo2 I could live
with, but would like to find as well, if possible. (Obviously I am using
these two example problems as indicative of the type of things I want to
find, it isn't an exhaustive list!)
BTW, what problems *does* "php -l" pick up? I can't find a description
anywhere.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php