@@ -3229,6 +3229,22 @@ public function generateCode(string $invocation, string $nameSuffix, array $allC
32293229 }
32303230 return $code;
32313231 }
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+ }
32323248}
32333249
32343250class ClassInfo {
@@ -4426,7 +4442,7 @@ function parseFunctionLike(
44264442 $type,
44274443 isset($docParamTypes[$varName]) ? Type::fromString($docParamTypes[$varName]) : null,
44284444 $param->default ? $prettyPrinter->prettyPrintExpr($param->default) : null,
4429- createAttributes ($param->attrGroups)
4445+ AttributeInfo::createFromGroups ($param->attrGroups)
44304446 );
44314447 if (!$param->default && !$param->variadic) {
44324448 $numRequiredArgs = $i + 1;
@@ -4465,7 +4481,7 @@ function parseFunctionLike(
44654481 $cond,
44664482 $isUndocumentable,
44674483 $minimumPhpVersionIdCompatibility,
4468- createAttributes ($func->attrGroups),
4484+ AttributeInfo::createFromGroups ($func->attrGroups),
44694485 $framelessFunctionInfos,
44704486 ExposedDocComment::extractExposedComment($comments)
44714487 );
@@ -4656,7 +4672,7 @@ function parseClass(
46564672 }
46574673 }
46584674
4659- $attributes = createAttributes ($class->attrGroups);
4675+ $attributes = AttributeInfo::createFromGroups ($class->attrGroups);
46604676 foreach ($attributes as $attribute) {
46614677 switch ($attribute->class) {
46624678 case 'AllowDynamicProperties':
@@ -4720,22 +4736,6 @@ function parseClass(
47204736 );
47214737}
47224738
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-
47394739function handlePreprocessorConditions(array &$conds, Stmt $stmt): ?string {
47404740 foreach ($stmt->getComments() as $comment) {
47414741 $text = trim($comment->getText());
@@ -4855,7 +4855,7 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
48554855 $cond,
48564856 $fileInfo->isUndocumentable,
48574857 $fileInfo->getMinimumPhpVersionIdCompatibility(),
4858- createAttributes ($classStmt->attrGroups)
4858+ AttributeInfo::createFromGroups ($classStmt->attrGroups)
48594859 );
48604860 }
48614861 } else if ($classStmt instanceof Stmt\Property) {
@@ -4872,7 +4872,7 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
48724872 $classStmt->getComments(),
48734873 $prettyPrinter,
48744874 $fileInfo->getMinimumPhpVersionIdCompatibility(),
4875- createAttributes ($classStmt->attrGroups)
4875+ AttributeInfo::createFromGroups ($classStmt->attrGroups)
48764876 );
48774877 }
48784878 } else if ($classStmt instanceof Stmt\ClassMethod) {
0 commit comments