Skip to content

Commit 6d07386

Browse files
committed
adds test case for internal class property attribute
1 parent 63a7f22 commit 6d07386

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

ext/zend_test/test.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static zend_class_entry *zend_test_parameter_attribute;
5050
static zend_class_entry *zend_test_property_attribute;
5151
static zend_class_entry *zend_test_class_with_method_with_parameter_attribute;
5252
static zend_class_entry *zend_test_child_class_with_method_with_parameter_attribute;
53+
static zend_class_entry *zend_test_class_with_property_attribute;
5354
static zend_class_entry *zend_test_forbid_dynamic_call;
5455
static zend_class_entry *zend_test_ns_foo_class;
5556
static zend_class_entry *zend_test_ns_unlikely_compile_error_class;
@@ -916,6 +917,12 @@ PHP_MINIT_FUNCTION(zend_test)
916917
zend_test_class_with_method_with_parameter_attribute = register_class_ZendTestClassWithMethodWithParameterAttribute();
917918
zend_test_child_class_with_method_with_parameter_attribute = register_class_ZendTestChildClassWithMethodWithParameterAttribute(zend_test_class_with_method_with_parameter_attribute);
918919

920+
zend_test_class_with_property_attribute = register_class_ZendTestClassWithPropertyAttribute();
921+
{
922+
zend_property_info *prop_info = zend_hash_str_find_ptr(&zend_test_class_with_property_attribute->properties_info, "attributed", sizeof("attributed") - 1);
923+
zend_add_property_attribute(zend_test_class_with_property_attribute, prop_info, zend_test_attribute->name, 0);
924+
}
925+
919926
zend_test_forbid_dynamic_call = register_class_ZendTestForbidDynamicCall();
920927

921928
zend_test_ns_foo_class = register_class_ZendTestNS_Foo();

ext/zend_test/test.stub.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ public function override(
104104
): int {}
105105
}
106106

107+
class ZendTestClassWithPropertyAttribute {
108+
// this attribute must be added internally in MINIT
109+
#[ZendTestAttribute]
110+
public string $attributed;
111+
}
112+
107113
final class ZendTestForbidDynamicCall {
108114
public function call(): void {}
109115
public static function callStatic(): void {}

ext/zend_test/test_arginfo.h

Lines changed: 22 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Tests attributes on internal class properties.
3+
--EXTENSIONS--
4+
zend_test
5+
reflection
6+
--FILE--
7+
<?php
8+
9+
$prop = new \ReflectionProperty(ZendTestClassWithPropertyAttribute::class, 'attributed');
10+
$attr = $prop->getAttributes(ZendTestAttribute::class)[0];
11+
var_dump($attr->getName());
12+
?>
13+
--EXPECT--
14+
string(17) "ZendTestAttribute"

0 commit comments

Comments
 (0)