echo PHP_EOL . "*** Trying ";
var_dump($value);
try {
- var_dump($function($value));
+ var_dump($function($value));
} catch (\TypeException $e) {
- echo "*** Caught " . $e->getMessage() . PHP_EOL;
+ echo "*** Caught " . $e->getMessage() . PHP_EOL;
}
}
}
*** Trying resource(%d) of type (stream)
*** Caught Argument 1 passed to {closure}() must be of the type boolean, resource given, called in %s on line %d
-Done
\ No newline at end of file
+Done
foreach ($functions as $type => $function) {
echo "Testing $type:", PHP_EOL;
try {
- var_dump($function());
+ var_dump($function());
} catch (TypeException $e) {
- echo "*** Caught " . $e->getMessage() . PHP_EOL;
+ echo "*** Caught " . $e->getMessage() . PHP_EOL;
}
}
echo PHP_EOL . "Done";
Testing bool nullable:
NULL
-Done
\ No newline at end of file
+Done
foreach ($functions as $type => $function) {
echo "Testing $type:", PHP_EOL;
try {
- var_dump($function(null));
+ var_dump($function(null));
} catch (TypeException $e) {
- echo "*** Caught " . $e->getMessage() . PHP_EOL;
+ echo "*** Caught " . $e->getMessage() . PHP_EOL;
}
}
Testing bool nullable:
NULL
-Done
\ No newline at end of file
+Done
echo "*** Trying ";
var_dump($value);
try {
- var_dump($function($value));
+ var_dump($function($value));
} catch (TypeException $e) {
- echo "*** Caught " . $e->getMessage() . PHP_EOL;
+ echo "*** Caught " . $e->getMessage() . PHP_EOL;
}
}
}
*** Trying resource(5) of type (stream)
*** Caught Return value of {closure}() must be of the type boolean, resource returned in %s on line %d
-Done
\ No newline at end of file
+Done
echo PHP_EOL . "*** Trying ";
var_dump($value);
try {
- var_dump($function($value));
+ var_dump($function($value));
} catch (TypeException $e) {
- echo "*** Caught " . $e->getMessage() . PHP_EOL;
+ echo "*** Caught " . $e->getMessage() . PHP_EOL;
}
}
}
*** Trying resource(5) of type (stream)
*** Caught Argument 1 passed to {closure}() must be of the type boolean, resource given, called in %s on line %d
-Done
\ No newline at end of file
+Done
$errored = false;
echo PHP_EOL . "*** Trying ", type($value), " value", PHP_EOL;
try {
- var_dump($function($value));
+ var_dump($function($value));
} catch (TypeException $e) {
- echo "*** Caught " . $e->getMessage() . PHP_EOL;
+ echo "*** Caught " . $e->getMessage() . PHP_EOL;
}
}
}
*** Trying resource value
*** Caught Argument 1 passed to {closure}() must be of the type boolean, resource given, called in %s on line %d
-Done
\ No newline at end of file
+Done
if (!quiet) {
zend_function *active_function = EG(current_execute_data)->func;
const char *class_name = active_function->common.scope ? active_function->common.scope->name->val : "";
-
+
zend_error(E_WARNING, "%s%s%s(): only one varargs specifier (* or +) is permitted",
class_name,
class_name[0] ? "::" : "",
/* }}} */
ZEND_API void zend_assert_valid_class_name(const zend_string *const_name) /* {{{ */
-{
+{
const scalar_typehint_info *info = zend_find_scalar_typehint(const_name);
-
+
if (info) {
zend_error_noreturn(E_COMPILE_ERROR, "\"%s\" cannot be used as a class name", info->name);
}
/* }}} */
static zend_always_inline zend_uchar zend_lookup_scalar_typehint_by_name(const zend_string *const_name) /* {{{ */
-{
+{
const scalar_typehint_info *info = zend_find_scalar_typehint(const_name);
-
+
if (info) {
if (const_name->len != info->name_len) {
zend_error_noreturn(E_COMPILE_ERROR, "\"%s\" cannot be used as a type declaration", const_name->val);
ZVAL_COPY_VALUE(&CG(declarables).ticks, &value_zv);
zval_dtor(&value_zv);
} else if (zend_string_equals_literal_ci(name, "encoding")) {
-
+
if (FAILURE == zend_declare_is_first_statement(ast)) {
zend_error_noreturn(E_COMPILE_ERROR, "Encoding declaration pragma must be "
"the very first statement in the script");
if (ast->child[1] != NULL) {
zend_error_noreturn(E_COMPILE_ERROR, "strict_types declaration must not "
- "use block mode");
+ "use block mode");
}
zend_const_expr_to_zval(&value_zv, value_ast);
if (Z_LVAL(value_zv) == 1) {
CG(active_op_array)->fn_flags |= ZEND_ACC_STRICT_TYPES;
}
-
+
} else {
zend_error(E_COMPILE_WARNING, "Unsupported declare '%s'", name->val);
}
if (type != 0) {
arg_info->type_hint = type;
} else {
-
+
if (zend_is_const_default_class_ref(type_ast)) {
class_name = zend_resolve_class_name_ast(type_ast);
} else {
}
if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
- zend_type_error("Argument %d passed to %s%s%s() must %s%s, %s%s given, called in %s on line %d",
- arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind,
+ zend_type_error("Argument %d passed to %s%s%s() must %s%s, %s%s given, called in %s on line %d",
+ arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind,
ptr->func->op_array.filename->val, ptr->opline->lineno);
} else {
zend_type_error("Argument %d passed to %s%s%s() must %s%s, %s%s given", arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind);
zend_arg_info *ret_info = EX(func)->common.arg_info - 1;
retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
-
- if (UNEXPECTED(!ret_info->class_name
- && ret_info->type_hint != IS_CALLABLE
+
+ if (UNEXPECTED(!ret_info->class_name
+ && ret_info->type_hint != IS_CALLABLE
&& !ZEND_SAME_FAKE_TYPE(ret_info->type_hint, Z_TYPE_P(retval_ptr)))) {
/* A cast or an error will happen, so separate the zval to prevent overwriting it */
-
+
if (EXPECTED((opline->extended_value & ZEND_RETURN_REF) == 0)) {
/* Does not return by reference */
SEPARATE_ZVAL(retval_ptr);
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(params)) {
param = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T);
if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
- do {
+ do {
zend_verify_arg_type(EX(func), arg_num, param, NULL, EX_USES_STRICT_TYPES());
if (Z_OPT_REFCOUNTED_P(param)) Z_ADDREF_P(param);
ZEND_HASH_FILL_ADD(param);
ZVAL_EMPTY_STRING(EX_VAR(opline->result.var));
}
ZEND_VM_NEXT_OPCODE();
-}
\ No newline at end of file
+}
+
ZVAL_EMPTY_STRING(EX_VAR(opline->result.var));
}
ZEND_VM_NEXT_OPCODE();
-}static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
+}
+
+static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE