#define PHP_GETTEXT_MAX_DOMAIN_LENGTH 1024
#define PHP_GETTEXT_MAX_MSGID_LENGTH 4096
-#define PHP_GETTEXT_DOMAIN_LENGTH_CHECK(domain_len) \
+#define PHP_GETTEXT_DOMAIN_LENGTH_CHECK(_arg_num, domain_len) \
if (UNEXPECTED(domain_len > PHP_GETTEXT_MAX_DOMAIN_LENGTH)) { \
- php_error_docref(NULL, E_WARNING, "Domain passed too long"); \
- RETURN_FALSE; \
+ zend_argument_value_error(_arg_num, "is too long"); \
+ RETURN_THROWS(); \
}
-#define PHP_GETTEXT_LENGTH_CHECK(check_name, check_len) \
+#define PHP_GETTEXT_LENGTH_CHECK(_arg_num, check_len) \
if (UNEXPECTED(check_len > PHP_GETTEXT_MAX_MSGID_LENGTH)) { \
- php_error_docref(NULL, E_WARNING, "%s passed too long", check_name); \
- RETURN_FALSE; \
+ zend_argument_value_error(_arg_num, "is too long"); \
+ RETURN_THROWS(); \
}
PHP_MINFO_FUNCTION(php_gettext)
RETURN_THROWS();
}
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK(domain_len)
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
if (domain != NULL && strcmp(domain, "") && strcmp(domain, "0")) {
domain_name = domain;
Z_PARAM_STR(msgid)
ZEND_PARSE_PARAMETERS_END();
- PHP_GETTEXT_LENGTH_CHECK("msgid", ZSTR_LEN(msgid))
+ PHP_GETTEXT_LENGTH_CHECK(1, ZSTR_LEN(msgid))
msgstr = gettext(ZSTR_VAL(msgid));
if (msgstr != ZSTR_VAL(msgid)) {
RETURN_THROWS();
}
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK(ZSTR_LEN(domain))
- PHP_GETTEXT_LENGTH_CHECK("msgid", ZSTR_LEN(msgid))
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
+ PHP_GETTEXT_LENGTH_CHECK(2, ZSTR_LEN(msgid))
msgstr = dgettext(ZSTR_VAL(domain), ZSTR_VAL(msgid));
RETURN_THROWS();
}
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK(ZSTR_LEN(domain))
- PHP_GETTEXT_LENGTH_CHECK("msgid", ZSTR_LEN(msgid))
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
+ PHP_GETTEXT_LENGTH_CHECK(2, ZSTR_LEN(msgid))
msgstr = dcgettext(ZSTR_VAL(domain), ZSTR_VAL(msgid), category);
RETURN_THROWS();
}
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK(domain_len)
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
if (domain[0] == '\0') {
- php_error(E_WARNING, "The first parameter of bindtextdomain must not be empty");
- RETURN_FALSE;
+ zend_argument_value_error(1, "cannot be empty");
+ RETURN_THROWS();
}
if (dir[0] != '\0' && strcmp(dir, "0")) {
RETURN_THROWS();
}
- PHP_GETTEXT_LENGTH_CHECK("msgid1", msgid1_len)
- PHP_GETTEXT_LENGTH_CHECK("msgid2", msgid2_len)
+ PHP_GETTEXT_LENGTH_CHECK(1, msgid1_len)
+ PHP_GETTEXT_LENGTH_CHECK(2, msgid2_len)
msgstr = ngettext(msgid1, msgid2, count);
RETURN_THROWS();
}
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK(domain_len)
- PHP_GETTEXT_LENGTH_CHECK("msgid1", msgid1_len)
- PHP_GETTEXT_LENGTH_CHECK("msgid2", msgid2_len)
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
+ PHP_GETTEXT_LENGTH_CHECK(2, msgid1_len)
+ PHP_GETTEXT_LENGTH_CHECK(3, msgid2_len)
msgstr = dngettext(domain, msgid1, msgid2, count);
RETURN_THROWS();
}
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK(domain_len)
- PHP_GETTEXT_LENGTH_CHECK("msgid1", msgid1_len)
- PHP_GETTEXT_LENGTH_CHECK("msgid2", msgid2_len)
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
+ PHP_GETTEXT_LENGTH_CHECK(2, msgid1_len)
+ PHP_GETTEXT_LENGTH_CHECK(3, msgid2_len)
msgstr = dcngettext(domain, msgid1, msgid2, count, category);
RETURN_THROWS();
}
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK(domain_len)
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
retval = bind_textdomain_codeset(domain, codeset);
/** @generate-function-entries */
-function textdomain(?string $domain): string|false {}
+function textdomain(?string $domain): string {}
-function gettext(string $msgid): string|false {}
+function gettext(string $msgid): string {}
/** @alias gettext */
-function _(string $msgid): string|false {}
+function _(string $msgid): string {}
-function dgettext(string $domain_name, string $msgid): string|false {}
+function dgettext(string $domain, string $msgid): string {}
-function dcgettext(string $domain_name, string $msgid, int $category): string|false {}
+function dcgettext(string $domain, string $msgid, int $category): string {}
-function bindtextdomain(string $domain_name, string $dir): string|false {}
+function bindtextdomain(string $domain, string $dir): string|false {}
#ifdef HAVE_NGETTEXT
-function ngettext(string $msgid1, string $msgid2, int $n): string|false {}
+function ngettext(string $msgid1, string $msgid2, int $n): string {}
#endif
#ifdef HAVE_DNGETTEXT
-function dngettext(string $domain, string $msgid1, string $msgid2, int $count): string|false {}
+function dngettext(string $domain, string $msgid1, string $msgid2, int $count): string {}
#endif
#ifdef HAVE_DCNGETTEXT
-function dcngettext(string $domain, string $msgid1, string $msgid2, int $count, int $category): string|false {}
+function dcngettext(string $domain, string $msgid1, string $msgid2, int $count, int $category): string {}
#endif
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 29c84ba2a2aa940baec3bd32503fc7c8e67885fe */
+ * Stub hash: a8b64ae24724f0552a62cd4146f6cfb3cd75fa19 */
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_textdomain, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_textdomain, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, domain, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gettext, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gettext, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, msgid, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo__ arginfo_gettext
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_dgettext, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
- ZEND_ARG_TYPE_INFO(0, domain_name, IS_STRING, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dgettext, 0, 2, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, domain, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, msgid, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_dcgettext, 0, 3, MAY_BE_STRING|MAY_BE_FALSE)
- ZEND_ARG_TYPE_INFO(0, domain_name, IS_STRING, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dcgettext, 0, 3, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, domain, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, msgid, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, category, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_bindtextdomain, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
- ZEND_ARG_TYPE_INFO(0, domain_name, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, domain, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, dir, IS_STRING, 0)
ZEND_END_ARG_INFO()
#if defined(HAVE_NGETTEXT)
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ngettext, 0, 3, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ngettext, 0, 3, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, msgid1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, msgid2, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, n, IS_LONG, 0)
#endif
#if defined(HAVE_DNGETTEXT)
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_dngettext, 0, 4, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dngettext, 0, 4, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, domain, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, msgid1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, msgid2, IS_STRING, 0)
#endif
#if defined(HAVE_DCNGETTEXT)
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_dcngettext, 0, 5, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dcngettext, 0, 5, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, domain, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, msgid1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, msgid2, IS_STRING, 0)
$domain = "domain";
$category = "cat";
-var_dump(bindtextdomain($overflown, 'path'));
-
-var_dump(dngettext($overflown, $msgid, $msgid, 1));
-var_dump(dngettext($domain, $overflown, $msgid, 1));
-var_dump(dngettext($domain, $msgid, $overflown, 1));
-
-var_dump(gettext($overflown));
-
-var_dump(ngettext($overflown, $msgid, -1));
-var_dump(ngettext($msgid, $overflown, -1));
-
-var_dump(dcgettext($overflown, $msgid, -1));
-var_dump(dcgettext($domain, $overflown, -1));
-
-var_dump(dcngettext($overflown, $msgid, $msgid, -1, -1));
-var_dump(dcngettext($domain, $overflown, $msgid, -1, -1));
-var_dump(dcngettext($domain, $msgid, $overflown, -1, -1));
-
-var_dump(dgettext($overflown, $msgid));
-var_dump(dgettext($domain, $overflown));
+try {
+ bindtextdomain($overflown, 'path');
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-var_dump(textdomain($overflown));
-?>
---EXPECTF--
-Warning: bindtextdomain(): Domain passed too long in %s on line %d
-bool(false)
+try {
+ dngettext($overflown, $msgid, $msgid, 1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: dngettext(): Domain passed too long in %s on line %d
-bool(false)
+try {
+ dngettext($domain, $overflown, $msgid, 1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: dngettext(): msgid1 passed too long in %s on line %d
-bool(false)
+try {
+ dngettext($domain, $msgid, $overflown, 1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: dngettext(): msgid2 passed too long in %s on line %d
-bool(false)
+try {
+ gettext($overflown);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: gettext(): msgid passed too long in %s on line %d
-bool(false)
+try {
+ ngettext($overflown, $msgid, -1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: ngettext(): msgid1 passed too long in %s on line %d
-bool(false)
+try {
+ ngettext($msgid, $overflown, -1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: ngettext(): msgid2 passed too long in %s on line %d
-bool(false)
+try {
+ dcgettext($overflown, $msgid, -1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: dcgettext(): Domain passed too long in %s on line %d
-bool(false)
+try {
+ dcgettext($domain, $overflown, -1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: dcgettext(): msgid passed too long in %s on line %d
-bool(false)
+try {
+ dcngettext($overflown, $msgid, $msgid, -1, -1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: dcngettext(): Domain passed too long in %s on line %d
-bool(false)
+try {
+ dcngettext($domain, $overflown, $msgid, -1, -1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: dcngettext(): msgid1 passed too long in %s on line %d
-bool(false)
+try {
+ dcngettext($domain, $msgid, $overflown, -1, -1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: dcngettext(): msgid2 passed too long in %s on line %d
-bool(false)
+try {
+ dgettext($overflown, $msgid);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: dgettext(): Domain passed too long in %s on line %d
-bool(false)
+try {
+ dgettext($domain, $overflown);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: dgettext(): msgid passed too long in %s on line %d
-bool(false)
+try {
+ textdomain($overflown);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: textdomain(): Domain passed too long in %s on line %d
-bool(false)
+?>
+--EXPECT--
+bindtextdomain(): Argument #1 ($domain) is too long
+dngettext(): Argument #1 ($domain) is too long
+dngettext(): Argument #2 ($msgid1) is too long
+dngettext(): Argument #3 ($msgid2) is too long
+gettext(): Argument #1 ($msgid) is too long
+ngettext(): Argument #1 ($msgid1) is too long
+ngettext(): Argument #2 ($msgid2) is too long
+dcgettext(): Argument #1 ($domain) is too long
+dcgettext(): Argument #2 ($msgid) is too long
+dcngettext(): Argument #1 ($domain) is too long
+dcngettext(): Argument #2 ($msgid1) is too long
+dcngettext(): Argument #3 ($msgid2) is too long
+dgettext(): Argument #1 ($domain) is too long
+dgettext(): Argument #2 ($msgid) is too long
+textdomain(): Argument #1 ($domain) is too long
if (!extension_loaded("gettext")) {
die("skip gettext extension is not loaded.\n");
}
+?>
--FILE--
<?php
+
chdir(__DIR__);
-bindtextdomain('', 'foobar');
---EXPECTF--
-Warning: The first parameter of bindtextdomain must not be empty in %s on line %d
+
+try {
+ bindtextdomain('', 'foobar');
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+?>
+--EXPECT--
+bindtextdomain(): Argument #1 ($domain) cannot be empty
--CREDITS--
Till Klampaeckel, till@php.net
PHP Testfest Berlin 2009-05-09
/* ext/xml */
F1("xml_error_string", MAY_BE_NULL | MAY_BE_STRING),
- F1("xml_parser_get_option", MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
+ F1("xml_parser_get_option", MAY_BE_LONG | MAY_BE_STRING),
F1("utf8_encode", MAY_BE_STRING),
F1("utf8_decode", MAY_BE_STRING),
F1("filter_list", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
/* ext/gettext */
- F1("textdomain", MAY_BE_FALSE | MAY_BE_STRING),
- F1("gettext", MAY_BE_FALSE | MAY_BE_STRING),
- F1("_", MAY_BE_FALSE | MAY_BE_STRING),
- F1("dgettext", MAY_BE_FALSE | MAY_BE_STRING),
- F1("dcgettext", MAY_BE_FALSE | MAY_BE_STRING),
+ F1("textdomain", MAY_BE_STRING),
+ F1("gettext", MAY_BE_STRING),
+ F1("_", MAY_BE_STRING),
+ F1("dgettext", MAY_BE_STRING),
+ F1("dcgettext", MAY_BE_STRING),
F1("bindtextdomain", MAY_BE_FALSE | MAY_BE_STRING),
#if HAVE_NGETTEXT
- F1("ngettext", MAY_BE_FALSE | MAY_BE_STRING),
+ F1("ngettext", MAY_BE_STRING),
#endif
#if HAVE_DNGETTEXT
- F1("dcngettext", MAY_BE_FALSE | MAY_BE_STRING),
+ F1("dcngettext", MAY_BE_STRING),
#endif
#if HAVE_BIND_TEXTDOMAIN_CODESET
F1("bind_textdomain_codeset", MAY_BE_FALSE | MAY_BE_STRING),
}
if (maxsize <= 0) {
- php_error_docref(NULL, E_WARNING, "Maximum size of the message has to be greater than zero");
- return;
+ zend_argument_value_error(4, "must be greater than 0");
+ RETURN_THROWS();
}
if (flags != 0) {
p = Z_STRVAL_P(message);
message_len = Z_STRLEN_P(message);
break;
-
case IS_LONG:
message_len = spprintf(&p, 0, ZEND_LONG_FMT, Z_LVAL_P(message));
break;
case IS_DOUBLE:
message_len = spprintf(&p, 0, "%F", Z_DVAL_P(message));
break;
+
default:
- php_error_docref(NULL, E_WARNING, "Message parameter must be either a string or a number.");
- RETURN_FALSE;
+ zend_argument_type_error(3, "must be of type string|int|float|bool, %s given", zend_zval_type_name(message));
+ RETURN_THROWS();
}
messagebuffer = safe_emalloc(message_len, 1, sizeof(struct php_msgbuf));
var_dump(msg_receive($q, 0, $null, 1, $msg, true, 0, $errno));
var_dump($errno != 0);
- // again, but triggering an E_WARNING
- var_dump(msg_receive($q, 0, $null, 0, $msg));
+ // again, but triggering an exception
+ try {
+ msg_receive($q, 0, $null, 0, $msg);
+ } catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
var_dump(msg_send($q, 1, 'foo', true, true, $errno));
var_dump($errno != 0);
bool(false)
bool(false)
bool(true)
-
-Warning: msg_receive(): Maximum size of the message has to be greater than zero in %s on line %d
-bool(false)
+msg_receive(): Argument #4 ($maxsize) must be greater than 0
Warning: msg_send(): msgsnd failed: Invalid argument in %s on line %d
bool(false)
bool(false)
bool(false)
bool(true)
-
-Warning: msg_receive(): Maximum size of the message has to be greater than zero in %s on line %d
-bool(false)
+msg_receive(): Argument #4 ($maxsize) must be greater than 0
Warning: msg_send(): msgsnd failed: Invalid argument in %s on line %d
bool(false)
foreach ($tests as $elem) {
echo @"Sending/receiving '$elem':\n";
- var_dump(msg_send($queue, 1, $elem, false));
+ try {
+ var_dump(msg_send($queue, 1, $elem, false));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
unset($msg);
var_dump(msg_receive($queue, 1, $msg_type, 1024, $msg, false, MSG_IPC_NOWAIT));
bool(true)
bool(false)
Sending/receiving '':
-
-Warning: msg_send(): Message parameter must be either a string or a number. in %s on line %d
-bool(false)
+msg_send(): Argument #3 ($message) must be of type string|int|float|bool, null given
bool(false)
bool(true)
bool(false)
Sending/receiving 'Array':
-
-Warning: msg_send(): Message parameter must be either a string or a number. in %s on line %d
-bool(false)
+msg_send(): Argument #3 ($message) must be of type string|int|float|bool, array given
bool(false)
bool(false)
bool(false)
require_once("skipif.inc");
if (!extension_loaded('iconv')) die ("skip iconv extension not available");
foreach(array('EUC-JP', 'Shift_JISP', 'GB2312') as $encoding) {
- if (@xml_parser_create($encoding) === false) die("skip libxml2 does not support $encoding encoding");
+ try {
+ xml_parser_create($encoding);
+ } catch (ValueError) {
+ die("skip libxml2 does not support $encoding encoding");
+ }
}
?>
--FILE--
$xmlParser = xml_parser_create();
-var_dump(xml_parser_get_option ($xmlParser, 42));
+try {
+ xml_parser_get_option ($xmlParser, 42);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
---EXPECTF--
-Warning: xml_parser_get_option(): Unknown option in %s on line %d
-bool(false)
+--EXPECT--
+xml_parser_get_option(): Argument #2 ($option) must be a PHP_XML_OPTION_* constant
$xmlParser = xml_parser_create();
var_dump(xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, 1));
-var_dump(xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, 'Invalid Encoding'));
+
+try {
+ xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, 'Invalid Encoding');
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
---EXPECTF--
+--EXPECT--
bool(true)
-
-Warning: xml_parser_set_option(): Unsupported target encoding "Invalid Encoding" in %s on line %d
-bool(false)
+xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding
$xmlParser = xml_parser_create();
-var_dump(xml_parser_set_option($xmlParser, 42, 1));
+try {
+ xml_parser_set_option($xmlParser, 42, 1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
---EXPECTF--
-Warning: xml_parser_set_option(): Unknown option in %s on line %d
-bool(false)
+--EXPECT--
+xml_parser_set_option(): Argument #2 ($option) must be a PHP_XML_OPTION_* constant
} else if (strcasecmp(encoding_param, "US-ASCII") == 0) {
encoding = (XML_Char*)"US-ASCII";
} else {
- php_error_docref(NULL, E_WARNING, "Unsupported source encoding \"%s\"", encoding_param);
- RETURN_FALSE;
+ zend_argument_value_error(1, "is not a supported source encoding");
+ RETURN_THROWS();
}
} else {
encoding = XML(default_encoding);
enc = xml_get_encoding((XML_Char*)Z_STRVAL_P(val));
if (enc == NULL) {
- php_error_docref(NULL, E_WARNING, "Unsupported target encoding \"%s\"", Z_STRVAL_P(val));
- RETURN_FALSE;
+ zend_argument_value_error(3, "is not a supported target encoding");
+ RETURN_THROWS();
}
parser->target_encoding = enc->name;
break;
}
default:
- php_error_docref(NULL, E_WARNING, "Unknown option");
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be a PHP_XML_OPTION_* constant");
+ RETURN_THROWS();
break;
}
RETVAL_TRUE;
RETURN_STRING((char *)parser->target_encoding);
break;
default:
- php_error_docref(NULL, E_WARNING, "Unknown option");
- RETURN_FALSE;
- break;
+ zend_argument_value_error(2, "must be a PHP_XML_OPTION_* constant");
+ RETURN_THROWS();
}
-
- RETVAL_FALSE; /* never reached */
}
/* }}} */
/** @generate-function-entries */
-function xml_parser_create(?string $encoding = null): XmlParser|false {}
+function xml_parser_create(?string $encoding = null): XmlParser {}
-function xml_parser_create_ns(?string $encoding = null, string $sep = ':'): XmlParser|false {}
+function xml_parser_create_ns(?string $encoding = null, string $sep = ':'): XmlParser {}
function xml_set_object(XmlParser $parser, object $obj): bool {}
/** @param string|int $value */
function xml_parser_set_option(XmlParser $parser, int $option, $value): bool {}
-function xml_parser_get_option(XmlParser $parser, int $option): string|int|false {}
+function xml_parser_get_option(XmlParser $parser, int $option): string|int {}
final class XMLParser
{
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 60a1f2421a3320374850aa5da7e995077961705e */
+ * Stub hash: b3c718c2aeba9a9c05b6cb281fd7ccaa3791d34e */
-ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_xml_parser_create, 0, 0, XmlParser, MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_xml_parser_create, 0, 0, XmlParser, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_xml_parser_create_ns, 0, 0, XmlParser, MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_xml_parser_create_ns, 0, 0, XmlParser, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, sep, IS_STRING, 0, "\':\'")
ZEND_END_ARG_INFO()
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_xml_parser_get_option, 0, 2, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_xml_parser_get_option, 0, 2, MAY_BE_STRING|MAY_BE_LONG)
ZEND_ARG_OBJ_INFO(0, parser, XmlParser, 0)
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
ZEND_END_ARG_INFO()