MediaWiki  1.34.0
BaseSearchResultSet.php
Go to the documentation of this file.
1 <?php
2 
14 abstract class BaseSearchResultSet implements ISearchResultSet {
15 
19  private $bcIterator;
20 
26  public function next() {
27  wfDeprecated( __METHOD__, '1.32' );
28  $it = $this->bcIterator();
29  $searchResult = $it->current();
30  $it->next();
31  return $searchResult ?? false;
32  }
33 
38  public function rewind() {
39  wfDeprecated( __METHOD__, '1.32' );
40  $this->bcIterator()->rewind();
41  }
42 
43  private function bcIterator() {
44  if ( $this->bcIterator === null ) {
45  $this->bcIterator = 'RECURSION';
46  $this->bcIterator = $this->getIterator();
47  } elseif ( $this->bcIterator === 'RECURSION' ) {
48  // Either next/rewind or extractResults must be implemented. This
49  // class was potentially instantiated directly. It should be
50  // abstract with abstract methods to enforce this but that's a
51  // breaking change...
52  wfDeprecated( static::class . ' without implementing extractResults', '1.32' );
53  $this->bcIterator = new ArrayIterator( [] );
54  }
55  return $this->bcIterator;
56  }
57 
66  public function termMatches() {
67  return [];
68  }
69 
74  public function free() {
75  }
76 }
getIterator
getIterator()
Definition: SearchResultSetTrait.php:57
BaseSearchResultSet\rewind
rewind()
Rewind result set back to beginning.
Definition: BaseSearchResultSet.php:38
BaseSearchResultSet
BaseSearchResultSet is the base class that must be extended by SearchEngine search result set impleme...
Definition: BaseSearchResultSet.php:14
BaseSearchResultSet\next
next()
Fetches next search result, or false.
Definition: BaseSearchResultSet.php:26
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1044
ISearchResultSet
A set of SearchEngine results.
Definition: ISearchResultSet.php:11
BaseSearchResultSet\free
free()
Frees the result set, if applicable.
Definition: BaseSearchResultSet.php:74
BaseSearchResultSet\$bcIterator
ArrayIterator null $bcIterator
Iterator supporting BC iteration methods.
Definition: BaseSearchResultSet.php:19
BaseSearchResultSet\bcIterator
bcIterator()
Definition: BaseSearchResultSet.php:43
BaseSearchResultSet\termMatches
termMatches()
Fetch an array of regular expression fragments for matching the search terms as parsed by this engine...
Definition: BaseSearchResultSet.php:66