Posting to newsgroup php.internals, Stanislav Malyshev wrote:

> > only reason to use type hints - to ensure the method is used
> > correctly and build more robust applications), it is better to tell
> 
> BTW, I'm not sure how exactly it makes the code more robust - if you 
> call it with wrong type and it's not checked, the app would probably die 
> on fatal error. If you call it with wrong type and it is checked, the 
> app would die on fatal error couple of lines above. Unless you use some 
> kind of static analysis tool to verify your app prior to deployment (if 
> you know such tools please tell me!) I don't see much difference here, 
> mostly syntax sugar and enforcing right style (which is not bad - just 
> it's not that big a deal).

Most of the current applications of PHP do not need strict type checking, and
PHP as we know today perfectly fits these needs. But debugging and "cleaning"
large applications may become a nightmare.

That's why I developed PHPLint, a PHP parser and validator that performs
a static analysis of the source, ensuring the safe handling of types. In
a word, this tool makes PHP very close to a strong-typed language without
the need to further complicate the interpreter with new features that would
pervert the nature of the language.

Every constant, variable, property has a well defined type, and every
function and method has a well defined signature that can be guessed by
PHPLint or provided through specific meta-code as in this example:


$i = 123;
# type of the variable guessed as int

define("RND_K", 1.0 / (1.0 + getrandmax()));
# type of the constant guessed as double

function rnd()
{
    return RND_K * rand();
}
# signature guessed as float()

$i = rnd();
# ERROR: assigning double to int

function textToattribute(/*.string.*/ $a)
{
    return "\"" . htmlspecialchars($a) . "\"";
}
# signature string(string)


Best regards,
 ___ 
/_|_\  Umberto Salsi
\/_\/  www.icosaedro.it

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to