Fix parserTests: Set scriptPath in setupGlobals() as well
[lhc/web/wiklou.git] / includes / CategoryFinder.php
index 33de740..3f0528e 100644 (file)
@@ -27,7 +27,7 @@
  * articles are in one or all of a given subset of categories.
  *
  * Example use :
- * <code>
+ * @code
  *     # Determines whether the article with the page_id 12345 is in both
  *     # "Category 1" and "Category 2" or their subcategories, respectively
  *
  *     );
  *     $a = $cf->run();
  *     print implode( ',' , $a );
- * </code>
+ * @endcode
  *
  */
 class CategoryFinder {
        /** @var int[] The original article IDs passed to the seed function */
-       protected $articles = array();
+       protected $articles = [];
 
        /** @var array Array of DBKEY category names for categories that don't have a page */
-       protected $deadend = array();
+       protected $deadend = [];
 
        /** @var array Array of [ID => array()] */
-       protected $parents = array();
+       protected $parents = [];
 
        /** @var array Array of article/category IDs */
-       protected $next = array();
+       protected $next = [];
 
        /** @var array Array of DBKEY category names */
-       protected $targets = array();
+       protected $targets = [];
 
        /** @var array */
-       protected $name2id = array();
+       protected $name2id = [];
 
        /** @var string "AND" or "OR" */
        protected $mode;
 
-       /** @var DatabaseBase Read-DB slave */
+       /** @var IDatabase Read-DB slave */
        protected $dbr;
 
        /**
@@ -80,7 +80,7 @@ class CategoryFinder {
                $this->mode = $mode;
 
                # Set the list of target categories; convert them to DBKEY form first
-               $this->targets = array();
+               $this->targets = [];
                foreach ( $categories as $c ) {
                        $ct = Title::makeTitleSafe( NS_CATEGORY, $c );
                        if ( $ct ) {
@@ -102,7 +102,7 @@ class CategoryFinder {
                }
 
                # Now check if this applies to the individual articles
-               $ret = array();
+               $ret = [];
 
                foreach ( $this->articles as $article ) {
                        $conds = $this->targets;
@@ -129,7 +129,7 @@ class CategoryFinder {
         * @param array $path Used to check for recursion loops
         * @return bool Does this match the conditions?
         */
-       private function check( $id, &$conds, $path = array() ) {
+       private function check( $id, &$conds, $path = [] ) {
                // Check for loops and stop!
                if ( in_array( $id, $path ) ) {
                        return false;
@@ -155,7 +155,7 @@ class CategoryFinder {
                                # This key is in the category list!
                                if ( $this->mode == 'OR' ) {
                                        # One found, that's enough!
-                                       $conds = array();
+                                       $conds = [];
                                        return true;
                                } else {
                                        # Assuming "AND" as default
@@ -187,11 +187,11 @@ class CategoryFinder {
        private function scanNextLayer() {
 
                # Find all parents of the article currently in $this->next
-               $layer = array();
+               $layer = [];
                $res = $this->dbr->select(
                        /* FROM   */ 'categorylinks',
                        /* SELECT */ '*',
-                       /* WHERE  */ array( 'cl_from' => $this->next ),
+                       /* WHERE  */ [ 'cl_from' => $this->next ],
                        __METHOD__ . '-1'
                );
                foreach ( $res as $o ) {
@@ -199,7 +199,7 @@ class CategoryFinder {
 
                        # Update parent tree
                        if ( !isset( $this->parents[$o->cl_from] ) ) {
-                               $this->parents[$o->cl_from] = array();
+                               $this->parents[$o->cl_from] = [];
                        }
                        $this->parents[$o->cl_from][$k] = $o;
 
@@ -216,14 +216,14 @@ class CategoryFinder {
                        $layer[$k] = $k;
                }
 
-               $this->next = array();
+               $this->next = [];
 
                # Find the IDs of all category pages in $layer, if they exist
                if ( count( $layer ) > 0 ) {
                        $res = $this->dbr->select(
                                /* FROM   */ 'page',
-                               /* SELECT */ array( 'page_id', 'page_title' ),
-                               /* WHERE  */ array( 'page_namespace' => NS_CATEGORY, 'page_title' => $layer ),
+                               /* SELECT */ [ 'page_id', 'page_title' ],
+                               /* WHERE  */ [ 'page_namespace' => NS_CATEGORY, 'page_title' => $layer ],
                                __METHOD__ . '-2'
                        );
                        foreach ( $res as $o ) {