On Sun, Jan 06, 2008 at 01:02:54PM +0100, Stefan Esser wrote: > Hello Alain, > > I think you are also confused about PHP type hinting... > > The manual clearly states: > > > > Type Hinting > > > PHP 5 introduces Type Hinting. Functions are now able to force > parameters to be objects (by specifying the name of the class in the > function prototype) or arrays (since PHP 5.1). > > And suddenly you want to change that definition to > > "Functions are now able to force parameters to be types that *could be > casted* to objects/arrays." > > That is not going to happen. Type hints are supposed to force parameter > to be of a specific type. Any kind of auto conversion would redefine > type hinting and would be just another feature that gives PHP haters a > reason to rant about. > And if you want that '1' is allowed to be passed as parameter (without > an actual int cast) because it COULD BE CASTED to int then you gain > ABSOLUTELY nothing from the type hint. Then you don't need to introduce > them at all.
No - you have misunderstood me. The actual cast IS part of the proposal. My mail showing how the checking works might have not be clear on the cast part - I was talking about the checking -- which has to happen before a cast. The point that I was trying to make is that the VALUE is preserved. Within the function type juggling may still happen, allowing an int to be used as a string (or whatever). Why I mean by: Type HINTING is not type ENFORCEMENT. is that: function foo(int $a) {} foo(1); // OK foo("1"); // OK - the string is juggled to an int when the function is called // ENFORCEMENT would have (in some interpretations) caused this to // FAIL since the function argument was a string. I suspect that there is quite a lot of agreement, however since what we are talking about has not been precisely defined we are arguing over different understandings of what this is about. Sam Barrow was trying to put together a precise description. It might be good to wait until he has posted that before we continue going round in circles. > Stefan Esser -- 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> -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php