From 5b50afdcafd150186ea5c7b0e1cad98065590b35 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 28 Aug 2026 18:44:28 +0000
Subject: [PATCH] =A few more phpStorm suggestions, mainly in PHPDocs

---
 inc/managers/Referrals.php |   31 +++++++++++++------------------
 1 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/inc/managers/Referrals.php b/inc/managers/Referrals.php
index 71769f7..396d1f2 100644
--- a/inc/managers/Referrals.php
+++ b/inc/managers/Referrals.php
@@ -1,6 +1,7 @@
 <?php
 namespace JVBase\managers;
 
+use Exception;
 use JVBase\Instance;
 use JVBase\integrations\services\Cloudflare;
 use JVBase\meta\Form;
@@ -63,14 +64,9 @@
 		$this->role = Site::getReferralRole();
 		$this->default_settings['referral_role'] = $this->role;
 
-		$this->cache = Cache::for('referrals', WEEK_IN_SECONDS);
-//		$this->requestCache = Cache::for('referral_requests', WEEK_IN_SECONDS)->connect('referrals', true);
-		$this->statsCache = Cache::for('referral_stats', WEEK_IN_SECONDS)->connect('referrals', true)->user();
-		if (JVB_TESTING) {
-			$this->cache->flush();
-//			$this->requestCache->flush();
-			$this->statsCache->flush();
-		}
+		$this->cache = Cache::for('referrals');
+
+		$this->statsCache = Cache::for('referral_stats', null, WEEK_IN_SECONDS)->user();
 
 		$this->referralPage = $this->getReferralPageId();
 		$this->settings = $this->getRewardSettings();
@@ -852,7 +848,7 @@
 	public function getTopReferrers(int $limit = 10, string $period = 'all'): array
 	{
 		return $this->statsCache->remember(
-			$this->statsCache->generateKey(['per_page' => $limit, 'period' => $period]),
+			['per_page' => $limit, 'period' => $period],
 			function() use ($limit, $period) {
 				$where = '';
 				if ($period !== 'all') {
@@ -915,7 +911,7 @@
 			'From ' . $yesterday
 		);
 
-		$content .= Emails::getInstance()->spacer(20);
+		$content .= Emails::getInstance()->spacer();
 		$content .= Emails::getInstance()->h2('New Referrals');
 
 		// Build list of referrals
@@ -985,7 +981,7 @@
 				Emails::getInstance()->stat($from_user->referral_count, 'Total Referrals'),
 				Emails::getInstance()->stat($from_user->treated_count, 'Treated')
 			];
-			$cardContent .= Emails::getInstance()->grid($stats, 2);
+			$cardContent .= Emails::getInstance()->grid($stats);
 
 			$content .= Emails::getInstance()->card($cardContent);
 			$rank++;
@@ -1005,7 +1001,7 @@
 	 */
 	protected function generateCSV(array $referrals): string
 	{
-		$cache = Cache::for('referralCSV', HOUR_IN_SECONDS)->connect('referrals');
+		$cache = Cache::for('referralCSV');
 		return $cache->remember(
 			'csv',
 			function () use ($referrals) {
@@ -1228,7 +1224,7 @@
 		}
 
 		// Check if code is unique
-		if ($this->isCodeTaken($code, $user_id)) {
+		if ($this->isCodeTaken($code)) {
 			add_action('user_profile_update_errors', function($errors) {
 				$errors->add('referral_code_taken',
 					'This referral code is already in use.');
@@ -1244,7 +1240,7 @@
 	 * Display user's referral code and share options
 	 * Use in templates or dashboard with: echo jvbReferralShareWidget();
 	 *
-	 * @return string HTML output
+	 * @return array HTML output
 	 */
 	public function outputShareWidget(array $actions):array
 	{
@@ -1277,7 +1273,7 @@
 		Cloudflare::getInstance()->renderTurnstile();
 		$turnstile = ob_get_clean();
 
-		$reward_text = $this->getRewardText(true);
+		$reward_text = $this->getRewardText();
 
 		// Pre-fill code if from referral link
 		$prefill_code = $_GET['ref'] ?? '';
@@ -1851,8 +1847,7 @@
 	 * Add referral settings subpage to admin menu
 	 * Add referral settings subpage to admin menu
 	 *
-	 * @param array $subpages
-	 * @return array
+	 * @return void
 	 */
 	public static function addSubpage():void
 	{
@@ -2786,7 +2781,7 @@
 				'message' => 'Referral settings saved successfully!'
 			];
 
-		} catch (\Exception $e) {
+		} catch (Exception $e) {
 			return [
 				'success' => false,
 				'message' => 'Failed to save settings: ' . $e->getMessage()

--
Gitblit v1.10.0