From: Derick Alangi Date: Fri, 22 Mar 2019 23:10:41 +0000 (+0100) Subject: block: Avoid use of empty() which doesn't warn on var non-existence X-Git-Tag: 1.34.0-rc.0~2400^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=e01619b17a59c11c411b56a6c8c06a05960b32df;p=lhc%2Fweb%2Fwiklou.git block: Avoid use of empty() which doesn't warn on var non-existence As empty() is more tolerant and doesn't warn on variable non-existence and will go ahead and treat it as if it has the value null, it's better to use ! in this case to make sure we catch even things like typos in the variable names within the code base. Let's make sure intended checks are actually checked instead of being tolerant. Follow up on: Ibaf555fac293da46fa397ccb9, thanks @Krinkle. Change-Id: Ibc45dba373bbbb6735a9681ed07a2438d4073ee0 --- diff --git a/includes/block/BlockRestriction.php b/includes/block/BlockRestriction.php index 72f6eaa9b6..c5ab16f40d 100644 --- a/includes/block/BlockRestriction.php +++ b/includes/block/BlockRestriction.php @@ -73,7 +73,7 @@ class BlockRestriction { * @return bool */ public static function insert( array $restrictions ) { - if ( empty( $restrictions ) ) { + if ( !$restrictions ) { return false; } @@ -85,7 +85,7 @@ class BlockRestriction { $rows[] = $restriction->toRow(); } - if ( empty( $rows ) ) { + if ( !$rows ) { return false; }