On Fri, Jan 04, 2008 at 12:37:19PM -0500, Robert Cummings wrote: > IMHO, optionally inclusion of type hinting for functions/methods can > only be a boon to code quality and readability. IMHO when a type hint is > provided and a parameter doesn't match the type hint then I think a > fatal error should occur. This forces the user of the function that has > type hinting to ensure their data is of the correct type. This prevents > accidental wrong data conversion. However, I see the other side of the > coin too where automatic type conversion could be desirable also. > Perhaps a mixed solution would be viable? > > <?php > > function foo( require int $a, require string $b ){} > > foo( '5', 'bleh' ); // <-- fatal error
No. > ?> > > Contrast versus: > > <?php > > function foo( int $a, string $b ){} > > foo( '5', 'bleh' ); // <-- no exception or error $a in foo() will > // be type int (automatic conversion) Yes. If $a is '5' but reject if $a is '5five'. > ?> > > Versus (still allowed default style): > > <?php > > function foo( $a, $b ){} > > foo( '5', 'bleh' ); // <-- no exceptions or type conversions > > ?> > > Thoughts? > > Cheers, > Rob. > -- > ........................................................... > SwarmBuy.com - http://www.swarmbuy.com > > Leveraging the buying power of the masses! > ........................................................... -- 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