What I've tried:
//...
zend_long dest;
if (UNEXPECTED(!zend_parse_arg_long(arg, &dest, NULL, 0, 0))) {
zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be of the type integer", "", zend_zval_type_name(arg), "", arg);
}
zval_ptr_dtor(arg);
ZVAL_LONG(arg, dest);
//...
The problem is that if arg
is a literal string with a malformed number like "10x"
the engine raises a notice:
Notice: A non well formed numeric value encountered in...
What I really wanted is to be able to cast arg
just like as the following PHP userland code:
(int) "10x" // evaluates to 10, no NOTICE
I'm still crawling through the zend API so any help on how to find a good (updated) PHP internals reference or general advice is welcome.