Allow new lines in between declarations and also allow multiline union and intersection definition for array shapes#263
Conversation
8cdeba3 to
e7ef350
Compare
e7ef350 to
122bb31
Compare
src/Parser/TypeParser.php
Outdated
| $isFirst | ||
| || $tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA) | ||
| || $tokens->tryConsumeTokenType(Lexer::TOKEN_UNION) | ||
| || $tokens->tryConsumeTokenType(Lexer::TOKEN_INTERSECTION) |
There was a problem hiding this comment.
This doesn't make sense to me. The code makes it look like | and & could be used in place of , in a generic type.
There was a problem hiding this comment.
Feel free to remove this part from the PR and submit it separately, the rest is solid.
There was a problem hiding this comment.
You're totally right it was totally the wrong place.
I moved it accordingly and also adjusted the tests which if I would have had a better look would have already made clear that the parsed information would therefore be wrong 🙈.
I had to adjust the TypeParser::parse by using savepoints to check whether the union &/ intersection is valid to when being parsed to rollback when somethings feels off due to the information outputted afterwards not being shown "right".
So e.g. parsing /** @return A & B | C */ would had shown a error with partial information missing the beginning showing off a & B | C instead. (applied on test case invalid with type and disallowed description start token (2))
So if you by any chance have a better idea or solution to making this happen I'd be happy about any improvement here.
Otherwise this should now fulfill it's purpose allowing multiline type declarations and other multiline operations that may have led to an error before as stated with the tests and the linked issues that this would solve.
Let me know or feel free to make adjustments yourself if there's something we should do here 👍.
Otherwise thanks for the effort you're putting into all of this ❤️!
…r place and handle them
6ff8fc0 to
61ead7b
Compare
|
Nice, thank you! |
Takes care of: