Re: [RFC] Type hints

From: Date: Wed, 12 May 2004 12:13:50 +0000
Subject: Re: [RFC] Type hints
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-9822@lists.php.net to get a copy of this message
IMHO if php is going to have the option to use type hinted parameters (which I really like) then it should have the option to use type hinted variables as well. Half stepping with the type hints are just going to complicate things. Afterall, NULL is a value and not a type. And if you use a type hinted parameter in your function - the argument passed to it, when declared, should be type hinted as well or throw an E_STRICT. Like many things this is probably easier said than done but..... <?php class UserClass { public static function forName($name, ClassLoader $c) { // ... } } ClassLoader $cl = NULL; UserClass::forName("somename", $cl); // passes the type hint $cl2 = NULL; UserClass::forName("somename", $cl); // throws an E_STRICT ?> No funny synatx no magic just clean code.

« previous php.internals (#9822) next »