diff options
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r-- | Zend/zend_compile.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index d43bb6f4a3..58fb3377d2 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1196,6 +1196,16 @@ zend_string *zend_type_to_string_resolved(zend_type type, zend_class_entry *scop } uint32_t type_mask = ZEND_TYPE_FULL_MASK(type); + if (type_mask & MAY_BE_STATIC) { + zend_string *name = ZSTR_KNOWN(ZEND_STR_STATIC); + if (scope) { + zend_class_entry *called_scope = zend_get_called_scope(EG(current_execute_data)); + if (called_scope) { + name = called_scope->name; + } + } + str = add_type_string(str, name); + } if (type_mask & MAY_BE_CALLABLE) { str = add_type_string(str, ZSTR_KNOWN(ZEND_STR_CALLABLE)); } @@ -5502,6 +5512,10 @@ static zend_type zend_compile_single_typename(zend_ast *ast) { ZEND_ASSERT(!(ast->attr & ZEND_TYPE_NULLABLE)); if (ast->kind == ZEND_AST_TYPE) { + if (ast->attr == IS_STATIC && !CG(active_class_entry) && zend_is_scope_known()) { + zend_error_noreturn(E_COMPILE_ERROR, + "Cannot use \"static\" when no class scope is active"); + } return (zend_type) ZEND_TYPE_INIT_CODE(ast->attr, 0, 0); } else { zend_string *class_name = zend_ast_get_str(ast); @@ -5657,7 +5671,7 @@ static zend_type zend_compile_typename( ZSTR_VAL(type_str)); } - if ((type_mask & MAY_BE_OBJECT) && ZEND_TYPE_HAS_CLASS(type)) { + if ((type_mask & MAY_BE_OBJECT) && (ZEND_TYPE_HAS_CLASS(type) || (type_mask & MAY_BE_STATIC))) { zend_string *type_str = zend_type_to_string(type); zend_error_noreturn(E_COMPILE_ERROR, "Type %s contains both object and a class type, which is redundant", |