Remove parameter EOLCharacterLength and detect it automatically #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Take a look at this line:
multipart-parser/src/StreamedPart.php
Line 157 in caad7d9
I was wondering, why
$eofLength
had to be multiplied with2
. Then I realized, this was to necessary to remove the length of the delimiter plus the EOL after the delimiter plus the EOL in the previous line.I realized, this could be an issue. When the EOL character length varies between the previous and the current line, this approach would fail. So I changed it to remove the length of
$line
instead of$trimmed
, so the current EOL is already subtracted. Then I only have to subtract one$eofLength
. But it must be the EOL character length of the previous line. So now, at the end of each iteration, I keep track of the EOL character length.This entirely obsoletes the constructor parameter
$EOLCharacterLength
, because now it is fully dynamic. So, I removed this parameter. I no not see this as a breaking change as using excess parameters in object initialization does not fail and raises no warning.I changed the tests accordingly, so they pass again. But to prove my point, I split my pull-request in two commits. The first commit removed the parameter for
$EOLCharacterLength
from the test-casetestNoNewLineAtTheEndOfThePartsWhenNewLineIsOneCharacterLong
. This makes the test fail. The second commit changes the implementation ofStreamedPart
and now the test passes again.