From 6cf148ea45b56d0f02f0d50c0ede818ed875ce5d Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 5 Sep 2023 17:20:49 +1200 Subject: [PATCH] Declare CRM_Core_Exception in cleanDir The only information our exception imparts is that it is coming from CiviCRM Core - but we should at least be consistent in that. Also - I think passing something other than a string here would be bad - so adding a type hint is good. We were already checking not target so the empty string check is redundant --- CRM/Utils/File.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CRM/Utils/File.php b/CRM/Utils/File.php index cdea5b63af..37f2522a43 100644 --- a/CRM/Utils/File.php +++ b/CRM/Utils/File.php @@ -90,12 +90,12 @@ class CRM_Utils_File { * @param bool $rmdir * @param bool $verbose * - * @throws Exception + * @throws \CRM_Core_Exception */ - public static function cleanDir($target, $rmdir = TRUE, $verbose = TRUE) { + public static function cleanDir(string $target, bool $rmdir = TRUE, bool $verbose = TRUE) { static $exceptions = ['.', '..']; - if ($target == '' || $target == '/' || !$target) { - throw new Exception("Overly broad deletion"); + if (!$target || $target === '/') { + throw new CRM_Core_Exception('Overly broad deletion'); } if ($dh = @opendir($target)) { @@ -894,8 +894,8 @@ HTACCESS; case 'image/x-png': case 'image/png': case 'image/jpg': - list($imageWidth, $imageHeight) = getimagesize($path); - list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight); + [$imageWidth, $imageHeight] = getimagesize($path); + [$imageThumbWidth, $imageThumbHeight] = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight); $url = " "; -- 2.25.1