PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Scalar Type Hints in PHP 5.3.99

Note: This article was originally published at Planet PHP on 24 November 2010.
Planet PHP

PHP 5.3.99, which will hopefully be released as PHP 5.4 in less than six months, introduces the concept of optional strict type checking for scalars. In a nutshell, this means that PHP 5.3.99 introduces new syntax -- scalar type hints -- but no new semantics. The latter can either be implemented as an extension written in C/C++, in userland PHP code, or in a tool that statically analyzes the code.

The code below shows how the Reflection API can be used to access the scalar type hint information in userland.

Please note that this feature is still under discussion and might be removed before the final release of PHP 5.4.