block: Avoid use of empty() which doesn't warn on var non-existence
authorDerick Alangi <alangiderick@gmail.com>
Fri, 22 Mar 2019 23:10:41 +0000 (00:10 +0100)
committerDerick Alangi <alangiderick@gmail.com>
Fri, 22 Mar 2019 23:13:51 +0000 (00:13 +0100)
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

includes/block/BlockRestriction.php

index 72f6eaa..c5ab16f 100644 (file)
@@ -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;
                }