Skip to content

Commit e1555ed

Browse files
committed
Adjustments from code review
1 parent be7639a commit e1555ed

File tree

8 files changed

+30
-15
lines changed

8 files changed

+30
-15
lines changed
File renamed without changes.
File renamed without changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Property constant expression
3+
--FILE--
4+
<?php
5+
6+
class A {}
7+
8+
class B {
9+
public $a;
10+
11+
public function __construct() {
12+
$this->a = new A;
13+
}
14+
}
15+
16+
const A = (new B)->a;
17+
debug_zval_dump(A);
18+
19+
?>
20+
--EXPECT--
21+
object(A)#2 (0) refcount(2){
22+
}
File renamed without changes.
File renamed without changes.

Zend/zend_ast.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -904,21 +904,17 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast
904904
case ZEND_AST_PROP:
905905
{
906906
if (UNEXPECTED(zend_ast_evaluate(&op1, ast->child[0], scope) != SUCCESS)) {
907-
ret = FAILURE;
908-
break;
907+
return FAILURE;
909908
}
910909
if (UNEXPECTED(zend_ast_evaluate(&op2, ast->child[1], scope) != SUCCESS)) {
911910
zval_ptr_dtor_nogc(&op1);
912-
ret = FAILURE;
913-
break;
911+
return FAILURE;
914912
}
915913

916-
convert_to_string(&op2);
917-
if (EG(exception)) {
914+
if (!try_convert_to_string(&op2)) {
918915
zval_ptr_dtor_nogc(&op1);
919916
zval_ptr_dtor_nogc(&op2);
920-
ret = FAILURE;
921-
break;
917+
return FAILURE;
922918
}
923919

924920
if (Z_TYPE(op1) != IS_OBJECT) {
@@ -932,8 +928,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast
932928
zval_ptr_dtor_nogc(&op2);
933929

934930
ZVAL_NULL(result);
935-
ret = SUCCESS;
936-
break;
931+
return SUCCESS;
937932
}
938933

939934
zend_object *zobj = Z_OBJ(op1);
@@ -942,17 +937,15 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast
942937
if (EG(exception)) {
943938
zval_ptr_dtor_nogc(&op1);
944939
zval_ptr_dtor_nogc(&op2);
945-
ret = FAILURE;
946-
break;
940+
return FAILURE;
947941
}
948942

949943
if (result != property_result) {
950-
ZVAL_COPY_VALUE(result, property_result);
944+
ZVAL_COPY(result, property_result);
951945
}
952946
zval_ptr_dtor_nogc(&op1);
953947
zval_ptr_dtor_nogc(&op2);
954-
ret = SUCCESS;
955-
break;
948+
return SUCCESS;
956949
}
957950
default:
958951
zend_throw_error(NULL, "Unsupported constant expression");

0 commit comments

Comments
 (0)