php: Throw exceptions instead of using errors

Parameter type errors and some other cases in SWIG-generated wrappers
now throw a PHP exception, which is how PHP's native parameter handling
deals with similar situations.

See #2014, but not closing yet as there may be more cases to convert.
This commit is contained in:
Olly Betts 2021-05-25 16:37:21 +12:00
commit cdc69f9843
5 changed files with 52 additions and 22 deletions

View file

@ -276,7 +276,8 @@ INT_TYPEMAP(unsigned long long);
/* So... we didn't get a ref or ptr, but we'll accept NULL by reference */
if (!(Z_ISREF($input) && Z_ISNULL_P(Z_REFVAL($input)))) {
/* wasn't a pre/ref/thing, OR anything like an int thing */
SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname.");
zend_type_error("Expected reference or NULL for argument $arg of $symname");
SWIG_FAIL;
}
}
force=0;