Browse Source

Don't convert constructor property promotion PHPDoc to comment.

liquid207 3 years ago
parent
commit
9e0cca2282

+ 3 - 0
src/Tokenizer/Analyzer/CommentsAnalyzer.php

@@ -171,6 +171,9 @@ final class CommentsAnalyzer
                 T_INCLUDE,
                 T_INCLUDE_ONCE,
                 T_FINAL,
+                CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PUBLIC,
+                CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PROTECTED,
+                CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PRIVATE,
             ];
 
             if (\defined('T_READONLY')) { // @TODO: drop condition when PHP 8.1+ is required

+ 12 - 0
tests/Fixer/Phpdoc/PhpdocToCommentFixerTest.php

@@ -879,6 +879,18 @@ Class MyAnnotation3
      */
 }',
             ],
+            [
+                '<?php
+class Foo
+{
+	public function __construct(
+	    /** @var string Do not convert this */
+		public string $bar
+	) {
+	}
+}
+',
+            ],
         ];
     }
 }