Normalize comment classes
-
getReformattedText(): fix@returntypes, remove comment trimming to keep empty lines in comment at begin and end, optimize detection of multi-line comments -
getShortestWhitespacePrefixLen(): replace floatINFtoPHP_INT_MAX -
jsonSerialize(): update@psalm-returnand remove redundant@return, fixnodeType
Test failures are legitimate.
@nikic yes, because
remove comment trimming to keep empty lines in comment at begin and end
If you agree with these changes, I'll update the tests
The change to trimming is fine -- to verify, I've landed it separately as https://github.com/nikic/PHP-Parser/commit/1f504d2c7da6020d56144cdb8443a3ba681f6183. This was a leftover from an older implementation, when comments were expected to have a trailing newline.
It's some of the other changes that cause problematic changes in formatting.
@nikic hm... I'm don't see how other changes can fail tests - content changed only here
@nikic tests failed because startLine/endLine not correct in current test: $this->startLine === $this->endLine always return true because by default they set as -1 i.e. -1=-1
@nikic I'm fixed fake/incorrect data passing to CommentTest tests, but I'm think other failed tests must be fixes in other PR's.
@nikic added alternative check to test instances:
|| ($this->endLine === -1 && strpos($this->text, "\n") !== false)