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