From a9654f00c8fbc9934289d761843ddd071025013f Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 28 Aug 2026 17:20:28 +0000
Subject: [PATCH] =PHPStorm Code Inspection: fixed class reference errors (from getting rid of JVB() and replacing with direct class::getInstance; as well as general code sniffing, etc

---
 inc/rest/routes/FormRoutes.php |   25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/inc/rest/routes/FormRoutes.php b/inc/rest/routes/FormRoutes.php
index f2bd9de..91232fc 100644
--- a/inc/rest/routes/FormRoutes.php
+++ b/inc/rest/routes/FormRoutes.php
@@ -8,7 +8,6 @@
 use JVBase\meta\Validator;
 use JVBase\rest\PermissionHandler;
 use JVBase\rest\Rest;
-use JVBase\managers\Cache;
 use JVBase\blocks\FormBlock;
 use JVBase\rest\Route;
 use JVBase\base\Site;
@@ -99,8 +98,7 @@
 			if (is_wp_error($result)) {
 				return $this->error(
 					$result->get_error_message(),
-					$result->get_error_code(),
-					400
+					$result->get_error_code()
 				);
 			}
 			if (array_key_exists('success', $result)){
@@ -161,7 +159,7 @@
 		if (!empty($files)) {
 			try {
 				$files = $this->validateFileUploads($files, $form_config);
-			} catch (\Exception $e) {
+			} catch (Exception $e) {
 				return new WP_Error('file_validation_failed', 'File validation error: ' . $e->getMessage());
 			}
 		}
@@ -169,7 +167,7 @@
 		// Validate and sanitize form data
 		try {
 			$processed_data = $this->validateAndSanitizeData($form_config, $form_data);
-		} catch (\Exception $e) {
+		} catch (Exception $e) {
 			return new WP_Error('validation_failed', 'Data validation error: ' . $e->getMessage());
 		}
 		if (array_key_exists('success', $processed_data) && $processed_data['success'] === false) {
@@ -179,7 +177,7 @@
 		// Send email notification with attachments
 		try {
 			$email_sent = $this->sendEmailNotification($form_type, $form_config, $processed_data, $files);
-		} catch (\Exception $e) {
+		} catch (Exception $e) {
 			return new WP_Error('email_failed', 'Email error: ' . $e->getMessage());
 		}
 
@@ -367,7 +365,7 @@
 			];
 		}
 
-		$body .= Emails::getInstance()->spacer(20);
+		$body .= Emails::getInstance()->spacer();
 		$body .= Emails::getInstance()->table($form);
 
 		// Show attachment info
@@ -375,8 +373,7 @@
 		if (!empty($attachments)) {
 			$body .= Emails::getInstance()->spacer(10);
 			$body .= Emails::getInstance()->alert(
-				sprintf('%d file(s) attached to this email', count($attachments)),
-				'info'
+				sprintf('%d file(s) attached to this email', count($attachments))
 			);
 		}
 
@@ -707,18 +704,18 @@
 		$forms = FormBlock::getForms();
 
 		// Remove sensitive data
-		$public_forms = [];
-		foreach ($forms as $key => $config) {
-			$public_forms[$key] = [
+		// Remove sensitive configuration
+		$public_forms = array_map(function ($config) use ($field) {
+			return [
 				'title' => $config['title'],
 				'description' => $config['description'],
-				'fields' => array_map(function($field) {
+				'fields' => array_map(function ($field) {
 					// Remove sensitive configuration
 					unset($field['email_to']);
 					return $field;
 				}, $config['fields'])
 			];
-		}
+		}, $forms);
 
 		return $this->success($public_forms);
 	}

--
Gitblit v1.10.0