Skip to content

Commit 3803151

Browse files
committed
fix failing tests for non-opcache
1 parent 05ca25a commit 3803151

11 files changed

+600
-561
lines changed

Zend/zend_ast.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ enum _zend_ast_kind {
133133
ZEND_AST_YIELD,
134134
ZEND_AST_COALESCE,
135135
ZEND_AST_ASSIGN_COALESCE,
136+
ZEND_AST_INNER_CLASS,
136137

137138
ZEND_AST_STATIC,
138139
ZEND_AST_WHILE,

Zend/zend_compile.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,6 +2268,7 @@ static void zend_adjust_for_fetch_type(zend_op *opline, znode *result, uint32_t
22682268

22692269
switch (type) {
22702270
case BP_VAR_R:
2271+
case BP_VAR_INNER_CLASS:
22712272
opline->result_type = IS_TMP_VAR;
22722273
result->op_type = IS_TMP_VAR;
22732274
return;
@@ -3253,6 +3254,8 @@ static zend_op *zend_compile_static_prop(znode *result, zend_ast *ast, uint32_t
32533254

32543255
if (delayed) {
32553256
opline = zend_delayed_emit_op(result, ZEND_FETCH_STATIC_PROP_R, &prop_node, NULL);
3257+
} else if (ast->kind == ZEND_AST_INNER_CLASS) {
3258+
opline = zend_emit_op(result, ZEND_FETCH_INNER_CLASS, &prop_node, NULL);
32563259
} else {
32573260
opline = zend_emit_op(result, ZEND_FETCH_STATIC_PROP_R, &prop_node, NULL);
32583261
}
@@ -11737,6 +11740,9 @@ static void zend_compile_expr_inner(znode *result, zend_ast *ast) /* {{{ */
1173711740
case ZEND_AST_PARENT_PROPERTY_HOOK_CALL:
1173811741
zend_compile_var(result, ast, BP_VAR_R, 0);
1173911742
return;
11743+
case ZEND_AST_INNER_CLASS:
11744+
zend_compile_var(result, ast, BP_VAR_INNER_CLASS, 0);
11745+
return;
1174011746
case ZEND_AST_ASSIGN:
1174111747
zend_compile_assign(result, ast);
1174211748
return;
@@ -11883,6 +11889,7 @@ static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t ty
1188311889
case ZEND_AST_NULLSAFE_PROP:
1188411890
return zend_compile_prop(result, ast, type, by_ref);
1188511891
case ZEND_AST_STATIC_PROP:
11892+
case ZEND_AST_INNER_CLASS:
1188611893
return zend_compile_static_prop(result, ast, type, by_ref, 0);
1188711894
case ZEND_AST_CALL:
1188811895
zend_compile_call(result, ast, type);

Zend/zend_compile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,7 @@ ZEND_API zend_string *zend_type_to_string(zend_type type);
10561056
#define BP_VAR_IS 3
10571057
#define BP_VAR_FUNC_ARG 4
10581058
#define BP_VAR_UNSET 5
1059+
#define BP_VAR_INNER_CLASS 6
10591060

10601061
#define ZEND_INTERNAL_FUNCTION 1
10611062
#define ZEND_USER_FUNCTION 2

Zend/zend_execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3647,7 +3647,7 @@ static zend_always_inline zval* zend_fetch_static_property_address(zend_property
36473647
result = CACHED_PTR(cache_slot + sizeof(void *));
36483648
property_info = CACHED_PTR(cache_slot + sizeof(void *) * 2);
36493649

3650-
if ((fetch_type == BP_VAR_R || fetch_type == BP_VAR_RW)
3650+
if ((fetch_type == BP_VAR_R || fetch_type == BP_VAR_INNER_CLASS || fetch_type == BP_VAR_RW)
36513651
&& UNEXPECTED(Z_TYPE_P(result) == IS_UNDEF)
36523652
&& ZEND_TYPE_IS_SET(property_info->type)) {
36533653
zend_throw_error(NULL, "Typed static property %s::$%s must not be accessed before initialization",

Zend/zend_language_parser.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ type_without_static:
879879

880880
inner_type_without_static:
881881
name T_PAAMAYIM_NEKUDOTAYIM identifier
882-
{ $$ = zend_ast_create(ZEND_AST_CLASS_CONST, $1, $3); }
882+
{ $$ = zend_ast_create(ZEND_AST_INNER_CLASS, $1, $3); }
883883

884884
union_type_without_static_element:
885885
type_without_static { $$ = $1; }
@@ -1583,7 +1583,7 @@ new_variable:
15831583
| new_variable T_PAAMAYIM_NEKUDOTAYIM simple_variable
15841584
{ $$ = zend_ast_create(ZEND_AST_STATIC_PROP, $1, $3); }
15851585
| class_name T_PAAMAYIM_NEKUDOTAYIM class_name
1586-
{ $$ = zend_ast_create(ZEND_AST_STATIC_PROP, $1, $3); }
1586+
{ $$ = zend_ast_create(ZEND_AST_INNER_CLASS, $1, $3); }
15871587
;
15881588

15891589
member_name:

Zend/zend_object_handlers.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1995,7 +1995,11 @@ ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend
19951995
ret = CE_STATIC_MEMBERS(ce) + property_info->offset;
19961996
ZVAL_DEINDIRECT(ret);
19971997

1998-
if (UNEXPECTED((type == BP_VAR_R || type == BP_VAR_RW)
1998+
if (UNEXPECTED((type == BP_VAR_INNER_CLASS) && !(property_info->flags & ZEND_ACC_INNER_CLASS_REFERENCE))) {
1999+
zend_throw_error(NULL, "Unexpected property or const: %s::%s, expecting inner class name", ZSTR_VAL(property_info->ce->name), ZSTR_VAL(property_name));
2000+
}
2001+
2002+
if (UNEXPECTED((type == BP_VAR_R || type == BP_VAR_INNER_CLASS || type == BP_VAR_RW)
19992003
&& Z_TYPE_P(ret) == IS_UNDEF && ZEND_TYPE_IS_SET(property_info->type))) {
20002004
zend_throw_error(NULL, "Typed static property %s::$%s must not be accessed before initialization",
20012005
ZSTR_VAL(property_info->ce->name), ZSTR_VAL(property_name));

Zend/zend_vm_def.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,12 @@ ZEND_VM_HANDLER(176, ZEND_FETCH_STATIC_PROP_IS, ANY, CLASS_FETCH, CACHE_SLOT)
18951895
ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_static_prop_helper, type, BP_VAR_IS);
18961896
}
18971897

1898+
/* No specialization for op_types (CONST|TMPVAR|CV, UNUSED|CLASS_FETCH|CONST|VAR) */
1899+
ZEND_VM_HANDLER(210, ZEND_FETCH_INNER_CLASS, ANY, CLASS_FETCH, CACHE_SLOT)
1900+
{
1901+
ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_static_prop_helper, type, BP_VAR_INNER_CLASS);
1902+
}
1903+
18981904
ZEND_VM_COLD_CONSTCONST_HANDLER(81, ZEND_FETCH_DIM_R, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
18991905
{
19001906
USE_OPLINE

0 commit comments

Comments
 (0)