-
Notifications
You must be signed in to change notification settings - Fork 148
[BUGFIX] Parse calc split over multiple lines #1399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @scq,
Thanks for this. I concur that the spec allows any type of whitespace around the + and - operators (requiring at least one whitespace character).
To cover all types of whitespace, we can use preg_match with \s (via the 'Safe' library).
As part of this change, it would be good to also allow all types of whitespace before the operator (as well as after) - with tests covering that too.
We're aiming to move the tests away from functional tests to dedicated unit tests. I note there is not yet a CalcFunctionTest. Adding such a TestCase for the tests related to this change would be good.
Also, could you add an entry to the CHANGELOG.md file (in the root folder of the repository)?
|
Sweet, thanks for the review! Made those changes. |
JakeQZ
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this is amazing and absolutely perfect.
I wasn't expecting such a comprehensive test suite. Appreciate the time you have taken, which has saved us some :))
Thank you ever so much <3
We are on the lookout for additional collaborators if you are interested...
| * @param string $css | ||
| * @return CalcFunction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These PHPDoc annotations are actually redundant, since the types are in the method signature.
JakeQZ
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking again, I found a few other minor nitpicks.
But this is a great set of tests, so I was keen to get it merged.
| - Use typesafe versions of PHP functions (#1379, #1380, #1382, #1383, #1384) | ||
| - Fix parsing of `calc` expressions when a newline immediately precedes or | ||
| follows a + or - operator (#1399) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to mention that we put the changelog entries in reverse chronological order (though I'm not sure why).
calc()expressions that are multiline, where one line ends on an operator, currently fail to parse. E.g.This is because the code is looking for a space character following the operator, and failing when it sees a newline instead.