A free open source IT asset/license management system
phpstan-fixes
Maciej Domanski540f783ba2a5
diff --git a/.github/workflows/SA-phpstan.yml b/.github/workflows/SA-phpstan.ymlindex 66196c20ac..995ef62c55 100644--- a/.github/workflows/SA-phpstan.yml+++ b/.github/workflows/SA-phpstan.yml@@ -1,3 +1,5 @@+# This workflow runs PHPStan security analysis tool+# More information: https://github.com/phpstan/phpstanname: PHPStan Security Scanon:push:@@ -21,8 +23,8 @@ jobs:- name: Download depsrun: composer update --no-interaction --no-progress- name: Download PHPStan- run: composer require --dev phpstan/phpstan #:1.5.x-dev- - name: Download Larastan v1 # (Laravel Framework 6.20.44)+ run: composer require --dev phpstan/phpstan+ - name: Download Larastan v1 # (Laravel Framework 6.20.44), v2 is for Laravel >=9run: composer require nunomaduro/larastan:^1.0 --dev- name: Download mcrypt helperrun: wget https://raw.githubusercontent.com/JetBrains/phpstorm-stubs/master/mcrypt/mcrypt.php -O _mcrypt_helper.phpdiff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.phpindex 19694569f9..533dd6bd98 100755--- a/app/Console/Commands/LdapSync.php+++ b/app/Console/Commands/LdapSync.php@@ -49,7 +49,7 @@ class LdapSync extends Command$ldap_result_last_name = Setting::getSettings()->ldap_lname_field;$ldap_result_first_name = Setting::getSettings()->ldap_fname_field;- $ldap_result_active_flag = Setting::getSettings()->ldap_active_flag_field;+ $ldap_result_active_flag = Setting::getSettings()->ldap_active_flag;$ldap_result_emp_num = Setting::getSettings()->ldap_emp_num;$ldap_result_email = Setting::getSettings()->ldap_email;$ldap_result_phone = Setting::getSettings()->ldap_phone_field;@@ -253,8 +253,8 @@ class LdapSync extends Commandif ($item['ldap_location_override'] == true) {$user->location_id = $item['location_id'];- } elseif ((isset($location)) && (! empty($location))) {- if ((is_array($location)) && (array_key_exists('id', $location))) {+ } elseif ((isset($location))) {+ if ((array_key_exists('id', $location))) {$user->location_id = $location['id'];} elseif (is_object($location)) {$user->location_id = $location->id;@@ -276,7 +276,7 @@ class LdapSync extends Command$item['status'] = 'error';}- array_push($summary, $item);+ $summary[] = $item;}}diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.phpindex 528e8851e0..7fb98bfd25 100644--- a/app/Helpers/Helper.php+++ b/app/Helpers/Helper.php@@ -60,7 +60,7 @@ class Helper** @author [A. Gianotto] [<[email protected]>]* @since [v3.3]- * @return array+ * @return string*/public static function defaultChartColors($index = 0){@@ -333,8 +333,6 @@ class Helper'#92896B',];--return $colors[$index];}@@ -416,8 +414,7 @@ class Helper**/$LocaleInfo = localeconv();- $floatString = str_replace(',', '', $floatString);- $floatString = str_replace($LocaleInfo['decimal_point'], '.', $floatString);+ $floatString = str_replace(array(',', $LocaleInfo['decimal_point']), array('', '.'), $floatString);// Strip Currency symbol// If no currency symbol is set, default to $ because Murica$currencySymbol = $LocaleInfo['currency_symbol'];@@ -427,7 +424,7 @@ class Helper$floatString = str_replace($currencySymbol, '', $floatString);- return floatval($floatString);+ return (float)$floatString;}/**@@ -435,7 +432,7 @@ class Helper** @author [B. Wetherington] [<[email protected]>]* @since [v5.2]- * @return Float+ * @return float*/public static function ParseCurrency($currencyString) {$without_currency = str_replace(Setting::getSettings()->default_currency, '', $currencyString); //generally shouldn't come up, since we don't do this in fields, but just in case it does...@@ -595,10 +592,11 @@ class Helper/*** Generates a random string+ * This function does not generate cryptographically secure values, and should not be used for cryptographic purposes** @author [A. Gianotto] [<[email protected]>]* @since [v3.0]- * @return array+ * @return string*/public static function generateRandomString($length = 10){@@ -606,7 +604,7 @@ class Helper$charactersLength = strlen($characters);$randomString = '';for ($i = 0; $i < $length; $i++) {- $randomString .= $characters[rand(0, $charactersLength - 1)];+ $randomString .= $characters[random_int(0, $charactersLength - 1)];}return $randomString;@@ -782,17 +780,15 @@ class Helper/*** Check to see if the given key exists in the array, and trim excess white space before returning it*- * @author Daniel Melzter- * @since 3.0* @param $array array* @param $key string* @param $default string* @return string+ *@author Daniel Melzter+ * @since 3.0*/- public static function array_smart_fetch(array $array, $key, $default = '')+ public static function array_smart_fetch(array $array, string $key, string $default = ''){- array_change_key_case($array, CASE_LOWER);-return array_key_exists(strtolower($key), array_change_key_case($array)) ? e(trim($array[$key])) : $default;}@@ -973,7 +969,6 @@ class Helpercase 'gif':case 'png':return true;- break;default:return false;}