Re: [Announce] PHPLint 0.3 - PHP source parser and validator
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: [Announce] PHPLint 0.3 - PHP source parser and validator

From: Umberto Salsi <salsi@icosaedro.italia>
Date: Tue Oct 18 2005 - 02:30:14 CEST

Janwillem Borleffs <jw@jwscripts.com> wrote:

> You might want to add variable variables and functions support:
>
> $this->$property = @$_REQUEST[$name];
> \_ HERE
> 31: FATAL ERROR: expected property name or method name after `->'

The variable-variables feature is already into my to-do list, but I think
that it will remain there quite a while, together to the variable-function
$f(). The reason is that these programming practices fit well with an
interpreted scripting language, but they are very difficult to check by a
strong-typed language, like PHPLint pretends to parse. The best I can do,
in a future release of the program, is to skip such constructs raising
an error message or a warning just telling that the parser is giving up,
and suggesting to the programmer that there should be a cleaner way.

A final note about the usage of the "@" operator: if $_REQUEST['NAME']
is not set the assignment fail and the variable assigned is not set:

    <?
    $x = @ $undefinedvar;
    echo isset($x)? "set":"not set";
    ?>

gives:

    not set

Moreover, $_REQUEST['NAME'] might be either a string:

    http://your.site/your-script.php?NAME=xxx

or an array:

    http://your.site/your-script.php?NAME[]=xxx&NAME[]=yyy

If you are expecting a string, you should write something like:

    $x = isset( $_REQUEST['NAME'] )? (string) $_REQUEST['NAME'] : "";

or, if you are expecting an array,

    $x = isset( $_REQUEST['NAME'] && is_array( $_REQUEST['NAME'] ) )?
        $_REQUEST['NAME'] : array();

Regards,
 ___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it
Received on Tue Oct 18 02:30:14 2005