From 0b0b329b608ea076709372b6b16ad950416e0b6d Mon Sep 17 00:00:00 2001 From: mark burdett Date: Fri, 15 Nov 2019 14:37:45 -0800 Subject: [PATCH 1/2] Add string type declarations to global API functions. --- api/api.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/api.php b/api/api.php index 2efc6ee659ab..3eec1a669514 100644 --- a/api/api.php +++ b/api/api.php @@ -19,7 +19,7 @@ * * @return array|int */ -function civicrm_api($entity, $action, array $params, $extra = NULL) { +function civicrm_api(string $entity, string $action, array $params, $extra = NULL) { return \Civi::service('civi_api_kernel')->runSafe($entity, $action, $params, $extra); } @@ -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); @@ -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'])) { From 8f76fa8b706631134c1d2e2e7300673f61a6c01e Mon Sep 17 00:00:00 2001 From: mark burdett Date: Mon, 18 Nov 2019 20:13:03 -0800 Subject: [PATCH 2/2] Various tests assume civicrm_api() $entity param is nullable. --- api/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/api.php b/api/api.php index 3eec1a669514..61501b6afd88 100644 --- a/api/api.php +++ b/api/api.php @@ -19,7 +19,7 @@ * * @return array|int */ -function civicrm_api(string $entity, string $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); }