@@ -63,14 +63,7 @@ export class PhpDocParser {
6363 constructor (
6464 public typeParser : TypeParser ,
6565 public constantExprParser : ConstExprParser ,
66- public requireWhitespaceBeforeDescription : boolean = false ,
67- public preserveTypeAliasesWithInvalidTypes : boolean = false ,
68- usedAttributes : { lines : boolean ; indexes : boolean } = {
69- lines : false ,
70- indexes : false ,
71- } ,
72- public parseDoctrineAnnotations : boolean = false ,
73- private textBetweenTagsBelongsToDescription : boolean = false ,
66+ usedAttributes : { lines ?: boolean ; indexes ?: boolean } = { } ,
7467 ) {
7568 this . useLinesAttributes = usedAttributes . lines ?? false ;
7669 this . useIndexAttributes = usedAttributes . indexes ?? false ;
@@ -177,21 +170,11 @@ export class PhpDocParser {
177170 private parseText ( tokens : TokenIterator ) : PhpDocTextNode {
178171 let text = '' ;
179172
180- let endTokens = [
181- Lexer . TOKEN_PHPDOC_EOL ,
182- Lexer . TOKEN_CLOSE_PHPDOC ,
183- Lexer . TOKEN_END ,
184- ] ;
185- if ( this . textBetweenTagsBelongsToDescription ) {
186- endTokens = [ Lexer . TOKEN_CLOSE_PHPDOC , Lexer . TOKEN_END ] ;
187- }
173+ const endTokens = [ Lexer . TOKEN_CLOSE_PHPDOC , Lexer . TOKEN_END ] ;
188174
189175 let savepoint = false ;
190176
191- while (
192- this . textBetweenTagsBelongsToDescription ||
193- ! tokens . isCurrentTokenType ( Lexer . TOKEN_PHPDOC_EOL )
194- ) {
177+ while ( true ) {
195178 const tmpText =
196179 tokens . getSkippedHorizontalWhiteSpaceIfAny ( ) +
197180 tokens . joinUntil ( Lexer . TOKEN_PHPDOC_EOL , ...endTokens ) ;
@@ -201,14 +184,12 @@ export class PhpDocParser {
201184 break ;
202185 }
203186
204- if ( this . textBetweenTagsBelongsToDescription ) {
205- if ( ! savepoint ) {
206- tokens . pushSavePoint ( ) ;
207- savepoint = true ;
208- } else if ( tmpText !== '' ) {
209- tokens . dropSavePoint ( ) ;
210- tokens . pushSavePoint ( ) ;
211- }
187+ if ( ! savepoint ) {
188+ tokens . pushSavePoint ( ) ;
189+ savepoint = true ;
190+ } else if ( tmpText !== '' ) {
191+ tokens . dropSavePoint ( ) ;
192+ tokens . pushSavePoint ( ) ;
212193 }
213194
214195 tokens . pushSavePoint ( ) ;
@@ -742,34 +723,29 @@ export class PhpDocParser {
742723 // support psalm-type syntax
743724 tokens . tryConsumeTokenType ( Lexer . TOKEN_EQUAL ) ;
744725
745- if ( this . preserveTypeAliasesWithInvalidTypes ) {
746- const startLine = tokens . currentTokenLine ( ) ;
747- const startIndex = tokens . currentTokenIndex ( ) ;
726+ const startLine = tokens . currentTokenLine ( ) ;
727+ const startIndex = tokens . currentTokenIndex ( ) ;
748728
749- try {
750- const type = this . typeParser . parse ( tokens ) ;
751- if ( ! tokens . isCurrentTokenType ( Lexer . TOKEN_CLOSE_PHPDOC ) ) {
752- if ( ! tokens . isCurrentTokenType ( Lexer . TOKEN_PHPDOC_EOL ) ) {
753- throw new Error ( 'Expected end of line' ) ;
754- }
729+ try {
730+ const type = this . typeParser . parse ( tokens ) ;
731+ if ( ! tokens . isCurrentTokenType ( Lexer . TOKEN_CLOSE_PHPDOC ) ) {
732+ if ( ! tokens . isCurrentTokenType ( Lexer . TOKEN_PHPDOC_EOL ) ) {
733+ throw new Error ( 'Expected end of line' ) ;
755734 }
756- return new TypeAliasTagValueNode ( alias , type ) ;
757- } catch ( e ) {
758- this . parseOptionalDescription ( tokens ) ;
759- return new TypeAliasTagValueNode (
760- alias ,
761- this . enrichWithAttributes (
762- tokens ,
763- new InvalidTypeNode ( e as ParserException ) ,
764- startLine ,
765- startIndex ,
766- ) ,
767- ) ;
768735 }
736+ return new TypeAliasTagValueNode ( alias , type ) ;
737+ } catch ( e ) {
738+ this . parseOptionalDescription ( tokens ) ;
739+ return new TypeAliasTagValueNode (
740+ alias ,
741+ this . enrichWithAttributes (
742+ tokens ,
743+ new InvalidTypeNode ( e as ParserException ) ,
744+ startLine ,
745+ startIndex ,
746+ ) ,
747+ ) ;
769748 }
770-
771- const type = this . typeParser . parse ( tokens ) ;
772- return new TypeAliasTagValueNode ( alias , type ) ;
773749 }
774750
775751 private parseTypeAliasImportTagValue (
@@ -941,7 +917,6 @@ export class PhpDocParser {
941917 }
942918
943919 if (
944- this . requireWhitespaceBeforeDescription &&
945920 ! tokens . isCurrentTokenType (
946921 Lexer . TOKEN_PHPDOC_EOL ,
947922 Lexer . TOKEN_CLOSE_PHPDOC ,
0 commit comments