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

Add string type declarations to global API functions. #15864

Merged
merged 2 commits into from
Nov 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @return array|int
*/
function civicrm_api($entity, $action, array $params, $extra = NULL) {
function civicrm_api(string $entity = NULL, string $action, array $params, $extra = NULL) {
return \Civi::service('civi_api_kernel')->runSafe($entity, $action, $params, $extra);
}

Expand All @@ -37,7 +37,7 @@ function civicrm_api($entity, $action, array $params, $extra = NULL) {
* @throws \API_Exception
* @throws \Civi\API\Exception\NotImplementedException
*/
function civicrm_api4($entity, $action, array $params = [], $index = NULL) {
function civicrm_api4(string $entity, string $action, array $params = [], $index = NULL) {
$apiCall = \Civi\Api4\Utils\ActionUtil::getAction($entity, $action);
foreach ($params as $name => $param) {
$setter = 'set' . ucfirst($name);
Expand Down Expand Up @@ -81,7 +81,7 @@ function civicrm_api4($entity, $action, array $params = [], $index = NULL) {
*
* @return array
*/
function civicrm_api3($entity, $action, array $params = []) {
function civicrm_api3(string $entity, string $action, array $params = []) {
$params['version'] = 3;
$result = \Civi::service('civi_api_kernel')->runSafe($entity, $action, $params);
if (is_array($result) && !empty($result['is_error'])) {
Expand Down