@@ -33,50 +33,7 @@ public function __construct(string $text, int $startLine = -1, int $startIndex =
33
33
34
34
public function getReformattedText (): ?string
35
35
{
36
- $ text = trim ($ this ->text );
37
- $ newlinePos = strpos ($ text , "\n" );
38
- if ($ newlinePos === false ) {
39
- // Single line comments don't need further processing
40
- return $ text ;
41
- } elseif (preg_match ('((*BSR_ANYCRLF)(*ANYCRLF)^.*(?:\R\s+\*.*)+$) ' , $ text ) === 1 ) {
42
- // Multi line comment of the type
43
- //
44
- // /*
45
- // * Some text.
46
- // * Some more text.
47
- // */
48
- //
49
- // is handled by replacing the whitespace sequences before the * by a single space
50
- return preg_replace ('(^\s+\*)m ' , ' * ' , $ this ->text );
51
- } elseif (preg_match ('(^/\*\*?\s*[\r\n]) ' , $ text ) === 1 && preg_match ('(\n(\s*)\*/$) ' , $ text , $ matches ) === 1 ) {
52
- // Multi line comment of the type
53
- //
54
- // /*
55
- // Some text.
56
- // Some more text.
57
- // */
58
- //
59
- // is handled by removing the whitespace sequence on the line before the closing
60
- // */ on all lines. So if the last line is " */", then " " is removed at the
61
- // start of all lines.
62
- return preg_replace ('(^ ' . preg_quote ($ matches [1 ]) . ')m ' , '' , $ text );
63
- } elseif (preg_match ('(^/\*\*?\s*(?!\s)) ' , $ text , $ matches ) === 1 ) {
64
- // Multi line comment of the type
65
- //
66
- // /* Some text.
67
- // Some more text.
68
- // Indented text.
69
- // Even more text. */
70
- //
71
- // is handled by removing the difference between the shortest whitespace prefix on all
72
- // lines and the length of the "/* " opening sequence.
73
- $ prefixLen = $ this ->getShortestWhitespacePrefixLen (substr ($ text , $ newlinePos + 1 ));
74
- $ removeLen = $ prefixLen - strlen ($ matches [0 ]);
75
- return preg_replace ('(^\s{ ' . $ removeLen . '})m ' , '' , $ text );
76
- }
77
-
78
- // No idea how to format this comment, so simply return as is
79
- return $ text ;
36
+ return trim ($ this ->text );
80
37
}
81
38
82
39
private function getShortestWhitespacePrefixLen (string $ str ): int
0 commit comments