The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Specifying Allowed Data Types for Function Arguments

As far as I know, PHP doesn't have any support for specifying required data types for function arguments. Does anyone know if the PHP developers are looking to add this functionality?

Most of you would have noticed, that all built-in PHP functions seem to support this, as they all report warning when an incorrect data type is passed for a certain argument. So why don't PHP consider this important for user functions, when they obviously consider this important for PHP's built-in functions?

In addition to that, PHP makes it difficult to make your own implementation of this, but limiting the trigger_error() function to simply two arguments. It would be handy if trigger_error() allowed the user (programmer) to pass through the file and line information manually, so we had more flexibility in defining our own error-type handlers.

For example, I've been working on a function that checks the arguments passed to a user-defined PHP function. It looks something like this...

Note how it passes $file and $line to trigger_error(). This is obviously not supported, but you can imagine how nice this function would be if $file and $line argument were supported. Here's an example of what you'd need to put into all of your functions for this to work...