Convert system/idl/function to HNI

Also fixes compatibility with PHP, when func_get_arg()
is called with non-integer parameter.

Closes #3015.