diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-01 11:50:22 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-01 11:50:22 +0100 |
commit | 715d89e16693f0523e3daf1e0a140a358475deca (patch) | |
tree | c5efae21cbc45c9b09639fe3df121600c7b8912c /Zend | |
parent | 1912ff5ccb01809f464effec392747a2f87d6f3c (diff) | |
parent | f06afc434aec631f18f8da8ffca9a6f0559e1acf (diff) | |
download | php-git-715d89e16693f0523e3daf1e0a140a358475deca.tar.gz |
Merge branch 'PHP-8.0'
* PHP-8.0:
Don't use scope when validating Attribute
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/attributes/032_attribute_validation_scope.phpt | 9 | ||||
-rw-r--r-- | Zend/zend_attributes.c | 5 |
2 files changed, 13 insertions, 1 deletions
diff --git a/Zend/tests/attributes/032_attribute_validation_scope.phpt b/Zend/tests/attributes/032_attribute_validation_scope.phpt new file mode 100644 index 0000000000..039a427254 --- /dev/null +++ b/Zend/tests/attributes/032_attribute_validation_scope.phpt @@ -0,0 +1,9 @@ +--TEST-- +Validation for "Attribute" does not use a scope when evaluating constant ASTs +--FILE-- +<?php +#[Attribute(parent::x)] +class x extends y {} +?> +--EXPECTF-- +Fatal error: Cannot access "parent" when no class scope is active in %s on line %d diff --git a/Zend/zend_attributes.c b/Zend/zend_attributes.c index 29a2f4a732..ae07802b5b 100644 --- a/Zend/zend_attributes.c +++ b/Zend/zend_attributes.c @@ -33,7 +33,10 @@ void validate_attribute(zend_attribute *attr, uint32_t target, zend_class_entry if (attr->argc > 0) { zval flags; - if (FAILURE == zend_get_attribute_value(&flags, attr, 0, scope)) { + /* As this is run in the middle of compilation, fetch the attribute value without + * specifying a scope. The class is not fully linked yet, and we may seen an + * inconsistent state. */ + if (FAILURE == zend_get_attribute_value(&flags, attr, 0, NULL)) { return; } |