Skip to content

Commit e4b76d7

Browse files
committed
Fix name collisions when an attribute is repeatable
1 parent 59dc172 commit e4b76d7

File tree

7 files changed

+137
-112
lines changed

7 files changed

+137
-112
lines changed

Zend/zend_attributes_arginfo.h

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Zend/zend_builtin_functions_arginfo.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/gen_stub.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,8 +2567,12 @@ function (Name $item) {
25672567
$code .= "\n#if (PHP_VERSION_ID >= " . PHP_82_VERSION_ID . ")";
25682568
}
25692569

2570-
foreach ($this->attributes as $attribute) {
2571-
$code .= $attribute->generateCode("zend_add_class_attribute(class_entry", "class_$escapedName", $allConstInfos);
2570+
foreach ($this->attributes as $key => $attribute) {
2571+
$code .= $attribute->generateCode(
2572+
"zend_add_class_attribute(class_entry",
2573+
"class_{$escapedName}_" . ($key + 1),
2574+
$allConstInfos
2575+
);
25722576
}
25732577

25742578
if (!$php82MinimumCompatibility) {
@@ -4170,13 +4174,21 @@ static function (FuncInfo $funcInfo) use ($allConstInfos) {
41704174
$functionTable = "CG(function_table)";
41714175
}
41724176

4173-
foreach ($funcInfo->attributes as $attribute) {
4174-
$code .= $attribute->generateCode("zend_add_function_attribute(zend_hash_str_find_ptr($functionTable, \"" . $funcInfo->name->getNameForAttributes() . "\", sizeof(\"" . $funcInfo->name->getNameForAttributes() . "\") - 1)", "func_" . $funcInfo->name->getNameForAttributes(), $allConstInfos);
4177+
foreach ($funcInfo->attributes as $key => $attribute) {
4178+
$code .= $attribute->generateCode(
4179+
"zend_add_function_attribute(zend_hash_str_find_ptr($functionTable, \"" . $funcInfo->name->getNameForAttributes() . "\", sizeof(\"" . $funcInfo->name->getNameForAttributes() . "\") - 1)",
4180+
"func_" . $funcInfo->name->getNameForAttributes() . "_" . ($key + 1),
4181+
$allConstInfos
4182+
);
41754183
}
41764184

41774185
foreach ($funcInfo->args as $index => $arg) {
4178-
foreach ($arg->attributes as $attribute) {
4179-
$code .= $attribute->generateCode("zend_add_parameter_attribute(zend_hash_str_find_ptr($functionTable, \"" . $funcInfo->name->getNameForAttributes() . "\", sizeof(\"" . $funcInfo->name->getNameForAttributes() . "\") - 1), $index", "func_{$funcInfo->name->getNameForAttributes()}_arg{$index}", $allConstInfos);
4186+
foreach ($arg->attributes as $key => $attribute) {
4187+
$code .= $attribute->generateCode(
4188+
"zend_add_parameter_attribute(zend_hash_str_find_ptr($functionTable, \"" . $funcInfo->name->getNameForAttributes() . "\", sizeof(\"" . $funcInfo->name->getNameForAttributes() . "\") - 1), $index",
4189+
"func_{$funcInfo->name->getNameForAttributes()}_arg{$index}_" . ($key + 1),
4190+
$allConstInfos
4191+
);
41804192
}
41814193
}
41824194

@@ -4196,8 +4208,12 @@ function generateConstantAttributeInitialization(iterable $constInfos, iterable
41964208
static function (ConstInfo $constInfo) use ($allConstInfos) {
41974209
$code = null;
41984210

4199-
foreach ($constInfo->attributes as $attribute) {
4200-
$code .= $attribute->generateCode("zend_add_class_constant_attribute(class_entry, const_" . $constInfo->name->getDeclarationName(), "const_" . $constInfo->name->getDeclarationName(), $allConstInfos);
4211+
foreach ($constInfo->attributes as $key => $attribute) {
4212+
$code .= $attribute->generateCode(
4213+
"zend_add_class_constant_attribute(class_entry, const_" . $constInfo->name->getDeclarationName(),
4214+
"const_" . $constInfo->name->getDeclarationName() . "_" . ($key + 1),
4215+
$allConstInfos
4216+
);
42014217
}
42024218

42034219
return $code;
@@ -4212,8 +4228,12 @@ static function (ConstInfo $constInfo) use ($allConstInfos) {
42124228
function generatePropertyAttributeInitialization(iterable $propertyInfos, iterable $allConstInfos): string {
42134229
$code = "";
42144230
foreach ($propertyInfos as $propertyInfo) {
4215-
foreach ($propertyInfo->attributes as $attribute) {
4216-
$code .= $attribute->generateCode("zend_add_property_attribute(class_entry, property_" . $propertyInfo->name->getDeclarationName(), "property_" . $propertyInfo->name->getDeclarationName(), $allConstInfos);
4231+
foreach ($propertyInfo->attributes as $key => $attribute) {
4232+
$code .= $attribute->generateCode(
4233+
"zend_add_property_attribute(class_entry, property_" . $propertyInfo->name->getDeclarationName(),
4234+
"property_" . $propertyInfo->name->getDeclarationName() . "_" . ($key + 1),
4235+
$allConstInfos
4236+
);
42174237
}
42184238
}
42194239

ext/oci8/oci8_arginfo.h

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/basic_functions_arginfo.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/zend_test/test.stub.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function returnsThrowable(): Exception {}
5050
trait _ZendTestTrait {
5151
/** @var int */
5252
#[ZendTestAttribute]
53+
#[ZendTestAttribute]
5354
public const TEST_CONST = 1;
5455

5556
/** @var mixed */
@@ -61,7 +62,7 @@ trait _ZendTestTrait {
6162
public function testMethod(): bool {}
6263
}
6364

64-
#[Attribute(Attribute::TARGET_ALL)]
65+
#[Attribute(Attribute::TARGET_ALL|Attribute::IS_REPEATABLE)]
6566
final class ZendTestAttribute {
6667

6768
}

0 commit comments

Comments
 (0)