Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Zend/zend_opcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ ZEND_API void destroy_zend_class(zval *zv)
if (prop_info->ce == ce) {
zend_string_release(prop_info->name);
zend_type_release(prop_info->type, /* persistent */ 1);
if (prop_info->attributes) {
zend_hash_release(prop_info->attributes);
}
free(prop_info);
}
} ZEND_HASH_FOREACH_END();
Expand Down
7 changes: 7 additions & 0 deletions ext/zend_test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ static zend_class_entry *zend_test_parameter_attribute;
static zend_class_entry *zend_test_property_attribute;
static zend_class_entry *zend_test_class_with_method_with_parameter_attribute;
static zend_class_entry *zend_test_child_class_with_method_with_parameter_attribute;
static zend_class_entry *zend_test_class_with_property_attribute;
static zend_class_entry *zend_test_forbid_dynamic_call;
static zend_class_entry *zend_test_ns_foo_class;
static zend_class_entry *zend_test_ns_unlikely_compile_error_class;
Expand Down Expand Up @@ -1021,6 +1022,12 @@ PHP_MINIT_FUNCTION(zend_test)
zend_test_class_with_method_with_parameter_attribute = register_class_ZendTestClassWithMethodWithParameterAttribute();
zend_test_child_class_with_method_with_parameter_attribute = register_class_ZendTestChildClassWithMethodWithParameterAttribute(zend_test_class_with_method_with_parameter_attribute);

zend_test_class_with_property_attribute = register_class_ZendTestClassWithPropertyAttribute();
{
zend_property_info *prop_info = zend_hash_str_find_ptr(&zend_test_class_with_property_attribute->properties_info, "attributed", sizeof("attributed") - 1);
zend_add_property_attribute(zend_test_class_with_property_attribute, prop_info, zend_test_attribute->name, 0);
}

zend_test_forbid_dynamic_call = register_class_ZendTestForbidDynamicCall();

zend_test_ns_foo_class = register_class_ZendTestNS_Foo();
Expand Down
6 changes: 6 additions & 0 deletions ext/zend_test/test.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ public function override(
): int {}
}

class ZendTestClassWithPropertyAttribute {
// this attribute must be added internally in MINIT
#[ZendTestAttribute]
public string $attributed;
}

final class ZendTestForbidDynamicCall {
public function call(): void {}
public static function callStatic(): void {}
Expand Down
23 changes: 22 additions & 1 deletion ext/zend_test/test_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions ext/zend_test/tests/attribute-internal-property.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Tests attributes on internal class properties.
--EXTENSIONS--
zend_test
reflection
--FILE--
<?php

$prop = new \ReflectionProperty(ZendTestClassWithPropertyAttribute::class, 'attributed');
$attr = $prop->getAttributes(ZendTestAttribute::class)[0];
var_dump($attr->getName());
?>
--EXPECT--
string(17) "ZendTestAttribute"