Re: type hinting

From: Date: Sun, 06 Jan 2008 20:24:36 +0000
Subject: Re: type hinting
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-34541@lists.php.net to get a copy of this message
Hello Cristian, Sunday, January 6, 2008, 7:42:58 PM, you wrote: > 2008/1/5, Alain Williams <addw@phcomp.co.uk>: >> "1" and 1 should both be acceptable to type hint 'int'. > No way, "1" is an string, not an integer. Well that is the whole issue here. In PHP "1" is pretty equal to 1 in any function. It only makes a difference in ===. Now type hints are not exact either, the allow the type itself or any subclass. And any integer can also be a float so that would be a kind of subclass. Further more all internal functions that use an integer request that in one of two ways. First way is that it uses old style parameter parsing with a conversion macro or it uses new stle parameter parsing API which does conversion internally. Now what we would want is most likely use the hints for the stuff we already have. And that would mean it would need to behave in the way of the stuff we already have. Why? Becasue we do so for the existing type hints as well. That said I would only agree to type hints if we make them respect existing PHP conversion rules. Best regards, Marcus

« previous php.internals (#34541) next »