]> git.mxchange.org Git - mailer.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 9 Sep 2024 18:49:23 +0000 (20:49 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 9 Sep 2024 18:49:23 +0000 (20:49 +0200)
- added missing type-hints
- fixed new PHP error about passing NULL to trim() function

inc/session-functions.php

index e1dff3de408cdfb6b00ff983ba70fb9eb2baaf41..11186f21b1cb85155c3b6092acc82d084ec2d71a 100644 (file)
@@ -36,7 +36,7 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Unset/set session variables
-function setSession ($var, $value) {
+function setSession (string $var, $value) {
        // Abort in CSS mode here
        if (isCssOutputMode()) {
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Is CSS mode:' . $var . '=' . $value);
@@ -44,10 +44,10 @@ function setSession ($var, $value) {
        } // END - if
 
        // Trim value and session variable
-       $var   = trim(secureString($var));
+       $var = trim(secureString($var));
 
        // Is the value no array?
-       if (!is_array($value)) {
+       if (!is_array($value) && !is_null($value)) {
                // Then trim it
                $value = trim($value);
        } // END - if
@@ -88,13 +88,13 @@ function setSession ($var, $value) {
 }
 
 // Check whether a session variable is set
-function isSessionVariableSet ($var) {
+function isSessionVariableSet (string $var) {
        // Warning: DO NOT call logDebugMessage() from here, this will cause an endless loop
        return (isset($_SESSION[$var]));
 }
 
 // Returns whether the value of the session variable or NULL if not set
-function getSession ($var) {
+function getSession (string $var) {
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'var=' . $var . ' - CALLED!');
        // Default is not found ;-)
        $value = NULL;
@@ -123,7 +123,7 @@ function getSessionArray () {
 }
 
 // Destroy user session
-function destroyMemberSession ($destroy = FALSE) {
+function destroyMemberSession (bool $destroy = FALSE) {
        // Reset userid
        initMemberId();
 
@@ -137,7 +137,7 @@ function destroyMemberSession ($destroy = FALSE) {
 }
 
 // Destroys the admin session
-function destroyAdminSession ($destroy = FALSE) {
+function destroyAdminSession (bool $destroy = FALSE) {
        // Kill maybe existing session variables including array elements
        setAdminId(0);
        setAdminMd5('');
@@ -177,7 +177,7 @@ function isValidSession () {
 }
 
 // Checks whether all given session data is set
-function isSessionDataSet ($sessionData) {
+function isSessionDataSet (array $sessionData) {
        // Default is set
        $isset = TRUE;
 
@@ -218,4 +218,3 @@ function initSession () {
 }
 
 // [EOF]
-?>