@@ -4528,6 +4528,25 @@ public function getVariableName(): string {
4528
4528
4529
4529
return $ matches ["name " ];
4530
4530
}
4531
+
4532
+ /** @return DocCommentTag[] */
4533
+ public static function parseDocComments (array $ comments ): array {
4534
+ $ tags = [];
4535
+ foreach ($ comments as $ comment ) {
4536
+ if (!($ comment instanceof DocComment)) {
4537
+ continue ;
4538
+ }
4539
+ $ commentText = substr ($ comment ->getText (), 2 , -2 );
4540
+ foreach (explode ("\n" , $ commentText ) as $ commentLine ) {
4541
+ $ regex = '/^\*\s*@([a-z-]+)(?:\s+(.+))?$/ ' ;
4542
+ if (preg_match ($ regex , trim ($ commentLine ), $ matches )) {
4543
+ $ tags [] = new DocCommentTag ($ matches [1 ], $ matches [2 ] ?? null );
4544
+ }
4545
+ }
4546
+ }
4547
+
4548
+ return $ tags ;
4549
+ }
4531
4550
}
4532
4551
4533
4552
// Instances of ExposedDocComment are immutable and do not need to be cloned
@@ -4571,25 +4590,6 @@ public static function extractExposedComment(array $comments): ?ExposedDocCommen
4571
4590
}
4572
4591
}
4573
4592
4574
- /** @return DocCommentTag[] */
4575
- function parseDocComments (array $ comments ): array {
4576
- $ tags = [];
4577
- foreach ($ comments as $ comment ) {
4578
- if (!($ comment instanceof DocComment)) {
4579
- continue ;
4580
- }
4581
- $ commentText = substr ($ comment ->getText (), 2 , -2 );
4582
- foreach (explode ("\n" , $ commentText ) as $ commentLine ) {
4583
- $ regex = '/^\*\s*@([a-z-]+)(?:\s+(.+))?$/ ' ;
4584
- if (preg_match ($ regex , trim ($ commentLine ), $ matches )) {
4585
- $ tags [] = new DocCommentTag ($ matches [1 ], $ matches [2 ] ?? null );
4586
- }
4587
- }
4588
- }
4589
-
4590
- return $ tags ;
4591
- }
4592
-
4593
4593
// Instances of FramelessFunctionInfo are immutable and do not need to be cloned
4594
4594
// when held by an object that is cloned
4595
4595
class FramelessFunctionInfo {
@@ -4628,7 +4628,7 @@ function parseFunctionLike(
4628
4628
$ framelessFunctionInfos = [];
4629
4629
4630
4630
if ($ comments ) {
4631
- $ tags = parseDocComments ($ comments );
4631
+ $ tags = DocCommentTag:: parseDocComments ($ comments );
4632
4632
4633
4633
foreach ($ tags as $ tag ) {
4634
4634
switch ($ tag ->name ) {
@@ -4817,7 +4817,7 @@ function parseConstLike(
4817
4817
$ link = null ;
4818
4818
$ isFileCacheAllowed = true ;
4819
4819
if ($ comments ) {
4820
- $ tags = parseDocComments ($ comments );
4820
+ $ tags = DocCommentTag:: parseDocComments ($ comments );
4821
4821
foreach ($ tags as $ tag ) {
4822
4822
if ($ tag ->name === 'var ' ) {
4823
4823
$ phpDocType = $ tag ->getType ();
@@ -4891,7 +4891,7 @@ function parseProperty(
4891
4891
$ link = null ;
4892
4892
4893
4893
if ($ comments ) {
4894
- $ tags = parseDocComments ($ comments );
4894
+ $ tags = DocCommentTag:: parseDocComments ($ comments );
4895
4895
foreach ($ tags as $ tag ) {
4896
4896
if ($ tag ->name === 'var ' ) {
4897
4897
$ phpDocType = $ tag ->getType ();
@@ -4962,7 +4962,7 @@ function parseClass(
4962
4962
$ allowsDynamicProperties = false ;
4963
4963
4964
4964
if ($ comments ) {
4965
- $ tags = parseDocComments ($ comments );
4965
+ $ tags = DocCommentTag:: parseDocComments ($ comments );
4966
4966
foreach ($ tags as $ tag ) {
4967
4967
if ($ tag ->name === 'alias ' ) {
4968
4968
$ alias = $ tag ->getValue ();
@@ -5067,7 +5067,7 @@ protected function pName_FullyQualified(Name\FullyQualified $node): string {
5067
5067
$ stmts = $ parser ->parse ($ code );
5068
5068
$ nodeTraverser ->traverse ($ stmts );
5069
5069
5070
- $ fileTags = parseDocComments (getFileDocComments ($ stmts ));
5070
+ $ fileTags = DocCommentTag:: parseDocComments (getFileDocComments ($ stmts ));
5071
5071
$ fileInfo = new FileInfo ($ fileTags );
5072
5072
5073
5073
$ fileInfo ->handleStatements ($ stmts , $ prettyPrinter );
0 commit comments