George Schlossnagle wrote: >> ..
$a = new fubar(); $a->doSomething(1, 2.0); $a->doSomething(3,4, 5.0); ?>
The problem with this is that that integer may well be a string when you look at it. There's no good way to do this past discriminating between scalar, array and object (by type, of course). I personally think that that is fine (adding an array typehint would be nice).
George
Hi George,
an integer can be represented as string or the float can be also a string and in this case it won't work but it works for situation where the programmer knows what he is doing. Joe average won't need the language feature thus won't need to implement it even in userland. Sebastian's case was about classes and an object cannot be anything else but object
protected function doSomething_objectBar_objectFoo($bar, $foo) {}
public function doSomething() {
$args = func_get_args();
$method_name = __FUNCTION__;
foreach ($args as $v) {
$type = $v;
$method_name .= "_".gettype($v);
if ($type === "object") $method_name .= get_class($v);
}
Of course this is quite fast :/
Cheers, Andrey
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php