diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index b2ff1822f28..73096056f98 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -656,7 +656,7 @@ if ($action == 'edit') {
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
// Force e-mail recipient
print '
| '.$langs->trans("MAIN_MAIL_FORCE_SENDTO").' | '.getDolGlobalString('MAIN_MAIL_FORCE_SENDTO');
- if (!empty(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
+ if (getDolGlobalString('MAIN_MAIL_FORCE_SENDTO')) {
if (!isValidEmail(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
print img_warning($langs->trans("ErrorBadEMail"));
} else {
diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php
index 391ca42a6d3..3f0d8426f8f 100644
--- a/htdocs/admin/sms.php
+++ b/htdocs/admin/sms.php
@@ -221,7 +221,7 @@ if ($action == 'edit') {
// Method
print ' |
| '.$langs->trans("MAIN_SMS_SENDMODE").' | ';
- $text = empty(getDolGlobalString('MAIN_SMS_SENDMODE')) ? '' : $listofmethods[getDolGlobalString('MAIN_SMS_SENDMODE')];
+ $text = getDolGlobalString('MAIN_SMS_SENDMODE') ? $listofmethods[getDolGlobalString('MAIN_SMS_SENDMODE')] : '';
if (empty($text)) {
$text = $langs->trans("Undefined").' '.img_warning();
}
diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php
index 1f32fec97aa..4aae87581d4 100644
--- a/htdocs/admin/ticket_public.php
+++ b/htdocs/admin/ticket_public.php
@@ -318,7 +318,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) {
// Check if email exists
print ' |
| '.$langs->trans("TicketsEmailMustExist").' | ';
print '';
- if (empty(getDolGlobalInt('TICKET_EMAIL_MUST_EXISTS'))) {
+ if (!getDolGlobalInt('TICKET_EMAIL_MUST_EXISTS')) {
print '' . img_picto($langs->trans('Disabled'), 'switch_off') . '';
} else {
print '' . img_picto($langs->trans('Enabled'), 'switch_on') . '';
@@ -334,7 +334,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) {
/*
print ' |
| '.$langs->trans("TicketCreateThirdPartyWithContactIfNotExist").' | ';
print '';
- if (empty(getDolGlobalInt('TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST'))) {
+ if (!getDolGlobalInt('TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST')) {
print '' . img_picto($langs->trans('Disabled'), 'switch_off') . '';
} else {
print '' . img_picto($langs->trans('Enabled'), 'switch_on') . '';
diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php
index 008aa7d2670..8764c48a770 100644
--- a/htdocs/core/lib/admin.lib.php
+++ b/htdocs/core/lib/admin.lib.php
@@ -1330,14 +1330,14 @@ function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tab
// We discard modules according to features level (PS: if module is activated we always show it)
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
- if ($objMod->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2 && empty(getDolGlobalString($const_name))) {
+ if ($objMod->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2 && !getDolGlobalString($const_name)) {
$modulequalified = 0;
}
- if ($objMod->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1 && empty(getDolGlobalString($const_name))) {
+ if ($objMod->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1 && !getDolGlobalString($const_name)) {
$modulequalified = 0;
}
- //If module is not activated disqualified
- if (empty(getDolGlobalString($const_name))) {
+ // If module is not activated disqualified
+ if (!getDolGlobalString($const_name)) {
$modulequalified = 0;
}
diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php
index 952d746960b..48927666b74 100644
--- a/test/phpunit/CodingPhpTest.php
+++ b/test/phpunit/CodingPhpTest.php
@@ -565,7 +565,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
$ok=false;
break;
}
- $this->assertTrue($ok, 'Found code empty($user->hasRight in file '.$file['relativename'].'. empty() must not be used with hasRight.');
+ $this->assertTrue($ok, 'Found code empty($user->hasRight in file '.$file['relativename'].'. empty() must not be used on a var not on a function.');
// Test we don't have empty(DolibarrApiAccess::$user->hasRight
$ok=true;
@@ -575,7 +575,17 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
$ok=false;
break;
}
- $this->assertTrue($ok, 'Found code empty(DolibarrApiAccess::$user->hasRight in file '.$file['relativename'].'. empty() must not be used with hasRight.');
+ $this->assertTrue($ok, 'Found code empty(DolibarrApiAccess::$user->hasRight in file '.$file['relativename'].'. empty() must not be used on a var not on a function.');
+
+ // Test we don't have empty($user->hasRight
+ $ok=true;
+ $matches=array();
+ preg_match_all('/empty\(getDolGlobal/', $filecontent, $matches, PREG_SET_ORDER);
+ foreach ($matches as $key => $val) {
+ $ok=false;
+ break;
+ }
+ $this->assertTrue($ok, 'Found code empty(getDolGlobal... in file '.$file['relativename'].'. empty() must be used on a var not on a function.');
// Test we don't have @var array(
$ok=true;
|