Misc/Cleanup

* more trait properties to const as they were always intended to be
This commit is contained in:
Sarjuuk
2025-02-28 14:05:04 +01:00
parent 1f59e6fe2d
commit fa33467610
3 changed files with 7 additions and 9 deletions

View File

@@ -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;
}
}
?>

View File

@@ -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);
}
}

View File

@@ -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" => ' ']);