Merge pull request #23814 from civicrm/5.51
[civicrm-core.git] / Civi / Api4 / Query / SqlFunctionCOUNT.php
index 8d52c9c73393fe0aac2e66ba4b799e9e145f956a..360ce7d8af0a0f9c979185521ae935a3199e5829 100644 (file)
@@ -18,27 +18,16 @@ class SqlFunctionCOUNT extends SqlFunction {
 
   protected static $category = self::CATEGORY_AGGREGATE;
 
-  protected static $params = [
-    [
-      'prefix' => ['', 'DISTINCT', 'ALL'],
-      'max_expr' => 1,
-      'must_be' => ['SqlField', 'SqlWild'],
-      'cant_be' => [],
-    ],
-  ];
+  protected static $dataType = 'Integer';
 
-  /**
-   * Reformat result as integer
-   *
-   * @see \Civi\Api4\Utils\FormattingUtil::formatOutputValues
-   * @param string $value
-   * @param string $dataType
-   * @return string|array
-   */
-  public function formatOutputValue($value, &$dataType) {
-    // Count is always an integer
-    $dataType = 'Integer';
-    return (int) $value;
+  protected static function params(): array {
+    return [
+      [
+        'flag_before' => ['DISTINCT' => ts('Distinct')],
+        'max_expr' => 1,
+        'must_be' => ['SqlField', 'SqlWild'],
+      ],
+    ];
   }
 
   /**
@@ -48,4 +37,11 @@ class SqlFunctionCOUNT extends SqlFunction {
     return ts('Count');
   }
 
+  /**
+   * @return string
+   */
+  public static function getDescription(): string {
+    return ts('The number of items in the grouping.');
+  }
+
 }