@@ -3229,6 +3229,22 @@ public function generateCode(string $invocation, string $nameSuffix, array $allC
3229
3229
}
3230
3230
return $code;
3231
3231
}
3232
+
3233
+ /**
3234
+ * @param array<int, array<int, AttributeGroup>> $attributeGroups
3235
+ * @return AttributeInfo[]
3236
+ */
3237
+ public static function createFromGroups(array $attributeGroups): array {
3238
+ $attributes = [];
3239
+
3240
+ foreach ($attributeGroups as $attrGroup) {
3241
+ foreach ($attrGroup->attrs as $attr) {
3242
+ $attributes[] = new AttributeInfo($attr->name->toString(), $attr->args);
3243
+ }
3244
+ }
3245
+
3246
+ return $attributes;
3247
+ }
3232
3248
}
3233
3249
3234
3250
class ClassInfo {
@@ -4426,7 +4442,7 @@ function parseFunctionLike(
4426
4442
$type,
4427
4443
isset($docParamTypes[$varName]) ? Type::fromString($docParamTypes[$varName]) : null,
4428
4444
$param->default ? $prettyPrinter->prettyPrintExpr($param->default) : null,
4429
- createAttributes ($param->attrGroups)
4445
+ AttributeInfo::createFromGroups ($param->attrGroups)
4430
4446
);
4431
4447
if (!$param->default && !$param->variadic) {
4432
4448
$numRequiredArgs = $i + 1;
@@ -4465,7 +4481,7 @@ function parseFunctionLike(
4465
4481
$cond,
4466
4482
$isUndocumentable,
4467
4483
$minimumPhpVersionIdCompatibility,
4468
- createAttributes ($func->attrGroups),
4484
+ AttributeInfo::createFromGroups ($func->attrGroups),
4469
4485
$framelessFunctionInfos,
4470
4486
ExposedDocComment::extractExposedComment($comments)
4471
4487
);
@@ -4656,7 +4672,7 @@ function parseClass(
4656
4672
}
4657
4673
}
4658
4674
4659
- $attributes = createAttributes ($class->attrGroups);
4675
+ $attributes = AttributeInfo::createFromGroups ($class->attrGroups);
4660
4676
foreach ($attributes as $attribute) {
4661
4677
switch ($attribute->class) {
4662
4678
case 'AllowDynamicProperties':
@@ -4720,22 +4736,6 @@ function parseClass(
4720
4736
);
4721
4737
}
4722
4738
4723
- /**
4724
- * @param array<int, array<int, AttributeGroup>> $attributeGroups
4725
- * @return Attribute[]
4726
- */
4727
- function createAttributes(array $attributeGroups): array {
4728
- $attributes = [];
4729
-
4730
- foreach ($attributeGroups as $attrGroup) {
4731
- foreach ($attrGroup->attrs as $attr) {
4732
- $attributes[] = new AttributeInfo($attr->name->toString(), $attr->args);
4733
- }
4734
- }
4735
-
4736
- return $attributes;
4737
- }
4738
-
4739
4739
function handlePreprocessorConditions(array &$conds, Stmt $stmt): ?string {
4740
4740
foreach ($stmt->getComments() as $comment) {
4741
4741
$text = trim($comment->getText());
@@ -4855,7 +4855,7 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
4855
4855
$cond,
4856
4856
$fileInfo->isUndocumentable,
4857
4857
$fileInfo->getMinimumPhpVersionIdCompatibility(),
4858
- createAttributes ($classStmt->attrGroups)
4858
+ AttributeInfo::createFromGroups ($classStmt->attrGroups)
4859
4859
);
4860
4860
}
4861
4861
} else if ($classStmt instanceof Stmt\Property) {
@@ -4872,7 +4872,7 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
4872
4872
$classStmt->getComments(),
4873
4873
$prettyPrinter,
4874
4874
$fileInfo->getMinimumPhpVersionIdCompatibility(),
4875
- createAttributes ($classStmt->attrGroups)
4875
+ AttributeInfo::createFromGroups ($classStmt->attrGroups)
4876
4876
);
4877
4877
}
4878
4878
} else if ($classStmt instanceof Stmt\ClassMethod) {
0 commit comments