Skip to content

Commit 64ab502

Browse files
committed
Eagerly evaluate class constants / statics
1 parent 15caace commit 64ab502

File tree

6 files changed

+16
-53
lines changed

6 files changed

+16
-53
lines changed

Zend/tests/enum/case-attributes.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var_dump((new \ReflectionClassConstant(Foo::class, 'Bar'))->getAttributes(EnumCa
1919

2020
?>
2121
--EXPECT--
22-
object(EnumCaseAttribute)#1 (1) {
22+
object(EnumCaseAttribute)#2 (1) {
2323
["value"]=>
2424
string(3) "Bar"
2525
}

Zend/tests/enum/name-property.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var_dump(IntFoo::Bar->name);
2323
--EXPECT--
2424
array(1) {
2525
[0]=>
26-
object(ReflectionProperty)#2 (2) {
26+
object(ReflectionProperty)#6 (2) {
2727
["name"]=>
2828
string(4) "name"
2929
["class"]=>
@@ -33,14 +33,14 @@ array(1) {
3333
string(3) "Bar"
3434
array(2) {
3535
[0]=>
36-
object(ReflectionProperty)#3 (2) {
36+
object(ReflectionProperty)#5 (2) {
3737
["name"]=>
3838
string(4) "name"
3939
["class"]=>
4040
string(6) "IntFoo"
4141
}
4242
[1]=>
43-
object(ReflectionProperty)#4 (2) {
43+
object(ReflectionProperty)#7 (2) {
4444
["name"]=>
4545
string(5) "value"
4646
["class"]=>

Zend/zend_inheritance.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,9 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
27102710
}
27112711
zv = zend_hash_find_ex(CG(class_table), key, 1);
27122712
Z_CE_P(zv) = ret;
2713+
if (!(ce->ce_flags & ZEND_ACC_TRAIT)) {
2714+
zend_update_class_constants(ret);
2715+
}
27132716
return ret;
27142717
}
27152718
} else {
@@ -2831,6 +2834,9 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
28312834
free_alloca(traits_and_interfaces, use_heap);
28322835
}
28332836

2837+
if (!(ce->ce_flags & ZEND_ACC_TRAIT)) {
2838+
zend_update_class_constants(ce);
2839+
}
28342840
return ce;
28352841
}
28362842
/* }}} */

ext/reflection/tests/ReflectionEnum_getCase.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ test(IntEnum::class, 'Baz');
3232

3333
?>
3434
--EXPECT--
35-
object(ReflectionEnumUnitCase)#2 (2) {
35+
object(ReflectionEnumUnitCase)#4 (2) {
3636
["name"]=>
3737
string(3) "Foo"
3838
["class"]=>
3939
string(5) "Enum_"
4040
}
4141
ReflectionException: Enum_::Bar is not a case
4242
ReflectionException: Case Enum_::Baz does not exist
43-
object(ReflectionEnumBackedCase)#2 (2) {
43+
object(ReflectionEnumBackedCase)#4 (2) {
4444
["name"]=>
4545
string(3) "Foo"
4646
["class"]=>

ext/reflection/tests/ReflectionEnum_getCases.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ var_dump((new ReflectionEnum(IntEnum::class))->getCases());
2222
--EXPECT--
2323
array(2) {
2424
[0]=>
25-
object(ReflectionEnumUnitCase)#2 (2) {
25+
object(ReflectionEnumUnitCase)#6 (2) {
2626
["name"]=>
2727
string(3) "Foo"
2828
["class"]=>
2929
string(5) "Enum_"
3030
}
3131
[1]=>
32-
object(ReflectionEnumUnitCase)#3 (2) {
32+
object(ReflectionEnumUnitCase)#7 (2) {
3333
["name"]=>
3434
string(3) "Bar"
3535
["class"]=>
@@ -38,14 +38,14 @@ array(2) {
3838
}
3939
array(2) {
4040
[0]=>
41-
object(ReflectionEnumBackedCase)#2 (2) {
41+
object(ReflectionEnumBackedCase)#6 (2) {
4242
["name"]=>
4343
string(3) "Foo"
4444
["class"]=>
4545
string(7) "IntEnum"
4646
}
4747
[1]=>
48-
object(ReflectionEnumBackedCase)#1 (2) {
48+
object(ReflectionEnumBackedCase)#5 (2) {
4949
["name"]=>
5050
string(3) "Bar"
5151
["class"]=>

tests/classes/constants_basic_006.phpt

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)