retformat != SUNFUNCS_RET_STRING &&
retformat != SUNFUNCS_RET_DOUBLE)
{
- php_error_docref(NULL, E_WARNING, "Wrong return format given, pick one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or SUNFUNCS_RET_DOUBLE");
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, or SUNFUNCS_RET_DOUBLE");
+ RETURN_THROWS();
}
altitude = 90 - zenith;
--- /dev/null
+--TEST--
+Test error condition of date_sunrise() and date_sunset()
+--FILE--
+<?php
+
+try {
+ date_sunrise(time(), 3);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ date_sunset(time(), 4);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+?>
+--EXPECT--
+date_sunrise(): Argument #2 ($returnFormat) must be one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, or SUNFUNCS_RET_DOUBLE
+date_sunset(): Argument #2 ($returnFormat) must be one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, or SUNFUNCS_RET_DOUBLE
finfo_object *obj = Z_FINFO_P(object); \
finfo = obj->ptr; \
if (!finfo) { \
- php_error_docref(NULL, E_WARNING, "The invalid fileinfo object."); \
- RETURN_FALSE; \
+ zend_throw_error(NULL, "Invalid finfo object"); \
+ RETURN_THROWS(); \
} \
}
}
if (magic_load(finfo->magic, file) == -1) {
- php_error_docref(NULL, E_WARNING, "Failed to load magic database at '%s'.", file);
+ php_error_docref(NULL, E_WARNING, "Failed to load magic database at \"%s\"", file);
magic_close(finfo->magic);
efree(finfo);
if (object) {
magic = magic_open(MAGIC_MIME_TYPE);
if (magic_load(magic, NULL) == -1) {
- php_error_docref(NULL, E_WARNING, "Failed to load magic database.");
+ php_error_docref(NULL, E_WARNING, "Failed to load magic database");
goto common;
}
} else if (object) {
Warning: finfo_open(): offset `b' invalid in %sbug61964-mb.php on line %d
-Warning: finfo_open(): Failed to load magic database at '%sbug61964-mb'. in %sbug61964-mb.php on line %d
+Warning: finfo_open(): Failed to load magic database at "%sbug61964-mb" in %sbug61964-mb.php on line %d
DONE: testing dir with files
Warning: finfo_open(): offset `b' invalid in %sbug61964.php on line %d
-Warning: finfo_open(): Failed to load magic database at '%sbug61964'. in %sbug61964.php on line %d
+Warning: finfo_open(): Failed to load magic database at "%sbug61964" in %sbug61964.php on line %d
DONE: testing dir with files
<br />
<b>Warning</b>: finfo_open(%s�c): Failed to open stream: No such file or directory in <b>%sbug68996.php</b> on line <b>%d</b><br />
<br />
-<b>Warning</b>: finfo_open(): Failed to load magic database at '%s�c'. in <b>%sbug68996.php</b> on line <b>%d</b><br />
+<b>Warning</b>: finfo_open(): Failed to load magic database at "%s�c" in <b>%s</b> on line <b>%d</b><br />
var_dump($finfo);
?>
--EXPECTF--
-Warning: finfo_open(): Failed to load magic database at '%sbug71527私はガラスを食べられます.magic'. in %sbug71527-mb.php on line %d
+Warning: finfo_open(): Failed to load magic database at "%sbug71527私はガラスを食べられます.magic" in %sbug71527-mb.php on line %d
bool(false)
var_dump($finfo);
?>
--EXPECTF--
-Warning: finfo_open(): Failed to load magic database at '%sbug71527.magic'. in %sbug71527.php on line %d
+Warning: finfo_open(): Failed to load magic database at "%sbug71527.magic" in %sbug71527.php on line %d
bool(false)
Warning: finfo_open(%s123): Failed to open stream: No such file or directory in %s on line %d
-Warning: finfo_open(): Failed to load magic database at '%s123'. in %s on line %d
+Warning: finfo_open(): Failed to load magic database at "%s123" in %s on line %d
bool(false)
Warning: finfo_open(%s1): Failed to open stream: No such file or directory in %s on line %d
Warning: finfo_open(%s1): Failed to open stream: No such file or directory in %s on line %d
-Warning: finfo_open(): Failed to load magic database at '%s1'. in %s on line %d
+Warning: finfo_open(): Failed to load magic database at "%s1" in %s on line %d
bool(false)
Warning: finfo_open(%sinexistent): Failed to open stream: No such file or directory in %s on line %d
Warning: finfo_open(%sinexistent): Failed to open stream: No such file or directory in %s on line %d
-Warning: finfo_open(): Failed to load magic database at '%sinexistent'. in %s on line %d
+Warning: finfo_open(): Failed to load magic database at "%sinexistent" in %s on line %d
bool(false)
Warning: finfo_open(%sfoobarfile): Failed to open stream: No such file or directory in %sfinfo_open_error.php on line %d
-Warning: finfo_open(): Failed to load magic database at '%sfoobarfile'. in %sfinfo_open_error.php on line %d
+Warning: finfo_open(): Failed to load magic database at "%sfoobarfile" in %sfinfo_open_error.php on line %d
bool(false)
Warning: finfo_open(): using regular magic file `%smagic' in %sfinfo_open_error.php on line %d
} \
}
+#define ERROR_ARG_POS(arg_num) (getThis() ? (arg_num-1) : (arg_num))
+
static HashTable classes;
static zend_object_handlers mysqli_object_handlers;
static zend_object_handlers mysqli_object_driver_handlers;
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
if (fetchtype < MYSQLI_ASSOC || fetchtype > MYSQLI_BOTH) {
- php_error_docref(NULL, E_WARNING, "The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH");
- RETURN_FALSE;
+ zend_argument_value_error(ERROR_ARG_POS(2), "must be one of MYSQLI_NUM, MYSQLI_ASSOC, or MYSQLI_BOTH");
+ RETURN_THROWS();
}
php_mysqli_fetch_into_hash_aux(return_value, result, fetchtype);
{
*p_copy++ = v;
} else if (warned == FALSE) {
- php_error_docref(NULL, E_WARNING, "Transaction name truncated. Must be only [0-9A-Za-z\\-_=]+");
+ php_error_docref(NULL, E_WARNING, "Transaction name has been truncated, since it can only contain the A-Z, a-z, 0-9, \"\\\", \"-\", \"_\", and \"=\" characters");
warned = TRUE;
}
++p_orig;
break;
default:
- php_error_docref(NULL, E_WARNING, "Undefined fieldtype %c (parameter %d)", types[ofs], i + num_extra_args + 1);
+ zend_argument_value_error(num_extra_args, "must only contain the \"b\", \"d\", \"i\", \"s\" type specifiers");
rc = 1;
goto end_1;
}
type = MYSQL_TYPE_VAR_STRING;
break;
default:
- /* We count parameters from 1 */
- php_error_docref(NULL, E_WARNING, "Undefined fieldtype %c (parameter %d)", types[i], i + num_extra_args + 1);
+ zend_argument_value_error(num_extra_args, "must only contain the \"b\", \"d\", \"i\", \"s\" type specifiers");
ret = FAIL;
mysqlnd_stmt_free_param_bind(stmt->stmt, params);
goto end;
if (!$mysqli->commit(0 , "tx_name0123")) {
printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error);
}
- if (!$mysqli->commit(0 , "*/ nonsense")) {
- printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error);
- }
- if (!$mysqli->commit(0 , "tx_name ulf вендел")) {
- printf("[014] [%d] %s\n", $mysqli->errno, $mysqli->error);
- }
- if (!$mysqli->commit(0 , "tx_name \t\n\r\b")) {
- printf("[015] [%d] %s\n", $mysqli->errno, $mysqli->error);
- }
+
+ var_dump($mysqli->commit(0 , "*/ nonsense"));
+
+ var_dump($mysqli->commit(0 , "tx_name ulf вендел"));
+
+ var_dump($mysqli->commit(0 , "tx_name \t\n\r\b"));
+
if (!$mysqli->commit(MYSQLI_TRANS_COR_AND_CHAIN | MYSQLI_TRANS_COR_NO_RELEASE , "tx_name")) {
printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error);
}
--EXPECTF--
mysqli object is not fully initialized
-Warning: mysqli::commit(): Transaction name truncated. Must be only [0-9A-Za-z\-_=]+ in %s on line %d
+Warning: mysqli::commit(): Transaction name has been truncated, since it can only contain the A-Z, a-z, 0-9, "\", "-", "_", and "=" characters in %s on line %d
+bool(true)
-Warning: mysqli::commit(): Transaction name truncated. Must be only [0-9A-Za-z\-_=]+ in %s on line %d
+Warning: mysqli::commit(): Transaction name has been truncated, since it can only contain the A-Z, a-z, 0-9, "\", "-", "_", and "=" characters in %s on line %d
+bool(true)
-Warning: mysqli::commit(): Transaction name truncated. Must be only [0-9A-Za-z\-_=]+ in %s on line %d
+Warning: mysqli::commit(): Transaction name has been truncated, since it can only contain the A-Z, a-z, 0-9, "\", "-", "_", and "=" characters in %s on line %d
+bool(true)
my_mysqli object is already closed
done!
$illegal_mode = mt_rand(-10000, 10000);
} while (in_array($illegal_mode, array(MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH)));
// NOTE: for BC reasons with ext/mysql, ext/mysqli accepts invalid result modes.
- $tmp = mysqli_fetch_array($res, $illegal_mode);
- if (false !== $tmp)
- printf("[013] Expecting boolean/false although, got %s/%s. [%d] %s\n",
- gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
+ try {
+ mysqli_fetch_array($res, $illegal_mode);
+ } catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
- $tmp = mysqli_fetch_array($res, $illegal_mode);
- if (false !== $tmp)
- printf("[014] Expecting boolean/false, got %s/%s. [%d] %s\n",
- gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
+ try {
+ mysqli_fetch_array($res, $illegal_mode);
+ } catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
mysqli_free_result($res);
["e"]=>
string(1) "1"
}
-
-Warning: mysqli_fetch_array(): The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH in %s on line %d
-
-Warning: mysqli_fetch_array(): The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH in %s on line %d
+mysqli_fetch_array(): Argument #2 ($fetchtype) must be one of MYSQLI_NUM, MYSQLI_ASSOC, or MYSQLI_BOTH
+mysqli_fetch_array(): Argument #2 ($fetchtype) must be one of MYSQLI_NUM, MYSQLI_ASSOC, or MYSQLI_BOTH
mysqli_result object is already closed
done!
$illegal_mode = mt_rand(-10000, 10000);
} while (in_array($illegal_mode, array(MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH)));
// NOTE: for BC reasons with ext/mysql, ext/mysqli accepts invalid result modes.
- $tmp = $res->fetch_array($illegal_mode);
- if (false !== $tmp)
- printf("[013] Expecting boolean/false although, got %s/%s. [%d] %s\n",
- gettype($tmp), $tmp, $mysqli->errno, $mysqli->error);
+ try {
+ $res->fetch_array($illegal_mode);
+ } catch (Error $exception) {
+ echo $exception->getMessage() . "\n";
+ }
- $tmp = $res->fetch_array($illegal_mode);
- if (false !== $tmp)
- printf("[014] Expecting boolean/false, got %s/%s. [%d] %s\n",
- gettype($tmp), $tmp, $mysqli->errno, $mysqli->error);
+ try {
+ $res->fetch_array($illegal_mode);
+ } catch (Error $exception) {
+ echo $exception->getMessage() . "\n";
+ }
$res->free_result();
["e"]=>
string(1) "1"
}
-
-Warning: mysqli_result::fetch_array(): The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH in %s on line %d
-
-Warning: mysqli_result::fetch_array(): The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH in %s on line %d
+mysqli_result::fetch_array(): Argument #1 ($result_type) must be one of MYSQLI_NUM, MYSQLI_ASSOC, or MYSQLI_BOTH
+mysqli_result::fetch_array(): Argument #1 ($result_type) must be one of MYSQLI_NUM, MYSQLI_ASSOC, or MYSQLI_BOTH
mysqli_result object is already closed
done!
}
try {
- if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "aa", $id, $label)))
- printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
- } catch (\ArgumentCountError $e) {
+ mysqli_stmt_bind_param($stmt, "aa", $id, $label);
+ } catch (ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
try {
- if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "ia", $id, $label)))
- printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
- } catch (\ArgumentCountError $e) {
+ mysqli_stmt_bind_param($stmt, "ia", $id, $label);
+ } catch (ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
<?php
require_once("clean_table.inc");
?>
---EXPECTF--
+--EXPECT--
The number of variables must match the number of parameters in the prepared statement
mysqli_stmt_bind_param(): Argument #2 ($types) cannot be empty
The number of elements in the type definition string must match the number of bind variables
The number of elements in the type definition string must match the number of bind variables
The number of variables must match the number of parameters in the prepared statement
The number of elements in the type definition string must match the number of bind variables
-
-Warning: mysqli_stmt_bind_param(): Undefined fieldtype a (parameter 3) in %s on line %d
-
-Warning: mysqli_stmt_bind_param(): Undefined fieldtype a (parameter 4) in %s on line %d
+mysqli_stmt_bind_param(): Argument #2 ($types) must only contain the "b", "d", "i", "s" type specifiers
+mysqli_stmt_bind_param(): Argument #2 ($types) must only contain the "b", "d", "i", "s" type specifiers
done!
{
*p_copy++ = v;
} else if (warned == FALSE) {
- php_error_docref(NULL, E_WARNING, "Transaction name truncated. Must be only [0-9A-Za-z\\-_=]+");
+ php_error_docref(NULL, E_WARNING, "Transaction name has been truncated, since it can only contain the A-Z, a-z, 0-9, \"\\\", \"-\", \"_\", and \"=\" characters");
warned = TRUE;
}
++p_orig;
ce = zend_lookup_class(ret_class);
if (ce == NULL || !instanceof_function(ce, curce)) {
xmlFreeDoc(newdocp);
- php_error_docref(NULL, E_WARNING,
- "Expecting class compatible with %s, '%s' given", ZSTR_VAL(curclass_name), ZSTR_VAL(ret_class));
- RETURN_FALSE;
+ zend_argument_type_error(2, "must be a class name compatible with %s, \"%s\" given",
+ ZSTR_VAL(curclass_name), ZSTR_VAL(ret_class)
+ );
+ RETURN_THROWS();
}
object_init_ex(return_value, ce);