]> git.mxchange.org Git - mailer.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 26 Dec 2024 02:21:24 +0000 (03:21 +0100)
committerRoland Häder <roland@mxchange.org>
Thu, 26 Dec 2024 02:21:24 +0000 (03:21 +0100)
- added type-hint 'array'
- changed some string concating to sprintf() mask

inc/extensions-functions.php
inc/general-functions.php
inc/http-functions.php
inc/libs/wernis_functions.php
inc/libs/yoomedia_functions.php
inc/modules/guest/what-rallyes.php
inc/template-functions.php
inc/wrapper-functions.php
inc/xml-functions.php

index acb65c929ae1a2f936265126f79090f1027cce64..9b5990724fd34994740dd982f6d4b8ab563b5613 100644 (file)
@@ -1067,7 +1067,7 @@ function createNewExtensionTask ($ext_name) {
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',taskId[' . gettype($taskId) . ']=' . $taskId);
        if ((!isValidId($taskId)) && (!isExtensionInstalled($ext_name))) {
                // Set default message if ext-foo is missing
-               $message = '{%message,ADMIN_EXTENSION_TEXT_FILE_MISSING=' . $ext_name . '%}';
+               $message = sprintf('{%%message,ADMIN_EXTENSION_TEXT_FILE_MISSING=%s%%}', $ext_name);
 
                // Template file
                $FQFN = sprintf('%s/ext/ext_%s.tpl',
@@ -1078,7 +1078,7 @@ function createNewExtensionTask ($ext_name) {
                // Load text for task if found
                if (isFileReadable($FQFN)) {
                        // Load extension's description template (but do not compile the code)
-                       $message = '{OPEN_TEMPLATE}template,LoadTemplate=ext_' . $ext_name . '{CLOSE_TEMPLATE}';
+                       $message = sprintf('{OPEN_TEMPLATE}template,LoadTemplate=ext_%s{CLOSE_TEMPLATE}', $ext_name);
                } else {
                        // Write this in debug.log as well
                        logDebugMessage(__FUNCTION__, __LINE__, $message);
index 8ede16413525f97f26e0f324bf7fe6ed98710dab..e962e0c6271582e9564e4b1d371d1940b35c7cf6 100644 (file)
@@ -425,10 +425,7 @@ function translateUserStatus ($status) {
 }
 
 // "Translates" 'visible' and 'locked' to a CSS class
-function translateMenuVisibleLocked ($content, $prefix = '') {
-       // 1st parameter should be an array
-       assert(is_array($content));
-
+function translateMenuVisibleLocked (array $content, $prefix = '') {
        // Default is 'menu_unknown'
        $content['visible_css'] = $prefix . 'menu_unknown';
 
index 0c040865ffe7fb0caab30f28156639d02f601da8..62bca5438c74755131be1fab2ac62b8899ad9a2b 100644 (file)
@@ -448,7 +448,7 @@ function sendRawRequest ($host, $request, $allowOnlyHttpOkay = TRUE) {
        // Proxy agent found or something went wrong?
        if (!isFilledArray($response)) {
                // No response, maybe timeout
-               $response = array('', '', '');
+               $response = ['', '', ''];
                logDebugMessage(__FUNCTION__, __LINE__, 'Invalid empty response array, maybe timed out?');
        } elseif ((substr(strtolower($response[0]), 0, 11) == 'proxy-agent') && (isProxyUsed() === TRUE)) {
                // Proxy header detected, so remove two lines
@@ -460,7 +460,7 @@ function sendRawRequest ($host, $request, $allowOnlyHttpOkay = TRUE) {
        if ((!isHttpStatusOkay($response[0])) && ($allowOnlyHttpOkay === TRUE)) {
                // Not found / access forbidden
                logDebugMessage(__FUNCTION__, __LINE__, 'Unexpected status code ' . $response[0] . ' detected. "200 OK" was expected.');
-               $response = array('', '', '');
+               $response = ['', '', ''];
        } else {
                // Check array for chuncked encoding
                $response = unchunkHttpResponse($response);
@@ -473,13 +473,13 @@ function sendRawRequest ($host, $request, $allowOnlyHttpOkay = TRUE) {
 // Is HTTP status okay?
 function isHttpStatusOkay ($header) {
        // Determine it
-       return in_array(strtoupper(trim($header)), array('HTTP/1.1 200 OK', 'HTTP/1.0 200 OK'));
+       return in_array(strtoupper(trim($header)), ['HTTP/1.1 200 OK', 'HTTP/1.0 200 OK']);
 }
 
 // Sets up a proxy tunnel for given hostname and through resource
 function setupProxyTunnel ($host, $proxyHost, $port, $resource) {
        // Initialize array
-       $response = array('', '', '');
+       $response = ['', '', ''];
 
        // Generate CONNECT request header
        $proxyTunnel  = 'CONNECT ' . $host . ':' . $port . ' HTTP/1.0' . getConfig('HTTP_EOL');
@@ -519,7 +519,7 @@ function setupProxyTunnel ($host, $proxyHost, $port, $resource) {
 }
 
 // Check array for chuncked encoding
-function unchunkHttpResponse ($response) {
+function unchunkHttpResponse (array $response) {
        // Default is not chunked
        $isChunked = FALSE;
 
index c9fe0da434ea4cb7b4f0fdbc3ddd449d02338e20..b8b3dccc6d89ad485d2ee2875b41cd0d26505a85 100644 (file)
@@ -443,24 +443,21 @@ function executeWernisApiAuth ($wernisId, $wernisPassword) {
 }
 
 // Execute get.php reguest with given auth data (not all are used)
-function executeWernisApiGet ($authData, $subRequest, $fields) {
-       // It must be an array
-       assert(is_array($authData));
-
+function executeWernisApiGet (array $authData, $subRequest, $fields) {
        // Check required array elements
        assert(isset($authData['wernis_userid']));
        assert(isset($authData['api_auth_key']));
        assert(isset($authData['api_redirect_challenge']));
 
        // Then create request array
-       $requestData = array(
+       $requestData = [
                'sub_request' => $subRequest,
                'fields'      => $fields,
                't_uid'       => bigintval($authData['wernis_userid']),
                't_md5'       => getWernisPassMd5(),
                'auth_key'    => $authData['api_auth_key'],
                'challenge'   => $authData['api_redirect_challenge']
-       );
+       ];
 
        // Call get.php
        $return = sendWernisApiRequest('get.php', $requestData);
@@ -873,9 +870,8 @@ function generateWernisDecryptionKey ($publicKey) {
 }
 
 // Registers or updates Wernis registration data
-function registerUpdateWernisRegistrationCall ($args, $challenge, $status) {
+function registerUpdateWernisRegistrationCall (array $args, $challenge, $status) {
        // Make sure the required array elements are there
-       assert(is_array($args));
        assert(isset($args['auth_key']));
        assert(isset($args['wernis_userid']));
 
@@ -929,10 +925,7 @@ LIMIT 1",
 //-----------------------------------------------------------------------------
 
 // Handler for auth_status=PENDING
-function doWernisAuthPending ($args) {
-       // $args must always be an array
-       assert(is_array($args));
-
+function doWernisAuthPending (array $args) {
        // auth_key and wernis_userid must be set
        assert(isset($args['auth_key']));
        assert(isset($args['wernis_userid']));
@@ -952,10 +945,7 @@ function doWernisAuthPending ($args) {
 }
 
 // Handler for auth_status=ACCEPTED
-function doWernisAuthAccepted ($args) {
-       // $args must always be an array
-       assert(is_array($args));
-
+function doWernisAuthAccepted (array $args) {
        // auth_key and wernis_userid must be set
        assert(isset($args['auth_key']));
        assert(isset($args['wernis_userid']));
index 1cec650162749e558ce8ff778a6a51fd3ab831e3..ba263825846d0263c378b9e14606ce09ea1cc82c 100644 (file)
@@ -150,7 +150,7 @@ function YOOMEDIA_GET_PARSED_RESULT_TEXTMAILS () {
 }
 
 // Parser function for Yoo!Media API responses
-function YOOMEDIA_PARSE_RESPONSE ($response, $type) {
+function YOOMEDIA_PARSE_RESPONSE (array $response, $type) {
        // Init result
        $result = [];
 
@@ -382,10 +382,7 @@ function YOOMEDIA_CONVERT_MODE ($mailMode) {
 }
 
 // Extract code from response
-function YOOMEDIA_GET_ERRORCODE_FROM_RESULT ($response) {
-       // The response must be an array
-       assert(is_array($response));
-
+function YOOMEDIA_GET_ERRORCODE_FROM_RESULT (array $response) {
        // Bad code as default
        $code = -999;
 
index 4f88889da6c28ab367ab5de7efd8f10321bdc170..99cc23fb9d7872ca963383211162d4896e195229 100644 (file)
@@ -96,7 +96,7 @@ if (sqlNumRows($result) == 1) {
        // Handle description...
        if ((empty($content['descr'])) && (!empty($content['template']))) {
                // Use description from template
-               $content['descr'] = '{%template,LoadTemplate=rallye_' . $content['template'] . '%}';
+               $content['descr'] = sprintf('{%%template,LoadTemplate=rallye_%s%%}', $content['template']);
        } // END - if
 
        // Set start and end time
@@ -105,7 +105,7 @@ if (sqlNumRows($result) == 1) {
 
        if ($expired === TRUE) {
                $content['prices']       = addReferralRallyeWinners('guest', $content['id']);
-               $content['top_users']    = '<div align="center" class="big">' . $content['extras'] . '</div>';
+               $content['top_users']    = sprintf('<div align="center" class="big">%s</div>', $content['extras']);
                $content['can_win_this'] = '{--RALLYE_OUR_WINNERS_ARE--}';
        } else {
                $content['prices']       = addReferralRallyePrices($content['id'], 'html');
index edf8be94aacdf707dad752a2a953c9c2dbc64fae..c081c43a6c52ee7b7bc130996a0033868e02b9c6 100644 (file)
@@ -1826,10 +1826,7 @@ function sendModeMails ($mod, $modes) {
 }
 
 // Generates a 'selection box' from given array
-function generateSelectionBoxFromArray ($options, $name, $optionKey, $optionContent = '', $extraName = '', $templateName = '', $default = NULL, $nameElement = '', $allowNone = FALSE, $useDefaultAsArray = FALSE) {
-       // options must be an array
-       assert(is_array($options));
-
+function generateSelectionBoxFromArray (array $options, $name, $optionKey, $optionContent = '', $extraName = '', $templateName = '', $default = NULL, $nameElement = '', $allowNone = FALSE, $useDefaultAsArray = FALSE) {
        // Default is empty
        $addKey = '';
 
@@ -1887,9 +1884,9 @@ function generateSelectionBoxFromArray ($options, $name, $optionKey, $optionCont
        $OUT .= '</select>';
 
        // Prepare output
-       $content = array(
+       $content = [
                'selection_box' => $OUT,
-       );
+       ];
 
        // Load template and return it
        if (empty($templateName)) {
@@ -1929,7 +1926,7 @@ function addPageHeaderFooter () {
        $OUT = '';
 
        // Add them all together. This is maybe to simple
-       foreach (array('__page_header', '__output', '__page_footer') as $pagePart) {
+       foreach (['__page_header', '__output', '__page_footer'] as $pagePart) {
                // Add page part if set
                if (isset($GLOBALS[$pagePart])) {
                        $OUT .= $GLOBALS[$pagePart];
@@ -2164,7 +2161,7 @@ function compactContent ($uncompactedContent) {
        $compactedContent = str_replace(chr(9), '', str_replace(PHP_EOL, '', str_replace(chr(13), '', $uncompactedContent)));
 
        // Make a space after >
-       $compactedContent = str_replace(array('>', '  '), array('> ', ' '), $compactedContent);
+       $compactedContent = str_replace(['>', '  '], ['> ', ' '], $compactedContent);
 
        // Then regex all comments like <!-- //--> away
        preg_match_all('/<!--[\w\W]*?(\/\/){0,1}-->/', $compactedContent, $matches);
@@ -2277,14 +2274,14 @@ function doTemplateNoYesSelectionBox ($templateName, $clear, $formField) {
 // Helper function to add extra content for guest area (module=index and others)
 function doTemplateGuestFooterExtras ($templateName, $clear) {
        // Init filter data
-       $filterData = array(
+       $filterData = [
                // Name of used template
                'template' => $templateName,
                // Target array for gathered data
                '__data'   => [],
                // Where the HTML output will go
                '__output' => '',
-       );
+       ];
 
        // Run the filter chain
        $filterData = runFilterChain('guest_footer_extras', $filterData);
@@ -2396,7 +2393,7 @@ function doTemplateDereferrerUrl ($templateName, $clear = FALSE, $url = NULL) {
        // Is the URL not NULL and not empty?
        if ((!is_null($url)) && (!empty($url))) {
                // Set HTML with EL code
-               $url = '<a href="{%pipe,generateDereferrerUrl=' . $url . '%}" rel="external" target="_blank">{--ADMIN_TEST_URL--}</a>';
+               $url = sprintf('<a href="{%%pipe,generateDereferrerUrl=%s%%}" rel="external" target="_blank">{--ADMIN_TEST_URL--}</a>', $url);
        } // END - if
 
        // Return URL (or content) or dashes if empty
index 960c723826a6efbe5953283d251abfec61e0ba71..3359e772daba63b1e8db67239f3a4c55a398fae2 100644 (file)
@@ -3496,9 +3496,8 @@ function translateFullComma ($dotted) {
 }
 
 // Wrapper to check if the first element to be shifted is set to given value
-function shift_array (&$array, $value, $key = '0') {
+function shift_array (array &$array, $value, $key = '0') {
        // Is the element set and value matches?
-       assert(is_array($array));
        assert(isset($array[$key]));
        assert($array[$key] === $value);
 
index 7d95d5971045b7a5550b5ed48c736ad48a3be76d..925e2ceab67c0afb8aaafdab8a1465d3021ef4c9 100644 (file)
@@ -290,7 +290,7 @@ function getSqlXmlFromTable ($tableName) {
 }
 
 // "Getter" for sql part back from given array
-function getSqlPartFromXmlArray ($columns) {
+function getSqlPartFromXmlArray (array $columns) {
        // Init SQL
        $sql = '';