Edit report at http://bugs.php.net/bug.php?id=53159&edit=1
ID: 53159 Comment by: uramihsayibok at gmail dot com Reported by: dmgx dot michael at gmail dot com Summary: Tolerant and Strict Variables and functions Status: Open Type: Feature/Change Request Package: Variables related PHP Version: Irrelevant Block user comment: N New Comment: See http://wiki.php.net/rfc/typechecking If you have a new idea, submit an RFC. Less likely to be shrugged off. Previous Comments: ------------------------------------------------------------------------ [2010-10-25 22:22:47] dmgx dot michael at gmail dot com Description: ------------ These are suggestions for PHP 6.0. A tolerant variable, unlike a scalar, has an assigned type. If a value is placed in a tolerant variable of the wrong type it silently casts it to the correct type. It would require a new language keyword, "tolerant". tolerant string $a = 'hello'; $a = false; echo $a // echos the string value of false, '' A strict variable behaves much the same but triggers an error (or throws exception) rather than silently recasting. It requires a new keyword "strict" strict int $a = 5; $a = false; // exception thrown. The purpose of these var types is to build a better bridge between undata-typed programming used by beginning coders and strict data-typed programming used by veterans without forcing the former camp to adjust - PHP's strength is ease of learning. Tolerant functions apply the recasting to their incoming arguments according to the datatypes hinted for the objects - if the value isn't of the appropriate object a new object ob the type hinted is created receiving that value as an argument. Strict functions throw errors but can also overload sharing names with each other so long as no two strict functions try to have both the same name and argument types. So strict function foo ( int $a ) {} strict function foo ( string $a ) {} strict function foo ( MyClass $a ) {} would be possible. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53159&edit=1