Skip to content

Commit

Permalink
Merge branch 'PHP-8.0'
Browse files Browse the repository at this point in the history
* PHP-8.0:
  Don't use scope when validating Attribute
  • Loading branch information
nikic committed Dec 1, 2020
2 parents 1912ff5 + f06afc4 commit 715d89e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Zend/tests/attributes/032_attribute_validation_scope.phpt
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion Zend/zend_attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 715d89e

Please sign in to comment.