X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FCategoryFinder.php;h=3f0528ebe0b41669491d8190d6b315b14a36be23;hb=d13a933feed48020cfb55f7ee765090ac6af46b0;hp=33de7404eb3e7e089d1f56f76bcd120a3987ea1f;hpb=31d239f9d9e2516fc725d9b743ece0dfe72c23a2;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/CategoryFinder.php b/includes/CategoryFinder.php index 33de7404eb..3f0528ebe0 100644 --- a/includes/CategoryFinder.php +++ b/includes/CategoryFinder.php @@ -27,7 +27,7 @@ * articles are in one or all of a given subset of categories. * * Example use : - * + * @code * # Determines whether the article with the page_id 12345 is in both * # "Category 1" and "Category 2" or their subcategories, respectively * @@ -39,32 +39,32 @@ * ); * $a = $cf->run(); * print implode( ',' , $a ); - * + * @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 ) {