diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2017-12-19 22:16:45 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-12-19 22:16:45 +0100 |
| commit | b6131364f95af68159b1c17ab48f9523e439cb65 (patch) | |
| tree | 460004998061b52d52bd0d35a282d8da2c4928de | |
| parent | fc46c4b1061f54246a754dd7a32a41902062e652 (diff) | |
| download | php-git-b6131364f95af68159b1c17ab48f9523e439cb65.tar.gz | |
Return false for instanceof on literal
| -rw-r--r-- | Zend/tests/errmsg_041.phpt | 11 | ||||
| -rw-r--r-- | Zend/tests/instanceof_const.phpt | 10 | ||||
| -rw-r--r-- | Zend/zend_compile.c | 6 |
3 files changed, 14 insertions, 13 deletions
diff --git a/Zend/tests/errmsg_041.phpt b/Zend/tests/errmsg_041.phpt deleted file mode 100644 index bfcafd261d..0000000000 --- a/Zend/tests/errmsg_041.phpt +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -errmsg: instanceof expects an object instance, constant given ---FILE-- -<?php - -var_dump("abc" instanceof stdclass); - -echo "Done\n"; -?> ---EXPECTF-- -Fatal error: instanceof expects an object instance, constant given in %s on line %d diff --git a/Zend/tests/instanceof_const.phpt b/Zend/tests/instanceof_const.phpt new file mode 100644 index 0000000000..f662d91603 --- /dev/null +++ b/Zend/tests/instanceof_const.phpt @@ -0,0 +1,10 @@ +--TEST-- +Instanceof on literals returns false +--FILE-- +<?php + +var_dump("abc" instanceof stdclass); + +?> +--EXPECT-- +bool(false) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index a032188e11..63f9d57e76 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7463,8 +7463,10 @@ void zend_compile_instanceof(znode *result, zend_ast *ast) /* {{{ */ zend_compile_expr(&obj_node, obj_ast); if (obj_node.op_type == IS_CONST) { - zend_error_noreturn(E_COMPILE_ERROR, - "instanceof expects an object instance, constant given"); + zend_do_free(&obj_node); + result->op_type = IS_CONST; + ZVAL_FALSE(&result->u.constant); + return; } zend_compile_class_ref_ex(&class_node, class_ast, |
