-
Notifications
You must be signed in to change notification settings - Fork 359
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
Replace substr with e.g. str_starts_with or str_ends_with where appropriate. #3196
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.
Thanks, @EreMaijala, this makes a lot of code significantly more readable, in addition to improving efficiency. I just had a couple of questions and observations from my review....
@@ -1496,7 +1496,7 @@ protected function extractComments($filename) | |||
// Is the current line a setting? If so, add to the return value: | |||
$set = trim(substr($trimmed, 0, $equals)); | |||
$set = trim(str_replace('[]', '', $set)); | |||
if (!empty($section) && !empty($set)) { | |||
if ('' == $section && '' == $set) { |
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.
This seems to be reversing the logic. If this didn't cause a test to fail, maybe we'd better add another test.
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.
Oops, fixed! It'd only affect inline comments, but yes, not caught by any test.
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've just pushed up a test to cover this code, and confirmed that it failed before your fix and passes after.
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.
Looks good to me now -- thanks again, @EreMaijala!
While profiling VuFind I noticed that there was a relatively high number of
substr
calls. While many of them are necessary, there was a lot of old code using them for comparison, so here's a bit cleanup. All tests are passing for me, but this was all manual work, so some scrutiny is welcome.TODO