On Monday 10 January 2005 17:58, Derick Rethans wrote: > On Mon, 10 Jan 2005, Leonardo Pedretti wrote: > > Are there any plans to include type hinting with basic types and type > > hinting for variables? (such as optional declaration) > > There are no such things planned, except for "array" afaik. That is quite good already, but... > > It would be useful to declare the type of a data member of a class, for > > example, for automation of data fetching from SQL databases or such > > things. > > That is *definitely* not on the list - PHP is weakly typed and will > remain so. I can't understand why being able to point some variable as strongly typed and remaining the default as weak typed would make php strongly typed. In fact, that assumption IS incorrect, a language is weakly typed when variable types are not forced to be respected though they already exist and change dynamically, and the programmer actively having to point a variable as strongly typed for the scope of a function obviously does not contradict that postulate. Even more, just having that feature in object data members would be heaven. Basic type hinting can be emulated using is_int, is_string, and so on on the beginning of the function needing that, but for objects it can not be done to know the type of a data member previously to it's assignment, and having to assign a value in the constructor forces one to declare a specific constructor doing that for classes that derive or implement an interface that has functions using that type for automation of tasks. Code just would be really so cleaner just by allowing one to put a type in front of an object data member declaration and allowing to retrieve that type.
For example, consider this code: abstract class base { function __construct() { // constructor just sets up some things } function someoperation() { /* this function needs to load the data members of basic types with some clear values but everything that is an object or an array must be filled through some specific process that can be automated just knowing the specific type in advance */ } } class specific_class { function construct() { $var1 = new SomeClass; $var2 = new SomeOtherClass; } private $var1; private $var2; } would the types could be showed int the class, function someoperation could still perform its task without any change, but specific_class now would be just the following: class specific_class { private SomeClass $var1; private SomeOtherClass $var2; } Which is identical to the upper version. Moreover, specifying the constructor parameters in the declaration should not be a problem, as it is equivalent code to the upper version. Well, i hope all this can be useful! Regards Leo > > Derick > > -- > Derick Rethans > http://derickrethans.nl | http://ez.no | http://xdebug.org -- Leonardo Pedretti Axon Sistemas Líder de Equipo Proyecto Basalto -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php