Skip to content

Commit 715d89e

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Don't use scope when validating Attribute
2 parents 1912ff5 + f06afc4 commit 715d89e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Validation for "Attribute" does not use a scope when evaluating constant ASTs
3+
--FILE--
4+
<?php
5+
#[Attribute(parent::x)]
6+
class x extends y {}
7+
?>
8+
--EXPECTF--
9+
Fatal error: Cannot access "parent" when no class scope is active in %s on line %d

Zend/zend_attributes.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ void validate_attribute(zend_attribute *attr, uint32_t target, zend_class_entry
3333
if (attr->argc > 0) {
3434
zval flags;
3535

36-
if (FAILURE == zend_get_attribute_value(&flags, attr, 0, scope)) {
36+
/* As this is run in the middle of compilation, fetch the attribute value without
37+
* specifying a scope. The class is not fully linked yet, and we may seen an
38+
* inconsistent state. */
39+
if (FAILURE == zend_get_attribute_value(&flags, attr, 0, NULL)) {
3740
return;
3841
}
3942

0 commit comments

Comments
 (0)