From 4233c9a1b8c230ba0ecc9621fe03c4c4d7173f6f Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 18 Jan 2022 15:50:23 +1300 Subject: [PATCH] Fix Grant::retrieve to meet full phpcs standard --- CRM/Core/DAO.php | 3 +-- ext/civigrant/CRM/Grant/BAO/Grant.php | 21 +++++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 2d28ec7ffe..940bedc4a0 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1502,8 +1502,7 @@ LIKE %1 * @param array $returnProperities * An assoc array of fields that need to be returned, eg array( 'first_name', 'last_name'). * - * @return object - * an object of type referenced by daoName + * @return static|null */ public static function commonRetrieve($daoName, &$params, &$defaults, $returnProperities = NULL) { $object = new $daoName(); diff --git a/ext/civigrant/CRM/Grant/BAO/Grant.php b/ext/civigrant/CRM/Grant/BAO/Grant.php index aca48e7714..51d09236b5 100644 --- a/ext/civigrant/CRM/Grant/BAO/Grant.php +++ b/ext/civigrant/CRM/Grant/BAO/Grant.php @@ -60,23 +60,20 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant { } /** - * Fetch object based on array of properties. + * Retrieve DB object and copy to defaults array. * * @param array $params - * (reference ) an assoc array of name/value pairs. + * Array of criteria values. * @param array $defaults - * (reference ) an assoc array to hold the flattened values. + * Array to be populated with found values. * - * @return CRM_Grant_DAO_Grant + * @return self|null + * The DAO object, if found. + * + * @deprecated */ - public static function retrieve(&$params, &$defaults) { - $grant = new CRM_Grant_DAO_Grant(); - $grant->copyValues($params); - if ($grant->find(TRUE)) { - CRM_Core_DAO::storeValues($grant, $defaults); - return $grant; - } - return NULL; + public static function retrieve(array $params, array &$defaults = []) { + return self::commonRetrieve(self::class, $params, $defaults); } /** -- 2.25.1