فهرست منبع

More consistent use of iterable type (#5308)

For `yield`
Alexandre Alapetite 3 سال پیش
والد
کامیت
62496339b6
7فایلهای تغییر یافته به همراه16 افزوده شده و 18 حذف شده
  1. 1 1
      app/Controllers/indexController.php
  2. 2 2
      app/Models/CategoryDAO.php
  3. 1 1
      app/Models/Entry.php
  4. 4 4
      app/Models/EntryDAO.php
  5. 2 4
      app/Models/Feed.php
  6. 2 2
      app/Models/FeedDAO.php
  7. 4 4
      app/Models/TagDAO.php

+ 1 - 1
app/Controllers/indexController.php

@@ -246,7 +246,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
 	 * This method returns a list of entries based on the Context object.
 	 * @return iterable<FreshRSS_Entry>
 	 */
-	public static function listEntriesByContext() {
+	public static function listEntriesByContext(): iterable {
 		$entryDAO = FreshRSS_Factory::createEntryDao();
 
 		$get = FreshRSS_Context::currentGet(true);

+ 2 - 2
app/Models/CategoryDAO.php

@@ -214,8 +214,8 @@ SQL;
 		}
 	}
 
-	/** @return iterator<array<string,string|int>> */
-	public function selectAll() {
+	/** @return iterable<array<string,string|int>> */
+	public function selectAll(): iterable {
 		$sql = 'SELECT id, name, kind, `lastUpdate`, error, attributes FROM `_category`';
 		$stm = $this->pdo->query($sql);
 		if ($stm != false) {

+ 1 - 1
app/Models/Entry.php

@@ -221,7 +221,7 @@ HTML;
 	}
 
 	/** @return iterable<array{'url':string,'type'?:string,'medium'?:string,'length'?:int,'title'?:string,'description'?:string,'credit'?:string,'height'?:int,'width'?:int,'thumbnails'?:array<string>}> */
-	public function enclosures(bool $searchBodyImages = false) {
+	public function enclosures(bool $searchBodyImages = false): iterable {
 		$attributeEnclosures = $this->attributes('enclosures');
 		if (is_array($attributeEnclosures)) {
 			// FreshRSS 1.20.1+: The enclosures are saved as attributes

+ 4 - 4
app/Models/EntryDAO.php

@@ -696,8 +696,8 @@ SQL;
 		}
 	}
 
-	/** @return iterator<array<string,string|int>> */
-	public function selectAll() {
+	/** @return iterable<array<string,string|int>> */
+	public function selectAll(): iterable {
 		$sql = 'SELECT id, guid, title, author, '
 			. (static::isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content')
 			. ', link, date, `lastSeen`, ' . static::sqlHexEncode('hash') . ' AS hash, is_read, is_favorite, id_feed, tags, attributes '
@@ -1153,7 +1153,7 @@ SQL;
 	 */
 	public function listWhere(string $type = 'a', int $id = 0, int $state = FreshRSS_Entry::STATE_ALL,
 			string $order = 'DESC', int $limit = 1, string $firstId = '',
-			?FreshRSS_BooleanSearch $filters = null, int $date_min = 0) {
+			?FreshRSS_BooleanSearch $filters = null, int $date_min = 0): iterable {
 		$stm = $this->listWhereRaw($type, $id, $state, $order, $limit, $firstId, $filters, $date_min);
 		if ($stm) {
 			while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {
@@ -1166,7 +1166,7 @@ SQL;
 	 * @param array<string> $ids
 	 * @return iterable<FreshRSS_Entry>
 	 */
-	public function listByIds(array $ids, string $order = 'DESC') {
+	public function listByIds(array $ids, string $order = 'DESC'): iterable {
 		if (count($ids) < 1) {
 			return;
 		}

+ 2 - 4
app/Models/Feed.php

@@ -478,10 +478,8 @@ class FreshRSS_Feed extends Minz_Model {
 		return $guids;
 	}
 
-	/**
-	 * @return iterable<FreshRSS_Entry>
-	 */
-	public function loadEntries(SimplePie $simplePie) {
+	/** @return iterable<FreshRSS_Entry> */
+	public function loadEntries(SimplePie $simplePie): iterable {
 		$hasBadGuids = $this->attributes('hasBadGuids');
 
 		$items = $simplePie->get_items();

+ 2 - 2
app/Models/FeedDAO.php

@@ -286,8 +286,8 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 		}
 	}
 
-	/** @return iterator<array<string,string|int>> */
-	public function selectAll() {
+	/** @return iterable<array<string,string|int>> */
+	public function selectAll(): iterable {
 		$sql = <<<'SQL'
 SELECT id, url, kind, category, name, website, description, `lastUpdate`,
 	priority, `pathEntries`, `httpAuth`, error, ttl, attributes

+ 4 - 4
app/Models/TagDAO.php

@@ -153,8 +153,8 @@ SQL;
 		}
 	}
 
-	/** @return iterator<array{'id':int,'name':string,'attributes':string}> */
-	public function selectAll() {
+	/** @return iterable<array{'id':int,'name':string,'attributes':string}> */
+	public function selectAll(): iterable {
 		$sql = 'SELECT id, name, attributes FROM `_tag`';
 		$stm = $this->pdo->query($sql);
 		while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {
@@ -162,8 +162,8 @@ SQL;
 		}
 	}
 
-	/** @return iterator<array{'id_tag':int,'id_entry':string}> */
-	public function selectEntryTag() {
+	/** @return iterable<array{'id_tag':int,'id_entry':string}> */
+	public function selectEntryTag(): iterable {
 		$sql = 'SELECT id_tag, id_entry FROM `_entrytag`';
 		$stm = $this->pdo->query($sql);
 		while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {