This is not safe to do at this point. Even if we made it safe,
we'd see inconsistencies due to a partially compiled class.
Fixes oss-fuzz #28129.
--- /dev/null
+--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
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;
}