News Archive
PhpRiot Newsletter
Your Email Address:

More information

PHP 5.4 Type Hints Patch

Note: This article was originally published at Planet PHP on 20 April 1720.
Planet PHP
I've recently started work on porting our internal company PHP patches over to PHP 5.4 as part of our migration from 5.3 to 5.4 One of those patches is the type-hint patch that introduces scalar type hints to PHP (something I wrote originally for PHP 5.1), something that was briefly included in PHP 5.4 but then (unfortunately) reverted.

Since I feel that type-hints is a pretty handy feature to have as it eliminates many possible errors, improves code interrogation and addresses some of the limitations currently being worked-around via annotations I've decided to share this patch with the community. The patch is available for download at: it applies cleanly against PHP 5.4.8 as well as 5.4 branch (5.4.9RC1). I suspect it will work with earlier versions of PHP 5.4 as well. The patch includes full test coverage around the new functionality and all of the existing tests continue to pass (so nothing is broken).