Re: RE: Optional scalar type hinting
| From: | Alain Williams | Date: | Fri, 04 Jan 2008 00:47:06 +0000 |
| Subject: | Re: RE: Optional scalar type hinting | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-34383@lists.php.net to get a copy of this message | ||
On Thu, Jan 03, 2008 at 10:43:39AM -0800, Stanislav Malyshev wrote:
> >When the type hint says I want an integer, then only integer should be
> >accepted; no casting should be done. It may give predictable results
>
> Why people that want Java just don't use Java I wonder? PHP never was a
> strict static typed language.
You aren't making it a strict static typed language. All that you are doing
is saying that at certain points (function entry) that the values are checked
and converted to certain types. If within the fuction an argument hinted as
integer is used in a string context, the juggling will still happen.
What you are doing to allowing the function author to protect the integrity
of his code without having to resort to a regex/... to check what the arguments are.
--
Alain Williams
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256 http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
Chairman of UKUUG: http://www.ukuug.org/
#include <std_disclaimer.h>