<?php
function test1() {
- var_dump(func_get_arg(-10));
- var_dump(func_get_arg(0));
- var_dump(func_get_arg(1));
+ try {
+ var_dump(func_get_arg(-10));
+ } catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
+
+ try {
+ var_dump(func_get_arg(0));
+ } catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
+ try {
+ var_dump(func_get_arg(1));
+ } catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
}
function test2($a) {
- var_dump(func_get_arg(0));
- var_dump(func_get_arg(1));
+ try {
+ var_dump(func_get_arg(0));
+ } catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
+ try {
+ var_dump(func_get_arg(1));
+ } catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
}
function test3($a, $b) {
- var_dump(func_get_arg(0));
- var_dump(func_get_arg(1));
- var_dump(func_get_arg(2));
+ try {
+ var_dump(func_get_arg(0));
+ } catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
+ try {
+ var_dump(func_get_arg(1));
+ } catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
+ try {
+ var_dump(func_get_arg(2));
+ } catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
}
test1();
class test {
static function test1($a) {
- var_dump(func_get_arg(0));
- var_dump(func_get_arg(1));
+ try {
+ var_dump(func_get_arg(0));
+ } catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
+ try {
+ var_dump(func_get_arg(1));
+ } catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
}
}
test::test1(1);
-var_dump(func_get_arg(1));
+try {
+ var_dump(func_get_arg(1));
+} catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
echo "Done\n";
?>
--EXPECTF--
-Warning: func_get_arg(): The argument number should be >= 0 in %s on line %d
-bool(false)
-
-Warning: func_get_arg(): Argument 0 not passed to function in %s on line %d
-bool(false)
-
-Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
-bool(false)
-
-Warning: func_get_arg(): The argument number should be >= 0 in %s on line %d
-bool(false)
+func_get_arg(): Argument #1 ($arg_num) must be greater than or equal to 0
+func_get_arg(): Argument 0 not passed to function
+func_get_arg(): Argument 1 not passed to function
+func_get_arg(): Argument #1 ($arg_num) must be greater than or equal to 0
int(10)
-
-Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
-bool(false)
+func_get_arg(): Argument 1 not passed to function
int(1)
-
-Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
-bool(false)
+func_get_arg(): Argument 1 not passed to function
Exception: Too few arguments to function test2(), 0 passed in %s002.php on line %d and exactly 1 expected
int(1)
int(2)
-
-Warning: func_get_arg(): Argument 2 not passed to function in %s on line %d
-bool(false)
-
-Warning: func_get_arg(): The argument number should be >= 0 in %s on line %d
-bool(false)
-
-Warning: func_get_arg(): Argument 0 not passed to function in %s on line %d
-bool(false)
-
-Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
-bool(false)
-Exception: Too few arguments to function test3(), 1 passed in %s002.php on line %d and exactly 2 expected
+func_get_arg(): Argument 2 not passed to function
+func_get_arg(): Argument #1 ($arg_num) must be greater than or equal to 0
+func_get_arg(): Argument 0 not passed to function
+func_get_arg(): Argument 1 not passed to function
+Exception: Too few arguments to function test3(), 1 passed in %s on line %d and exactly 2 expected
int(1)
int(2)
-
-Warning: func_get_arg(): Argument 2 not passed to function in %s on line %d
-bool(false)
+func_get_arg(): Argument 2 not passed to function
int(1)
-
-Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
-bool(false)
-
-Warning: func_get_arg(): Called from the global scope - no function context in %s on line %d
-bool(false)
+func_get_arg(): Argument 1 not passed to function
+func_get_arg() cannot be called from the global scope
Done
}
test::test1(1);
-var_dump(func_get_args());
-echo "Done\n";
+try {
+ var_dump(func_get_args());
+} catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+
?>
--EXPECTF--
array(0) {
[0]=>
int(1)
}
-
-Warning: func_get_args(): Called from the global scope - no function context in %s on line %d
-bool(false)
-Done
+func_get_args() cannot be called from the global scope
<?php
var_dump(strncmp("", "", 100));
-var_dump(strncmp("aef", "dfsgbdf", -1));
+try {
+ var_dump(strncmp("aef", "dfsgbdf", -1));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
var_dump(strncmp("fghjkl", "qwer", 0));
var_dump(strncmp("qwerty", "qwerty123", 6));
var_dump(strncmp("qwerty", "qwerty123", 7));
-echo "Done\n";
?>
---EXPECTF--
+--EXPECT--
int(0)
-
-Warning: Length must be greater than or equal to 0 in %s on line %d
-bool(false)
+strncmp(): Argument #3 ($len) must be greater than or equal to 0
int(0)
int(0)
int(-1)
-Done
--FILE--
<?php
-var_dump(strncasecmp("", "", -1));
+try {
+ var_dump(strncasecmp("", "", -1));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+
var_dump(strncasecmp("aef", "dfsgbdf", 0));
var_dump(strncasecmp("aef", "dfsgbdf", 10));
var_dump(strncasecmp("qwe", "qwer", 3));
var_dump(strncasecmp("q123", "Q123", 3));
var_dump(strncasecmp("01", "01", 1000));
-echo "Done\n";
?>
---EXPECTF--
-Warning: Length must be greater than or equal to 0 in %s on line %d
-bool(false)
+--EXPECT--
+strncasecmp(): Argument #3 ($len) must be greater than or equal to 0
int(0)
int(-3)
int(0)
int(2)
int(0)
int(0)
-Done
var_dump(property_exists($foo,"pp3"));
var_dump(property_exists($foo,"nonexistent"));
var_dump(property_exists($foo,""));
-var_dump(property_exists(array(),"test"));
-var_dump(property_exists(1,"test"));
-var_dump(property_exists(true,"test"));
+
+try {
+ var_dump(property_exists(array(), "test"));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump(property_exists(1, "test"));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump(property_exists(3.14, "test"));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump(property_exists(true, "test"));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump(property_exists(null, "test"));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
$foo->bar();
$bar = new bar;
$bar->test();
-echo "Done\n";
?>
---EXPECTF--
+--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
-
-Warning: First parameter must either be an object or the name of an existing class in %s on line %d
-NULL
-
-Warning: First parameter must either be an object or the name of an existing class in %s on line %d
-NULL
-
-Warning: First parameter must either be an object or the name of an existing class in %s on line %d
-NULL
+property_exists(): Argument #1 ($object_or_class) must be of type object|string, array given
+property_exists(): Argument #1 ($object_or_class) must be of type object|string, int given
+property_exists(): Argument #1 ($object_or_class) must be of type object|string, float given
+property_exists(): Argument #1 ($object_or_class) must be of type object|string, bool given
+property_exists(): Argument #1 ($object_or_class) must be of type object|string, null given
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
-Done
<?php
var_dump(trigger_error("error"));
-var_dump(trigger_error("error", -1));
-var_dump(trigger_error("error", 0));
+
+try {
+ var_dump(trigger_error("error", -1));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump(trigger_error("error", 0));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+
var_dump(trigger_error("error", E_USER_WARNING));
var_dump(trigger_error("error", E_USER_DEPRECATED));
-echo "Done\n";
?>
--EXPECTF--
Notice: error in %s on line %d
bool(true)
-
-Warning: Invalid error type specified in %s on line %d
-bool(false)
-
-Warning: Invalid error type specified in %s on line %d
-bool(false)
+trigger_error(): Argument #2 ($error_type) must be one of E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE, or E_USER_DEPRECATED
+trigger_error(): Argument #2 ($error_type) must be one of E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE, or E_USER_DEPRECATED
Warning: error in %s on line %d
bool(true)
Deprecated: error in %s on line %d
bool(true)
-Done
--FILE--
<?php
-var_dump(func_get_arg(1));
+try {
+ var_dump(func_get_arg(1));
+} catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
function bar() {
var_dump(func_get_arg(1));
bar(func_get_arg(1));
}
-foo(1,2);
+try {
+ foo(1,2);
+} catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
-echo "Done\n";
?>
---EXPECTF--
-Warning: func_get_arg(): Called from the global scope - no function context in %s on line %d
-bool(false)
-
-Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
-bool(false)
-Done
+--EXPECT--
+func_get_arg() cannot be called from the global scope
+func_get_arg(): Argument 1 not passed to function
--FILE--
<?php
-set_exception_handler("fo");
-set_exception_handler(array("", ""));
+try {
+ set_exception_handler("fo");
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ set_exception_handler(array("", ""));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
-echo "Done\n";
?>
---EXPECTF--
-Warning: set_exception_handler(): Argument #1 ($exception_handler) must be a valid callback in %s on line %d
-
-Warning: set_exception_handler(): Argument #1 ($exception_handler) must be a valid callback in %s on line %d
-Done
+--EXPECT--
+set_exception_handler(): Argument #1 ($exception_handler) must be a valid callback
+set_exception_handler(): Argument #1 ($exception_handler) must be a valid callback
--TEST--
-Testing func_get_args()
+Testing func_get_args() throws error when called from the global scope
--FILE--
<?php
-func_get_args();
+try {
+ func_get_args();
+} catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
-Warning: func_get_args(): Called from the global scope - no function context in %s on line 3
+--EXPECT--
+func_get_args() cannot be called from the global scope
ZEND_FE(strlen, arginfo_strlen)
ZEND_FE(strcmp, arginfo_strcmp)
ZEND_FE(strncmp, arginfo_strncmp)
- ZEND_FE(strcasecmp, arginfo_strcmp)
- ZEND_FE(strncasecmp, arginfo_strncmp)
+ ZEND_FE(strcasecmp, arginfo_strcasecmp)
+ ZEND_FE(strncasecmp, arginfo_strncasecmp)
ZEND_FE(error_reporting, arginfo_error_reporting)
ZEND_FE(define, arginfo_define)
ZEND_FE(defined, arginfo_defined)
}
if (requested_offset < 0) {
- zend_error(E_WARNING, "func_get_arg(): The argument number should be >= 0");
- RETURN_FALSE;
+ zend_argument_value_error(1, "must be greater than or equal to 0");
+ RETURN_THROWS();
}
ex = EX(prev_execute_data);
if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) {
- zend_error(E_WARNING, "func_get_arg(): Called from the global scope - no function context");
- RETURN_FALSE;
+ zend_throw_error(NULL, "func_get_arg() cannot be called from the global scope");
+ RETURN_THROWS();
}
if (zend_forbid_dynamic_call("func_get_arg()") == FAILURE) {
- RETURN_FALSE;
+ RETURN_THROWS();
}
arg_count = ZEND_CALL_NUM_ARGS(ex);
if ((zend_ulong)requested_offset >= arg_count) {
- zend_error(E_WARNING, "func_get_arg(): Argument " ZEND_LONG_FMT " not passed to function", requested_offset);
- RETURN_FALSE;
+ zend_throw_error(NULL, "func_get_arg(): Argument " ZEND_LONG_FMT " not passed to function", requested_offset);
+ RETURN_THROWS();
}
first_extra_arg = ex->func->op_array.num_args;
zend_execute_data *ex = EX(prev_execute_data);
if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) {
- zend_error(E_WARNING, "func_get_args(): Called from the global scope - no function context");
- RETURN_FALSE;
+ zend_throw_error(NULL, "func_get_args() cannot be called from the global scope");
+ RETURN_THROWS();
}
if (zend_forbid_dynamic_call("func_get_args()") == FAILURE) {
- RETURN_FALSE;
+ RETURN_THROWS();
}
arg_count = ZEND_CALL_NUM_ARGS(ex);
ZEND_PARSE_PARAMETERS_END();
if (len < 0) {
- zend_error(E_WARNING, "Length must be greater than or equal to 0");
- RETURN_FALSE;
+ zend_argument_value_error(3, "must be greater than or equal to 0");
+ RETURN_THROWS();
}
RETURN_LONG(zend_binary_strncmp(ZSTR_VAL(s1), ZSTR_LEN(s1), ZSTR_VAL(s2), ZSTR_LEN(s2), len));
ZEND_PARSE_PARAMETERS_END();
if (len < 0) {
- zend_error(E_WARNING, "Length must be greater than or equal to 0");
- RETURN_FALSE;
+ zend_argument_value_error(3, "must be greater than or equal to 0");
+ RETURN_THROWS();
}
RETURN_LONG(zend_binary_strncasecmp(ZSTR_VAL(s1), ZSTR_LEN(s1), ZSTR_VAL(s2), ZSTR_LEN(s2), len));
if (scope) {
RETURN_STR_COPY(scope->name);
} else {
- zend_error(E_WARNING, "get_class() called without object from outside a class");
- RETURN_FALSE;
+ zend_throw_error(NULL, "get_class() without arguments must be called from within a class");
+ RETURN_THROWS();
}
}
ZEND_PARSE_PARAMETERS_NONE();
called_scope = zend_get_called_scope(execute_data);
- if (called_scope) {
- RETURN_STR_COPY(called_scope->name);
- } else {
- zend_class_entry *scope = zend_get_executed_scope();
- if (!scope) {
- zend_error(E_WARNING, "get_called_class() called from outside a class");
- }
+ if (!called_scope) {
+ zend_throw_error(NULL, "get_called_class() must be called from within a class");
+ RETURN_THROWS();
}
- RETURN_FALSE;
+
+ RETURN_STR_COPY(called_scope->name);
}
/* }}} */
} else if (Z_TYPE_P(object) == IS_OBJECT) {
ce = Z_OBJCE_P(object);
} else {
- zend_error(E_WARNING, "First parameter must either be an object or the name of an existing class");
- RETURN_NULL();
+ zend_argument_type_error(1, "must be of type object|string, %s given", zend_zval_type_name(object));
+ RETURN_THROWS();
}
property_info = zend_hash_find_ptr(&ce->properties_info, property);
case E_USER_DEPRECATED:
break;
default:
- zend_error(E_WARNING, "Invalid error type specified");
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be one of E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE,"
+ " or E_USER_DEPRECATED");
+ RETURN_THROWS();
break;
}
zend_error((int)error_type, "%s", message);
+ // TODO Change to void
RETURN_TRUE;
}
/* }}} */
if (Z_TYPE_P(error_handler) != IS_NULL) { /* NULL == unset */
if (!zend_is_callable(error_handler, 0, NULL)) {
zend_string *error_handler_name = zend_get_callable_name(error_handler);
- zend_error(E_WARNING, "%s(): Argument #1 ($error_handler) must be a valid callback", get_active_function_name());
+ zend_argument_type_error(1, "must be a valid callback");
zend_string_release_ex(error_handler_name, 0);
- return;
+ RETURN_THROWS();
}
}
ZVAL_COPY_VALUE(&EG(user_error_handler), tmp);
zend_stack_del_top(&EG(user_error_handlers));
}
+
+ // TODO Change to void
RETURN_TRUE;
}
/* }}} */
if (Z_TYPE_P(exception_handler) != IS_NULL) { /* NULL == unset */
if (!zend_is_callable(exception_handler, 0, NULL)) {
zend_string *exception_handler_name = zend_get_callable_name(exception_handler);
- zend_error(E_WARNING, "%s(): Argument #1 ($exception_handler) must be a valid callback", get_active_function_name());
+ zend_argument_type_error(1, "must be a valid callback");
zend_string_release_ex(exception_handler_name, 0);
- return;
+ RETURN_THROWS();
}
}
ZVAL_COPY_VALUE(&EG(user_exception_handler), tmp);
zend_stack_del_top(&EG(user_exception_handlers));
}
+
+ // TODO Change to void
RETURN_TRUE;
}
/* }}} */
/** @return mixed */
function func_get_arg(int $arg_num) {}
-function func_get_args(): array|false {}
+function func_get_args(): array {}
function strlen(string $str): int {}
function strcmp(string $str1, string $str2): int {}
-function strncmp(string $str1, string $str2, int $len): int|false {}
+function strncmp(string $str1, string $str2, int $len): int {}
+
+function strcasecmp(string $str1, string $str2): int {}
+
+function strncasecmp(string $str1, string $str2, int $len): int {}
function error_reporting($new_error_level = UNKNOWN): int {}
function defined(string $constant_name): bool {}
-function get_class(object $object = UNKNOWN): string|false {}
+function get_class(object $object = UNKNOWN): string {}
-function get_called_class(): string|false {}
+function get_called_class(): string {}
function get_parent_class($object = UNKNOWN): string|false {}
function method_exists($object_or_class, string $method): bool {}
-function property_exists($object_or_class, string $property_name): ?bool {}
+function property_exists($object_or_class, string $property_name): bool {}
function class_exists(string $classname, bool $autoload = true): bool {}
ZEND_ARG_TYPE_INFO(0, arg_num, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_func_get_args, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_func_get_args, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strlen, 0, 1, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, str2, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strncmp, 0, 3, MAY_BE_LONG|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strncmp, 0, 3, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, str1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, str2, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, len, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_error_reporting, 0, 0, IS_LONG, 0)
+#define arginfo_strcasecmp arginfo_strcmp
+
+#define arginfo_strncasecmp arginfo_strncmp
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_error_reporting, 0, 0, IS_LONG, 1)
ZEND_ARG_INFO(0, new_error_level)
ZEND_END_ARG_INFO()
ZEND_ARG_TYPE_INFO(0, constant_name, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_get_class, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_class, 0, 0, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_get_called_class, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
-ZEND_END_ARG_INFO()
+#define arginfo_get_called_class arginfo_zend_version
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_get_parent_class, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_INFO(0, object)
ZEND_ARG_TYPE_INFO(0, method, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_property_exists, 0, 2, _IS_BOOL, 1)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_property_exists, 0, 2, _IS_BOOL, 0)
ZEND_ARG_INFO(0, object_or_class)
ZEND_ARG_TYPE_INFO(0, property_name, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_ARG_TYPE_INFO(0, autoload, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_included_files, 0, 0, IS_ARRAY, 0)
-ZEND_END_ARG_INFO()
+#define arginfo_get_included_files arginfo_func_get_args
-#define arginfo_get_required_files arginfo_get_included_files
+#define arginfo_get_required_files arginfo_func_get_args
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_trigger_error, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, message, IS_STRING, 0)
#define arginfo_restore_exception_handler arginfo_restore_error_handler
-#define arginfo_get_declared_classes arginfo_get_included_files
+#define arginfo_get_declared_classes arginfo_func_get_args
-#define arginfo_get_declared_traits arginfo_get_included_files
+#define arginfo_get_declared_traits arginfo_func_get_args
-#define arginfo_get_declared_interfaces arginfo_get_included_files
+#define arginfo_get_declared_interfaces arginfo_func_get_args
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_defined_functions, 0, 0, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, exclude_disabled, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
-#define arginfo_get_defined_vars arginfo_get_included_files
+#define arginfo_get_defined_vars arginfo_func_get_args
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_resource_type, 0, 1, IS_STRING, 0)
ZEND_ARG_INFO(0, res)
#define arginfo_gc_disable arginfo_gc_enable
-#define arginfo_gc_status arginfo_get_included_files
+#define arginfo_gc_status arginfo_func_get_args
}
echo "===PROBLEMS===\n";
-var_dump(property_exists(NULL, 'empty'));
-var_dump(property_exists(25,'empty'));
+try {
+ var_dump(property_exists(NULL, 'empty'));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump(property_exists(25,'empty'));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
var_dump(property_exists('',''));
var_dump(property_exists('A',''));
var_dump(property_exists('A','123'));
var_dump(property_exists(new A, 'init'));
var_dump(property_exists(new A, 'empty'));
?>
---EXPECTF--
+--EXPECT--
===A===
obj(A)::$a
bool(true)
obj(C)::$e
bool(false)
===PROBLEMS===
-
-Warning: First parameter must either be an object or the name of an existing class in %sproperty_exists.php on line %d
-NULL
-
-Warning: First parameter must either be an object or the name of an existing class in %sproperty_exists.php on line %d
-NULL
+property_exists(): Argument #1 ($object_or_class) must be of type object|string, null given
+property_exists(): Argument #1 ($object_or_class) must be of type object|string, int given
bool(false)
bool(false)
bool(false)
echo "\n-- Testing property_exists() function with incorrect arguments --\n";
$property_name = 'string_val';
-var_dump( property_exists(10, $property_name) );
+
+try {
+ var_dump( property_exists(10, $property_name) );
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
+--EXPECT--
*** Testing property_exists() : error conditions ***
-- Testing property_exists() function with incorrect arguments --
-
-Warning: First parameter must either be an object or the name of an existing class in %sproperty_exists_error.php on line %d
-NULL
+property_exists(): Argument #1 ($object_or_class) must be of type object|string, int given
--FILE--
<?php
-var_dump(strncmp("test ", "e", -1));
+try {
+ var_dump(strncmp("test ", "e", -1));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
var_dump(strncmp("test ", "e", 10));
var_dump(strncmp("test ", "e", 0));
-var_dump(strncasecmp("test ", "E", -1));
+try {
+ var_dump(strncasecmp("test ", "E", -1));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
var_dump(strncasecmp("test ", "E", 10));
var_dump(strncasecmp("test ", "E", 0));
-echo "Done\n";
?>
--EXPECTF--
-Warning: Length must be greater than or equal to 0 in %s on line %d
-bool(false)
+strncmp(): Argument #3 ($len) must be greater than or equal to 0
int(%d)
int(0)
-
-Warning: Length must be greater than or equal to 0 in %s on line %d
-bool(false)
+strncasecmp(): Argument #3 ($len) must be greater than or equal to 0
int(%d)
int(0)
-Done
$str1 = 'string_val';
$str2 = 'string_val';
-echo "\n-- Testing strncasecmp() function with invalid argument --";
+echo "-- Testing strncasecmp() function with invalid argument --\n";
$len = -10;
-var_dump( strncasecmp($str1, $str2, $len) );
-echo "*** Done ***\n";
+
+try {
+ var_dump( strncasecmp($str1, $str2, $len) );
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+
?>
---EXPECTF--
+--EXPECT--
*** Testing strncasecmp() function: error conditions ***
-
-- Testing strncasecmp() function with invalid argument --
-Warning: Length must be greater than or equal to 0 in %s on line %d
-bool(false)
-*** Done ***
+strncasecmp(): Argument #3 ($len) must be greater than or equal to 0
/* Invalid argument for $len */
$len = -10;
-var_dump( strncmp($str1, $str2, $len) );
-echo "*** Done ***\n";
+
+try {
+ var_dump( strncmp($str1, $str2, $len) );
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+
?>
---EXPECTF--
+--EXPECT--
*** Testing strncmp() function: error conditions ***
-
-Warning: Length must be greater than or equal to 0 in %s on line %d
-bool(false)
-*** Done ***
+strncmp(): Argument #3 ($len) must be greater than or equal to 0
--FILE--
<?php
-var_dump (func_get_arg(0));
+try {
+ var_dump(func_get_arg(0));
+} catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
-Warning: func_get_arg(): Called from the global scope - no function context in %s on line %d
-bool(false)
+--EXPECT--
+func_get_arg() cannot be called from the global scope
function foo($a)
{
- var_dump(func_get_arg(2));
+ try {
+ var_dump(func_get_arg(2));
+ } catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
}
foo(2, 3);
-echo "\n";
?>
---EXPECTF--
-Warning: func_get_arg(): Argument 2 not passed to function in %s on line %d
-bool(false)
+--EXPECT--
+func_get_arg(): Argument 2 not passed to function
function foo($a)
{
$a=5;
- echo func_get_arg(-1);
- echo func_get_arg(2);
+ try {
+ echo func_get_arg(-1);
+ } catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
+
+ try {
+ echo func_get_arg(2);
+ } catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
}
foo(2);
-echo "\n";
-?>
---EXPECTF--
-Warning: func_get_arg(): The argument number should be >= 0 in %s on line %d
-Warning: func_get_arg(): Argument 2 not passed to function in %s on line %d
+?>
+--EXPECT--
+func_get_arg(): Argument #1 ($arg_num) must be greater than or equal to 0
+func_get_arg(): Argument 2 not passed to function
--FILE--
<?php
-var_dump(func_get_args());
+try {
+ var_dump(func_get_args());
+} catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTREGEX--
-Warning\: func_get_args\(\)\: Called from the global scope - no function context in \S* on line 3
-bool\(false\)
+--EXPECT--
+func_get_args() cannot be called from the global scope