Stanislav Malyshev, > I would rather have int $num for coercive typing - given that close to > 100% of existing typed functions - namely internal functions - mean > exactly that and are actually documented with this exact syntax. > [...] > As for strict, maybe it can be int! $num or something like that. I'm not > exactly supporting it, but out of what I have seen this would make the > most sense for me - it expresses the intent pretty clearly ("give me > int! or else!" :) and does not conflict with existing stuff.
The hole point (at least for me) for being against `function bar(int $num){}` to achieve type coercion is that the syntactic equivalent code `function bar(array $numbers){}` won't do any coercion - (array) $numbers - because BC break would be too big to handle. Having `int|integer|bool|float|real|string` as coercive type hints while `array` is "strict" looks like an ugly hack (no pun intended). 2015-01-15 21:32 GMT-03:00 Stanislav Malyshev <smalys...@gmail.com>: > Hi! > >>> 1. Strict >>> function bar(int $num){} >>> >>> 2. Lax >>> function bar((int) $num){} > > I would rather have int $num for coercive typing - given that close to > 100% of existing typed functions - namely internal functions - mean > exactly that and are actually documented with this exact syntax. Yes, > there are some functions that do strict, but those are in most cases are > either close to bugs which nobody cares to fix since it's so narrow a > case or some very special cases of some complex API where type matters > for API-specific reasons. > > As for strict, maybe it can be int! $num or something like that. I'm not > exactly supporting it, but out of what I have seen this would make the > most sense for me - it expresses the intent pretty clearly ("give me > int! or else!" :) and does not conflict with existing stuff. > > Putting it on the table as a brainstorming exercise. > > -- > Stas Malyshev > smalys...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php