Re: [RFC] Scalar Type Hints v0.2

From: Date: Fri, 16 Jan 2015 00:54:12 +0000
Subject: Re: [RFC] Scalar Type Hints v0.2
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  Groups: php.internals 
Request: Send a blank email to internals+get-80607@lists.php.net to get a copy of this message
Hi! > 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). That's how all internal functions work. It looks like you didn't actually read my argument but just repeated "I want my use case". I know you want strict typing. I even proposed the option for it. But if you read "function bar(int $num)" in the PHP manual, coercive typing is exactly what it means. That's how it has been since forever. It has nothing to do with arrays, because - repeating it in like 10000th time in this discussion - arrays are not scalars and PHP does not coerce non-scalars, only scalars. You can make scalars work like non-scalars - that would mean turning PHP into strongly typed language, like Python. -- Stas Malyshev smalyshev@gmail.com

« previous php.internals (#80607) next »