Skip to content
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] Use ?? operator instead of CRM_Utils_Array::value() in return statements #16719

Merged
merged 1 commit into from
Mar 10, 2020

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Mar 9, 2020

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.

Comments

This PR was generated from a single regex which replaces all return statements that use CRM_Utils_Array::value() with only 2 arguments. Before/after are functionally identical because the default is null.

@civibot
Copy link

civibot bot commented Mar 9, 2020

(Standard links)

@civibot civibot bot added the master label Mar 9, 2020
@demeritcowboy
Copy link
Contributor

All of these look good. And especially for these ones it seems better that it would now throw an error if the thing is an object.

@colemanw colemanw merged commit 385d044 into civicrm:master Mar 10, 2020
@colemanw colemanw deleted the arrayValue3 branch March 13, 2020 15:06
@@ -298,7 +298,7 @@ public static function &pcPage($id = NULL) {
);
}
if ($id) {
return CRM_Utils_Array::value($id, self::$pcPage);
return self::$pcPage[$id] ?? NULL;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@twomice this is the only return-by-ref function affected by this PR. I'll do a followup to remove the & from the function declaration per your comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out the function was unused. #16771

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants