-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
[REF] Replace CRM_Utils_Array::value with ?? in variable assignments #16768
Conversation
(Standard links)
|
-- From https://www.php.net/manual/en/language.operators.comparison.php
|
I think the big safety consideration here is what happens when the
IMO the last two items are ok. Any code passing a string or an object to a function that expects an array is already broken so it's better to have the errors more prominent. |
Test failures should be fixed by merging #16778 |
This is rebased and tests are passing. It will go stale soon due to its size. |
This is a partial of civicrm#16768 & consists of the lines I have reviewed from it
Partial of civicrm#16768 - only contains test lines which I don't think need individual review
👍 I think this really improves the code readability. (alas it requires rebase) |
@mlutfy - rebased |
OK, so this PR is really scary (huge number of changes), but based on other similar cleanups Coleman as done (which have gone well), I think we should bite the bullet. Last call? :D |
Linting passed, so I merged (after other test runs had passed previously; this was just a 2 line rebase). |
Overview
This is part of a series of PRs to update an old code pattern.
CRM_Utils_Array::value()
can in many cases be swapped for the new PHP7??
operator.Technical Details
This PR was done entirely by regex find/replace. It targets variable assignments that use a single
CRM_Utils_Array::value()
call where the 3rd param is either NULL or omitted.No manual tweaking was done, only regex. The two patterns used were:
= CRM_Utils_Array::value\(([^,]+), ([^(),]+)\);$
= CRM_Utils_Array::value\(([^,]+), ([^(),]+), NULL\);$
For additional safety, this was done with file filter set to
.php
, case-sensitive enabled, and comments and string literals excluded.Comments
With 1,698 lines affected, IMO there's only one way to do this: treat it like a mass code autoformat like the one @twomice did a few years ago. Trust the regex, trust the unit tests, do a little spot-checking for sanity's sake, but do not attempt manual review.