summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-01-31 12:25:51 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-01-31 13:52:06 +0100
commitaad39879f2d2e89de105c4f87d334ee129b4321c (patch)
treec4a0615c40ddaa3596e1c29e4ccbcdf2ae197c05 /Zend/zend_compile.c
parent3d39479f4d7c86c66aa92fc5d0d97fb660109ee9 (diff)
downloadphp-git-aad39879f2d2e89de105c4f87d334ee129b4321c.tar.gz
Remove bareword fallback for constants
Access to undefined constants will now always result in an Error exception being thrown. This required quite a few test changes, because there were many buggy tests that unintentionally used bareword fallback in combination with error suppression.
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index d153bf79f4..b56356660b 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -7643,19 +7643,13 @@ void zend_compile_const(znode *result, zend_ast *ast) /* {{{ */
opline = zend_emit_op_tmp(result, ZEND_FETCH_CONSTANT, NULL, NULL);
opline->op2_type = IS_CONST;
- if (is_fully_qualified) {
+ if (is_fully_qualified || !FC(current_namespace)) {
opline->op2.constant = zend_add_const_name_literal(
resolved_name, 0);
} else {
- opline->op1.num = IS_CONSTANT_UNQUALIFIED;
- if (FC(current_namespace)) {
- opline->op1.num |= IS_CONSTANT_IN_NAMESPACE;
- opline->op2.constant = zend_add_const_name_literal(
- resolved_name, 1);
- } else {
- opline->op2.constant = zend_add_const_name_literal(
- resolved_name, 0);
- }
+ opline->op1.num = IS_CONSTANT_UNQUALIFIED_IN_NAMESPACE;
+ opline->op2.constant = zend_add_const_name_literal(
+ resolved_name, 1);
}
opline->extended_value = zend_alloc_cache_slot();
}
@@ -7985,7 +7979,8 @@ void zend_compile_const_expr_const(zend_ast **ast_ptr) /* {{{ */
}
zend_ast_destroy(ast);
- *ast_ptr = zend_ast_create_constant(resolved_name, !is_fully_qualified ? IS_CONSTANT_UNQUALIFIED : 0);
+ *ast_ptr = zend_ast_create_constant(resolved_name,
+ !is_fully_qualified && FC(current_namespace) ? IS_CONSTANT_UNQUALIFIED_IN_NAMESPACE : 0);
}
/* }}} */