From fa33467610671effc3c418d811bb002270331658 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Fri, 28 Feb 2025 14:05:04 +0100 Subject: [PATCH] Misc/Cleanup * more trait properties to const as they were always intended to be --- includes/ajaxHandler.class.php | 6 ++---- includes/utilities.php | 8 ++++---- pages/guide.php | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/includes/ajaxHandler.class.php b/includes/ajaxHandler.class.php index f40ed712..27b6aae3 100644 --- a/includes/ajaxHandler.class.php +++ b/includes/ajaxHandler.class.php @@ -37,10 +37,7 @@ class AjaxHandler return false; } - $h = $this->handler; - $out = $this->$h(); - if ($out === null) - $out = ''; + $out = $this->{$this->handler}() ?? ''; return true; } @@ -68,4 +65,5 @@ class AjaxHandler return true; } } + ?> diff --git a/includes/utilities.php b/includes/utilities.php index e3a05a3e..92e27277 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -19,8 +19,8 @@ class SimpleXML extends SimpleXMLElement trait TrRequestData { // const in trait supported in php8.2+ - public static $PATTERN_TEXT_LINE = '/[\p{Cc}\p{Cf}\p{Co}\p{Cs}\p{Cn}]/ui'; - public static $PATTERN_TEXT_BLOB = '/[\x00-\x09\x0B-\x1F\p{Cf}\p{Co}\p{Cs}\p{Cn}]/ui'; + public const PATTERN_TEXT_LINE = '/[\p{Cc}\p{Cf}\p{Co}\p{Cs}\p{Cn}]/ui'; + public const PATTERN_TEXT_BLOB = '/[\x00-\x09\x0B-\x1F\p{Cf}\p{Co}\p{Cs}\p{Cn}]/ui'; protected $_get = []; // fill with variables you that are going to be used; eg: protected $_post = []; // 'id' => ['filter' => FILTER_CALLBACK, 'options' => 'AjaxHandler::checkIdList'] @@ -104,13 +104,13 @@ trait TrRequestData private static function checkTextLine(string $val) : string { // trim non-printable chars - return preg_replace(self::$PATTERN_TEXT_LINE, '', $val); + return preg_replace(self::PATTERN_TEXT_LINE, '', $val); } private static function checkTextBlob(string $val) : string { // trim non-printable chars - return preg_replace(self::$PATTERN_TEXT_BLOB, '', $val); + return preg_replace(self::PATTERN_TEXT_BLOB, '', $val); } } diff --git a/pages/guide.php b/pages/guide.php index c0bf3a34..08a4a44e 100644 --- a/pages/guide.php +++ b/pages/guide.php @@ -555,7 +555,7 @@ class GuidePage extends GenericPage protected static function checkDescription(string $str) : string { // run checkTextBlob and also replace \n => \s and \s+ => \s - $str = preg_replace(parent::$PATTERN_TEXT_BLOB, '', $str); + $str = preg_replace(parent::PATTERN_TEXT_BLOB, '', $str); $str = strtr($str, ["\n" => ' ', "\r" => ' ']);