Bladeren bron

PHPStan booleansInConditions (#6793)

* PHPStan booleansInConditions

* Uniformisation
Alexandre Alapetite 1 jaar geleden
bovenliggende
commit
dfac9f5813
44 gewijzigde bestanden met toevoegingen van 200 en 216 verwijderingen
  1. 0 3
      .github/workflows/tests.yml
  2. 7 7
      app/Controllers/feedController.php
  3. 2 2
      app/Controllers/importExportController.php
  4. 1 1
      app/Controllers/subscriptionController.php
  5. 1 1
      app/Controllers/tagController.php
  6. 1 1
      app/FreshRSS.php
  7. 9 9
      app/Models/CategoryDAO.php
  8. 1 1
      app/Models/CategoryDAOSQLite.php
  9. 2 2
      app/Models/DatabaseDAO.php
  10. 2 2
      app/Models/DatabaseDAOSQLite.php
  11. 33 33
      app/Models/Entry.php
  12. 32 35
      app/Models/EntryDAO.php
  13. 7 7
      app/Models/EntryDAOSQLite.php
  14. 5 5
      app/Models/Feed.php
  15. 19 19
      app/Models/FeedDAO.php
  16. 1 1
      app/Models/FeedDAOSQLite.php
  17. 1 1
      app/Models/FormAuth.php
  18. 1 1
      app/Models/LogDAO.php
  19. 10 10
      app/Models/TagDAO.php
  20. 2 2
      app/Models/Themes.php
  21. 3 3
      app/Models/View.php
  22. 1 1
      app/Models/ViewStats.php
  23. 1 1
      app/Services/ExportService.php
  24. 4 4
      app/Services/ImportService.php
  25. 2 2
      app/views/configure/archiving.phtml
  26. 2 2
      app/views/configure/queries.phtml
  27. 1 1
      app/views/configure/query.phtml
  28. 3 0
      app/views/helpers/feed/update.phtml
  29. 6 3
      app/views/helpers/index/article.phtml
  30. 3 0
      app/views/helpers/index/normal/entry_bottom.phtml
  31. 3 0
      app/views/helpers/index/normal/entry_header.phtml
  32. 3 0
      app/views/helpers/index/tags.phtml
  33. 1 1
      app/views/helpers/stream-footer.phtml
  34. 10 1
      app/views/index/normal.phtml
  35. 2 2
      app/views/stats/repartition.phtml
  36. 1 1
      app/views/subscription/feed.phtml
  37. 6 5
      cli/CliOptionsParser.php
  38. 1 1
      cli/create-user.php
  39. 1 1
      cli/update-user.php
  40. 1 2
      composer.json
  41. 1 1
      lib/Minz/ModelPdo.php
  42. 4 4
      lib/lib_rss.php
  43. 1 34
      phpstan-next.neon
  44. 2 3
      phpstan.neon

+ 0 - 3
.github/workflows/tests.yml

@@ -49,9 +49,6 @@ jobs:
     - name: PHPStan
       run: composer run-script phpstan
 
-    - name: PHPStan Next Level
-      run: composer run-script phpstan-next
-
     # NPM tests
 
     - name: Uses Node.js

+ 7 - 7
app/Controllers/feedController.php

@@ -92,7 +92,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
 		}
 
 		$feedDAO = FreshRSS_Factory::createFeedDao();
-		if ($feedDAO->searchByUrl($feed->url())) {
+		if ($feedDAO->searchByUrl($feed->url()) !== null) {
 			throw new FreshRSS_AlreadySubscribed_Exception($url, $feed->name());
 		}
 
@@ -340,7 +340,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
 			}
 
 			$feed = $feedDAO->searchByUrl($this->view->feed->url());
-			if ($feed) {
+			if ($feed !== null) {
 				// Already subscribe so we redirect to the feed configuration page.
 				$url_redirect['a'] = 'feed';
 				$url_redirect['params']['id'] = $feed->id();
@@ -617,7 +617,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
 
 						$needFeedCacheRefresh = true;
 
-						if ($pubSubHubbubEnabled && !$simplePiePush) {	//We use push, but have discovered an article by pull!
+						if ($pubSubHubbubEnabled && $simplePiePush === null) {	//We use push, but have discovered an article by pull!
 							$text = 'An article was discovered by pull although we use PubSubHubbub!: Feed ' .
 								SimplePie_Misc::url_remove_credentials($url) .
 								' GUID ' . $entry->guid();
@@ -658,10 +658,10 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
 
 			$feedProperties = [];
 
-			if ($pubsubhubbubEnabledGeneral && $feed->hubUrl() && $feed->selfUrl()) {	//selfUrl has priority for WebSub
+			if ($pubsubhubbubEnabledGeneral && $feed->hubUrl() !== '' && $feed->selfUrl() !== '') {	//selfUrl has priority for WebSub
 				if ($feed->selfUrl() !== $url) {	// https://github.com/pubsubhubbub/PubSubHubbub/wiki/Moving-Feeds-or-changing-Hubs
 					$selfUrl = checkUrl($feed->selfUrl());
-					if ($selfUrl) {
+					if ($selfUrl != false) {
 						Minz_Log::debug('WebSub unsubscribe ' . $feed->url(false));
 						if (!$feed->pubSubHubbubSubscribe(false)) {	//Unsubscribe
 							Minz_Log::warning('Error while WebSub unsubscribing from ' . $feed->url(false));
@@ -709,7 +709,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
 			}
 
 			$feed->faviconPrepare();
-			if ($pubsubhubbubEnabledGeneral && $feed->pubSubHubbubPrepare()) {
+			if ($pubsubhubbubEnabledGeneral && $feed->pubSubHubbubPrepare() != false) {
 				Minz_Log::notice('WebSub subscribe ' . $feed->url(false));
 				if (!$feed->pubSubHubbubSubscribe(true)) {	//Subscribe
 					Minz_Log::warning('Error while WebSub subscribing to ' . $feed->url(false));
@@ -997,7 +997,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
 				break;
 			case 'normal':
 				$get = Minz_Request::paramString('get');
-				if ($get) {
+				if ($get !== '') {
 					$redirect_url = ['c' => 'index', 'a' => 'normal', 'params' => ['get' => $get]];
 				} else {
 					$redirect_url = ['c' => 'index', 'a' => 'normal'];

+ 2 - 2
app/Controllers/importExportController.php

@@ -351,7 +351,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
 				}
 			}
 
-			if ($feed != null) {
+			if ($feed !== null) {
 				$article_to_feed[$item['guid']] = $feed->id();
 				if (!isset($newFeedGuids['f_' . $feed->id()])) {
 					$newFeedGuids['f_' . $feed->id()] = [];
@@ -627,7 +627,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
 
 		foreach ($export_feeds as $feed_id) {
 			$result = $export_service->generateFeedEntries((int)$feed_id, $max_number_entries);
-			if (!$result) {
+			if ($result === null) {
 				// It means the actual feed_id doesn’t correspond to any existing feed
 				continue;
 			}

+ 1 - 1
app/Controllers/subscriptionController.php

@@ -304,7 +304,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
 				case 'normal':
 				case 'reader':
 					$get = Minz_Request::paramString('get');
-					if ($get) {
+					if ($get !== '') {
 						$url_redirect = ['c' => 'index', 'a' => $from, 'params' => ['get' => $get]];
 					} else {
 						$url_redirect = ['c' => 'index', 'a' => $from];

+ 1 - 1
app/Controllers/tagController.php

@@ -40,7 +40,7 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
 			if ($id_entry != '') {
 				$tagDAO = FreshRSS_Factory::createTagDao();
 				if ($id_tag == 0 && $name_tag !== '' && $checked) {
-					if ($existing_tag = $tagDAO->searchByName($name_tag)) {
+					if (($existing_tag = $tagDAO->searchByName($name_tag)) !== null) {
 						// Use existing tag
 						$tagDAO->tagEntry($existing_tag->id(), $id_entry, $checked);
 					} else {

+ 1 - 1
app/FreshRSS.php

@@ -111,7 +111,7 @@ class FreshRSS extends Minz_FrontController {
 			return;
 		}
 		$theme = FreshRSS_Themes::load(FreshRSS_Context::userConf()->theme);
-		if ($theme) {
+		if (is_array($theme)) {
 			foreach (array_reverse($theme['files']) as $file) {
 				switch (substr($file, -3)) {
 					case '.js':

+ 9 - 9
app/Models/CategoryDAO.php

@@ -12,7 +12,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
 			$stm->bindValue(':id', self::DEFAULTCATEGORYID, PDO::PARAM_INT);
 			$stm->bindValue(':name', 'Uncategorized');
 		}
-		return $stm && $stm->execute();
+		return $stm !== false && $stm->execute();
 	}
 
 	protected function addColumn(string $name): bool {
@@ -126,7 +126,7 @@ SQL;
 			$catId = $this->pdo->lastInsertId('`_category_id_seq`');
 			return $catId === false ? false : (int)$catId;
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			if ($this->autoUpdateDb($info)) {
 				return $this->addCategory($valuesTmp);
 			}
@@ -137,7 +137,7 @@ SQL;
 
 	public function addCategoryObject(FreshRSS_Category $category): int|false {
 		$cat = $this->searchByName($category->name());
-		if (!$cat) {
+		if ($cat === null) {
 			$values = [
 				'kind' => $category->kind(),
 				'name' => $category->name(),
@@ -175,7 +175,7 @@ SQL;
 		if ($stm !== false && $stm->execute($values)) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			if ($this->autoUpdateDb($info)) {
 				return $this->updateCategory($id, $valuesTmp);
 			}
@@ -196,7 +196,7 @@ SQL;
 		if ($stm !== false && $stm->execute($values)) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -211,7 +211,7 @@ SQL;
 		if ($stm !== false && $stm->bindParam(':id', $id, PDO::PARAM_INT) && $stm->execute()) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -290,7 +290,7 @@ SQL;
 				 * 	'id'?:int,'name'?:string,'url'?:string,'kind'?:int,'category'?:int,'website'?:string,'priority'?:int,'error'?:int|bool,'attributes'?:string,'cache_nbEntries'?:int,'cache_nbUnreads'?:int,'ttl'?:int}> $res */
 				return self::daoToCategoriesPrepopulated($res);
 			} else {
-				$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+				$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 				if ($this->autoUpdateDb($info)) {
 					return $this->listCategories($prePopulateFeeds, $details);
 				}
@@ -315,7 +315,7 @@ SQL;
 			$stm->execute()) {
 			return self::daoToCategories($stm->fetchAll(PDO::FETCH_ASSOC));
 		} else {
-			$info = $stm ? $stm->errorInfo() : $this->pdo->errorInfo();
+			$info = $stm !== false ? $stm->errorInfo() : $this->pdo->errorInfo();
 			if ($this->autoUpdateDb($info)) {
 				return $this->listCategoriesOrderUpdate($defaultCacheDuration, $limit);
 			}
@@ -362,7 +362,7 @@ SQL;
 				$catId = $this->pdo->lastInsertId('`_category_id_seq`');
 				return $catId === false ? false : (int)$catId;
 			} else {
-				$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+				$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 				Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 				return false;
 			}

+ 1 - 1
app/Models/CategoryDAOSQLite.php

@@ -6,7 +6,7 @@ class FreshRSS_CategoryDAOSQLite extends FreshRSS_CategoryDAO {
 	/** @param array<int|string> $errorInfo */
 	#[\Override]
 	protected function autoUpdateDb(array $errorInfo): bool {
-		if ($tableInfo = $this->pdo->query("PRAGMA table_info('category')")) {
+		if (($tableInfo = $this->pdo->query("PRAGMA table_info('category')")) !== false) {
 			$columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1);
 			foreach (['kind', 'lastUpdate', 'error', 'attributes'] as $column) {
 				if (!in_array($column, $columns, true)) {

+ 2 - 2
app/Models/DatabaseDAO.php

@@ -242,9 +242,9 @@ SQL;
 		foreach ($tables as $table) {
 			$sql = 'OPTIMIZE TABLE `_' . $table . '`';	//MySQL
 			$stm = $this->pdo->query($sql);
-			if ($stm == false || $stm->fetchAll(PDO::FETCH_ASSOC) == false) {
+			if ($stm === false || $stm->fetchAll(PDO::FETCH_ASSOC) == false) {
 				$ok = false;
-				$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+				$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 				Minz_Log::warning(__METHOD__ . ' error: ' . $sql . ' : ' . json_encode($info));
 			}
 		}

+ 2 - 2
app/Models/DatabaseDAOSQLite.php

@@ -10,7 +10,7 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO {
 	public function tablesAreCorrect(): bool {
 		$sql = "SELECT name FROM sqlite_master WHERE type='table'";
 		$stm = $this->pdo->query($sql);
-		$res = $stm ? $stm->fetchAll(PDO::FETCH_ASSOC) : false;
+		$res = $stm !== false ? $stm->fetchAll(PDO::FETCH_ASSOC) : false;
 		if ($res === false) {
 			return false;
 		}
@@ -35,7 +35,7 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO {
 	public function getSchema(string $table): array {
 		$sql = 'PRAGMA table_info(' . $table . ')';
 		$stm = $this->pdo->query($sql);
-		return $stm ? $this->listDaoToSchema($stm->fetchAll(PDO::FETCH_ASSOC) ?: []) : [];
+		return $stm !== false ? $this->listDaoToSchema($stm->fetchAll(PDO::FETCH_ASSOC) ?: []) : [];
 	}
 
 	#[\Override]

+ 33 - 33
app/Models/Entry.php

@@ -590,83 +590,83 @@ HTML;
 			} elseif ($filter instanceof FreshRSS_Search) {
 				// Searches are combined by OR and are not recursive
 				$ok = true;
-				if ($filter->getEntryIds()) {
+				if ($filter->getEntryIds() !== null) {
 					$ok &= in_array($this->id, $filter->getEntryIds(), true);
 				}
-				if ($ok && $filter->getNotEntryIds()) {
+				if ($ok && $filter->getNotEntryIds() !== null) {
 					$ok &= !in_array($this->id, $filter->getNotEntryIds(), true);
 				}
-				if ($ok && $filter->getMinDate()) {
+				if ($ok && $filter->getMinDate() !== null) {
 					$ok &= strnatcmp($this->id, $filter->getMinDate() . '000000') >= 0;
 				}
-				if ($ok && $filter->getNotMinDate()) {
+				if ($ok && $filter->getNotMinDate() !== null) {
 					$ok &= strnatcmp($this->id, $filter->getNotMinDate() . '000000') < 0;
 				}
-				if ($ok && $filter->getMaxDate()) {
+				if ($ok && $filter->getMaxDate() !== null) {
 					$ok &= strnatcmp($this->id, $filter->getMaxDate() . '000000') <= 0;
 				}
-				if ($ok && $filter->getNotMaxDate()) {
+				if ($ok && $filter->getNotMaxDate() !== null) {
 					$ok &= strnatcmp($this->id, $filter->getNotMaxDate() . '000000') > 0;
 				}
-				if ($ok && $filter->getMinPubdate()) {
+				if ($ok && $filter->getMinPubdate() !== null) {
 					$ok &= $this->date >= $filter->getMinPubdate();
 				}
-				if ($ok && $filter->getNotMinPubdate()) {
+				if ($ok && $filter->getNotMinPubdate() !== null) {
 					$ok &= $this->date < $filter->getNotMinPubdate();
 				}
-				if ($ok && $filter->getMaxPubdate()) {
+				if ($ok && $filter->getMaxPubdate() !== null) {
 					$ok &= $this->date <= $filter->getMaxPubdate();
 				}
-				if ($ok && $filter->getNotMaxPubdate()) {
+				if ($ok && $filter->getNotMaxPubdate() !== null) {
 					$ok &= $this->date > $filter->getNotMaxPubdate();
 				}
-				if ($ok && $filter->getFeedIds()) {
+				if ($ok && $filter->getFeedIds() !== null) {
 					$ok &= in_array($this->feedId, $filter->getFeedIds(), true);
 				}
-				if ($ok && $filter->getNotFeedIds()) {
+				if ($ok && $filter->getNotFeedIds() !== null) {
 					$ok &= !in_array($this->feedId, $filter->getNotFeedIds(), true);
 				}
-				if ($ok && $filter->getAuthor()) {
+				if ($ok && $filter->getAuthor() !== null) {
 					foreach ($filter->getAuthor() as $author) {
 						$ok &= stripos(implode(';', $this->authors), $author) !== false;
 					}
 				}
-				if ($ok && $filter->getAuthorRegex()) {
+				if ($ok && $filter->getAuthorRegex() !== null) {
 					foreach ($filter->getAuthorRegex() as $author) {
 						$ok &= preg_match($author, implode("\n", $this->authors)) === 1;
 					}
 				}
-				if ($ok && $filter->getNotAuthor()) {
+				if ($ok && $filter->getNotAuthor() !== null) {
 					foreach ($filter->getNotAuthor() as $author) {
 						$ok &= stripos(implode(';', $this->authors), $author) === false;
 					}
 				}
-				if ($ok && $filter->getNotAuthorRegex()) {
+				if ($ok && $filter->getNotAuthorRegex() !== null) {
 					foreach ($filter->getNotAuthorRegex() as $author) {
 						$ok &= preg_match($author, implode("\n", $this->authors)) === 0;
 					}
 				}
-				if ($ok && $filter->getIntitle()) {
+				if ($ok && $filter->getIntitle() !== null) {
 					foreach ($filter->getIntitle() as $title) {
 						$ok &= stripos($this->title, $title) !== false;
 					}
 				}
-				if ($ok && $filter->getIntitleRegex()) {
+				if ($ok && $filter->getIntitleRegex() !== null) {
 					foreach ($filter->getIntitleRegex() as $title) {
 						$ok &= preg_match($title, $this->title) === 1;
 					}
 				}
-				if ($ok && $filter->getNotIntitle()) {
+				if ($ok && $filter->getNotIntitle() !== null) {
 					foreach ($filter->getNotIntitle() as $title) {
 						$ok &= stripos($this->title, $title) === false;
 					}
 				}
-				if ($ok && $filter->getNotIntitleRegex()) {
+				if ($ok && $filter->getNotIntitleRegex() !== null) {
 					foreach ($filter->getNotIntitleRegex() as $title) {
 						$ok &= preg_match($title, $this->title) === 0;
 					}
 				}
-				if ($ok && $filter->getTags()) {
+				if ($ok && $filter->getTags() !== null) {
 					foreach ($filter->getTags() as $tag2) {
 						$found = false;
 						foreach ($this->tags as $tag1) {
@@ -679,7 +679,7 @@ HTML;
 						$ok &= $found;
 					}
 				}
-				if ($ok && $filter->getTagsRegex()) {
+				if ($ok && $filter->getTagsRegex() !== null) {
 					foreach ($filter->getTagsRegex() as $tag2) {
 						$found = false;
 						foreach ($this->tags as $tag1) {
@@ -692,7 +692,7 @@ HTML;
 						$ok &= $found;
 					}
 				}
-				if ($ok && $filter->getNotTags()) {
+				if ($ok && $filter->getNotTags() !== null) {
 					foreach ($filter->getNotTags() as $tag2) {
 						$found = false;
 						foreach ($this->tags as $tag1) {
@@ -705,7 +705,7 @@ HTML;
 						$ok &= !$found;
 					}
 				}
-				if ($ok && $filter->getNotTagsRegex()) {
+				if ($ok && $filter->getNotTagsRegex() !== null) {
 					foreach ($filter->getNotTagsRegex() as $tag2) {
 						$found = false;
 						foreach ($this->tags as $tag1) {
@@ -718,42 +718,42 @@ HTML;
 						$ok &= !$found;
 					}
 				}
-				if ($ok && $filter->getInurl()) {
+				if ($ok && $filter->getInurl() !== null) {
 					foreach ($filter->getInurl() as $url) {
 						$ok &= stripos($this->link, $url) !== false;
 					}
 				}
-				if ($ok && $filter->getInurlRegex()) {
+				if ($ok && $filter->getInurlRegex() !== null) {
 					foreach ($filter->getInurlRegex() as $url) {
 						$ok &= preg_match($url, $this->link) === 1;
 					}
 				}
-				if ($ok && $filter->getNotInurl()) {
+				if ($ok && $filter->getNotInurl() !== null) {
 					foreach ($filter->getNotInurl() as $url) {
 						$ok &= stripos($this->link, $url) === false;
 					}
 				}
-				if ($ok && $filter->getNotInurlRegex()) {
+				if ($ok && $filter->getNotInurlRegex() !== null) {
 					foreach ($filter->getNotInurlRegex() as $url) {
 						$ok &= preg_match($url, $this->link) === 0;
 					}
 				}
-				if ($ok && $filter->getSearch()) {
+				if ($ok && $filter->getSearch() !== null) {
 					foreach ($filter->getSearch() as $needle) {
 						$ok &= (stripos($this->title, $needle) !== false || stripos($this->content, $needle) !== false);
 					}
 				}
-				if ($ok && $filter->getNotSearch()) {
+				if ($ok && $filter->getNotSearch() !== null) {
 					foreach ($filter->getNotSearch() as $needle) {
 						$ok &= (stripos($this->title, $needle) === false && stripos($this->content, $needle) === false);
 					}
 				}
-				if ($ok && $filter->getSearchRegex()) {
+				if ($ok && $filter->getSearchRegex() !== null) {
 					foreach ($filter->getSearchRegex() as $needle) {
 						$ok &= (preg_match($needle, $this->title) === 1 || preg_match($needle, $this->content) === 1);
 					}
 				}
-				if ($ok && $filter->getNotSearchRegex()) {
+				if ($ok && $filter->getNotSearchRegex() !== null) {
 					foreach ($filter->getNotSearchRegex() as $needle) {
 						$ok &= (preg_match($needle, $this->title) === 0 && preg_match($needle, $this->content) === 0);
 					}
@@ -1056,7 +1056,7 @@ HTML;
 		if ($category != null && $mode !== 'freshrss') {
 			$item['categories'][] = 'user/-/label/' . htmlspecialchars_decode($category->name(), ENT_QUOTES);
 		}
-		if ($feed != null) {
+		if ($feed !== null) {
 			$item['origin']['htmlUrl'] = htmlspecialchars_decode($feed->website());
 			$item['origin']['title'] = $feed->name();	//EasyRSS
 			if ($mode === 'compat') {

+ 32 - 35
app/Models/EntryDAO.php

@@ -138,10 +138,7 @@ SQL;
 		return false;
 	}
 
-	/**
-	 * @var PDOStatement|null|false
-	 */
-	private $addEntryPrepared = false;
+	private PDOStatement|null|false $addEntryPrepared = null;
 
 	/** @param array{'id':string,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,'lastSeen':int,'hash':string,
 	 *		'is_read':bool|int|null,'is_favorite':bool|int|null,'id_feed':int,'tags':string,'attributes'?:null|string|array<string,mixed>} $valuesTmp */
@@ -158,7 +155,7 @@ SQL;
 				. ', :is_read, :is_favorite, :id_feed, :tags, :attributes)');
 			$this->addEntryPrepared = $this->pdo->prepare($sql);
 		}
-		if ($this->addEntryPrepared) {
+		if ($this->addEntryPrepared != false) {
 			$this->addEntryPrepared->bindParam(':id', $valuesTmp['id']);
 			$valuesTmp['guid'] = substr($valuesTmp['guid'], 0, 767);
 			$valuesTmp['guid'] = safe_ascii($valuesTmp['guid']);
@@ -200,10 +197,10 @@ SQL;
 				$this->addEntryPrepared->bindParam(':hash', $valuesTmp['hashBin']);
 			}
 		}
-		if ($this->addEntryPrepared && $this->addEntryPrepared->execute()) {
+		if ($this->addEntryPrepared != false && $this->addEntryPrepared->execute()) {
 			return true;
 		} else {
-			$info = $this->addEntryPrepared == null ? $this->pdo->errorInfo() : $this->addEntryPrepared->errorInfo();
+			$info = $this->addEntryPrepared == false ? $this->pdo->errorInfo() : $this->addEntryPrepared->errorInfo();
 			if ($this->autoUpdateDb($info)) {
 				$this->addEntryPrepared = null;
 				return $this->addEntry($valuesTmp);
@@ -240,7 +237,7 @@ SQL;
 		return $result;
 	}
 
-	private ?PDOStatement $updateEntryPrepared = null;
+	private PDOStatement|null|false $updateEntryPrepared = null;
 
 	/** @param array{'id':string,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,'lastSeen':int,'hash':string,
 	 *		'is_read':bool|int|null,'is_favorite':bool|int|null,'id_feed':int,'tags':string,'attributes':array<string,mixed>} $valuesTmp */
@@ -252,7 +249,7 @@ SQL;
 			$valuesTmp['is_favorite'] = null;
 		}
 
-		if ($this->updateEntryPrepared === null) {
+		if ($this->updateEntryPrepared == null) {
 			$sql = 'UPDATE `_entry` '
 				. 'SET title=:title, author=:author, '
 				. (static::isCompressed() ? 'content_bin=COMPRESS(:content)' : 'content=:content')
@@ -262,9 +259,9 @@ SQL;
 				. ', is_favorite=COALESCE(:is_favorite, is_favorite)'
 				. ', tags=:tags, attributes=:attributes '
 				. 'WHERE id_feed=:id_feed AND guid=:guid';
-			$this->updateEntryPrepared = $this->pdo->prepare($sql) ?: null;
+			$this->updateEntryPrepared = $this->pdo->prepare($sql);
 		}
-		if ($this->updateEntryPrepared) {
+		if ($this->updateEntryPrepared != false) {
 			$valuesTmp['guid'] = substr($valuesTmp['guid'], 0, 767);
 			$valuesTmp['guid'] = safe_ascii($valuesTmp['guid']);
 			$this->updateEntryPrepared->bindParam(':guid', $valuesTmp['guid']);
@@ -309,10 +306,10 @@ SQL;
 			}
 		}
 
-		if ($this->updateEntryPrepared && $this->updateEntryPrepared->execute()) {
+		if ($this->updateEntryPrepared != false && $this->updateEntryPrepared->execute()) {
 			return true;
 		} else {
-			$info = $this->updateEntryPrepared == null ? $this->pdo->errorInfo() : $this->updateEntryPrepared->errorInfo();
+			$info = $this->updateEntryPrepared == false ? $this->pdo->errorInfo() : $this->updateEntryPrepared->errorInfo();
 			if ($this->autoUpdateDb($info)) {
 				return $this->updateEntry($valuesTmp);
 			}
@@ -367,7 +364,7 @@ SQL;
 		if ($stm !== false && $stm->execute($values)) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -406,7 +403,7 @@ SQL;
 		if ($stm !== false && $stm->execute($values)) {
 			return true;
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -444,8 +441,8 @@ SQL;
 			$values = [$is_read ? 1 : 0];
 			$values = array_merge($values, $ids);
 			$stm = $this->pdo->prepare($sql);
-			if (!($stm && $stm->execute($values))) {
-				$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			if ($stm === false || !$stm->execute($values)) {
+				$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 				Minz_Log::error('SQL error ' . __METHOD__ . ' A ' . json_encode($info));
 				return false;
 			}
@@ -465,7 +462,7 @@ SQL;
 			if ($stm !== false && $stm->execute($values)) {
 				return $stm->rowCount();
 			} else {
-				$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+				$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 				Minz_Log::error('SQL error ' . __METHOD__ . ' B ' . json_encode($info));
 				return false;
 			}
@@ -514,8 +511,8 @@ SQL;
 		[$searchValues, $search] = $this->sqlListEntriesWhere('', $filters, $state);
 
 		$stm = $this->pdo->prepare($sql . $search);
-		if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		if ($stm === false || !$stm->execute(array_merge($values, $searchValues))) {
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -555,8 +552,8 @@ SQL;
 		[$searchValues, $search] = $this->sqlListEntriesWhere('', $filters, $state);
 
 		$stm = $this->pdo->prepare($sql . $search);
-		if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		if ($stm === false || !$stm->execute(array_merge($values, $searchValues))) {
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -597,8 +594,8 @@ SQL;
 		[$searchValues, $search] = $this->sqlListEntriesWhere('', $filters, $state);
 
 		$stm = $this->pdo->prepare($sql . $search);
-		if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		if ($stm === false || !$stm->execute(array_merge($values, $searchValues))) {
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info) . ' with SQL: ' . $sql . $search);
 			$this->pdo->rollBack();
 			return false;
@@ -613,7 +610,7 @@ SQL;
 			if (!($stm !== false &&
 				$stm->bindParam(':id', $id_feed, PDO::PARAM_INT) &&
 				$stm->execute())) {
-				$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+				$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 				Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 				$this->pdo->rollBack();
 				return false;
@@ -655,8 +652,8 @@ SQL;
 		[$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state);
 
 		$stm = $this->pdo->prepare($sql . $search);
-		if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		if ($stm === false || !$stm->execute(array_merge($values, $searchValues))) {
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -721,7 +718,7 @@ SQL;
 		if ($stm !== false && $stm->execute($params)) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			if ($this->autoUpdateDb($info)) {
 				return $this->cleanOldEntries($id_feed, $options);
 			}
@@ -1144,7 +1141,7 @@ SQL;
 			$search .= 'AND ' . $alias . 'id >= ? ';
 			$values[] = $date_min . '000000';
 		}
-		if ($filters && count($filters->searches()) > 0) {
+		if ($filters !== null && count($filters->searches()) > 0) {
 			[$filterValues, $filterSearch] = self::sqlBooleanSearch($alias, $filters);
 			$filterSearch = trim($filterSearch);
 			if ($filterSearch !== '') {
@@ -1252,7 +1249,7 @@ SQL;
 		if ($stm !== false && $stm->execute($values)) {
 			return $stm;
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			if ($this->autoUpdateDb($info)) {
 				return $this->listWhereRaw($type, $id, $state, $order, $limit, $offset, $firstId, $filters, $date_min);
 			}
@@ -1272,7 +1269,7 @@ SQL;
 			string $order = 'DESC', int $limit = 1, int $offset = 0, string $firstId = '',
 			?FreshRSS_BooleanSearch $filters = null, int $date_min = 0): Traversable {
 		$stm = $this->listWhereRaw($type, $id, $state, $order, $limit, $offset, $firstId, $filters, $date_min);
-		if ($stm) {
+		if ($stm !== false) {
 			while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {
 				if (is_array($row)) {
 					/** @var array{'id':string,'id_feed':int,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,
@@ -1343,7 +1340,7 @@ SQL;
 			/** @var array<numeric-string> $res */
 			return $res;
 		}
-		$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 		Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 		return null;
 	}
@@ -1377,7 +1374,7 @@ SQL;
 			}
 			return $result;
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			if ($this->autoUpdateDb($info)) {
 				return $this->listHashForFeedGuids($id_feed, $guids);
 			}
@@ -1413,7 +1410,7 @@ SQL;
 		if ($stm !== false && $stm->execute($values)) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			if ($this->autoUpdateDb($info)) {
 				return $this->updateLastSeen($id_feed, $guids);
 			}
@@ -1448,7 +1445,7 @@ SQL;
 			$stm->execute()) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info) . ' while updating feed ' . $id_feed);
 			return false;
 		}

+ 7 - 7
app/Models/EntryDAOSQLite.php

@@ -52,7 +52,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO {
 	/** @param array<string|int> $errorInfo */
 	#[\Override]
 	protected function autoUpdateDb(array $errorInfo): bool {
-		if ($tableInfo = $this->pdo->query("PRAGMA table_info('entry')")) {
+		if (($tableInfo = $this->pdo->query("PRAGMA table_info('entry')")) !== false) {
 			$columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1) ?: [];
 			foreach (['attributes'] as $column) {
 				if (!in_array($column, $columns, true)) {
@@ -117,8 +117,8 @@ SQL;
 			$sql = 'UPDATE `_entry` SET is_read=? WHERE id=? AND is_read=?';
 			$values = [$is_read ? 1 : 0, $ids, $is_read ? 0 : 1];
 			$stm = $this->pdo->prepare($sql);
-			if (!($stm && $stm->execute($values))) {
-				$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			if ($stm === false || !$stm->execute($values)) {
+				$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 				Minz_Log::error('SQL error ' . __METHOD__ . ' A ' . json_encode($info));
 				$this->pdo->rollBack();
 				return false;
@@ -129,8 +129,8 @@ SQL;
 				 . 'WHERE id=(SELECT e.id_feed FROM `_entry` e WHERE e.id=?)';
 				$values = [$ids];
 				$stm = $this->pdo->prepare($sql);
-				if (!($stm && $stm->execute($values))) {
-					$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+				if ($stm === false || !$stm->execute($values)) {
+					$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 					Minz_Log::error('SQL error ' . __METHOD__ . ' B ' . json_encode($info));
 					$this->pdo->rollBack();
 					return false;
@@ -167,8 +167,8 @@ SQL;
 		[$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state);
 
 		$stm = $this->pdo->prepare($sql . $search);
-		if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		if ($stm === false || !$stm->execute(array_merge($values, $searchValues))) {
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}

+ 5 - 5
app/Models/Feed.php

@@ -371,7 +371,7 @@ class FreshRSS_Feed extends Minz_Model {
 				Minz_ExtensionManager::callHook('simplepie_before_init', $simplePie, $this);
 				$mtime = $simplePie->init();
 
-				if ((!$mtime) || $simplePie->error()) {
+				if ((!$mtime) || !empty($simplePie->error())) {
 					$errorMessage = $simplePie->error();
 					if (empty($errorMessage)) {
 						$errorMessage = '';
@@ -950,7 +950,7 @@ class FreshRSS_Feed extends Minz_Model {
 	public function pubSubHubbubEnabled(): bool {
 		$url = $this->selfUrl ?: $this->url;
 		$hubFilename = PSHB_PATH . '/feeds/' . sha1($url) . '/!hub.json';
-		if ($hubFile = @file_get_contents($hubFilename)) {
+		if (($hubFile = @file_get_contents($hubFilename)) != false) {
 			$hubJson = json_decode($hubFile, true);
 			if (is_array($hubJson) && empty($hubJson['error']) &&
 				(empty($hubJson['lease_end']) || $hubJson['lease_end'] > time())) {
@@ -976,10 +976,10 @@ class FreshRSS_Feed extends Minz_Model {
 	public function pubSubHubbubPrepare(): string|false {
 		$key = '';
 		if (Minz_Request::serverIsPublic(FreshRSS_Context::systemConf()->base_url) &&
-			$this->hubUrl && $this->selfUrl && @is_dir(PSHB_PATH)) {
+			$this->hubUrl !== '' && $this->selfUrl !== '' && @is_dir(PSHB_PATH)) {
 			$path = PSHB_PATH . '/feeds/' . sha1($this->selfUrl);
 			$hubFilename = $path . '/!hub.json';
-			if ($hubFile = @file_get_contents($hubFilename)) {
+			if (($hubFile = @file_get_contents($hubFilename)) != false) {
 				$hubJson = json_decode($hubFile, true);
 				if (!is_array($hubJson) || empty($hubJson['key']) || !ctype_xdigit($hubJson['key'])) {
 					$text = 'Invalid JSON for WebSub: ' . $this->url;
@@ -1027,7 +1027,7 @@ class FreshRSS_Feed extends Minz_Model {
 		} else {
 			$url = $this->url;	//Always use current URL during unsubscribe
 		}
-		if ($url && (Minz_Request::serverIsPublic(FreshRSS_Context::systemConf()->base_url) || !$state)) {
+		if ($url !== '' && (Minz_Request::serverIsPublic(FreshRSS_Context::systemConf()->base_url) || !$state)) {
 			$hubFilename = PSHB_PATH . '/feeds/' . sha1($url) . '/!hub.json';
 			$hubFile = @file_get_contents($hubFilename);
 			if ($hubFile === false) {

+ 19 - 19
app/Models/FeedDAO.php

@@ -71,7 +71,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 			$feedId = $this->pdo->lastInsertId('`_feed_id_seq`');
 			return $feedId === false ? false : (int)$feedId;
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			if ($this->autoUpdateDb($info)) {
 				return $this->addFeed($valuesTmp);
 			}
@@ -83,7 +83,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 	public function addFeedObject(FreshRSS_Feed $feed): int|false {
 		// Add feed only if we don’t find it in DB
 		$feed_search = $this->searchByUrl($feed->url());
-		if (!$feed_search) {
+		if ($feed_search === null) {
 			$values = [
 				'id' => $feed->id(),
 				'url' => $feed->url(),
@@ -176,7 +176,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 		if ($stm !== false && $stm->execute($values)) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			if ($this->autoUpdateDb($info)) {
 				return $this->updateFeed($id, $originalValues);
 			}
@@ -212,7 +212,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 		if ($stm !== false && $stm->execute($values)) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::warning(__METHOD__ . ' error: ' . $sql . ' : ' . json_encode($info));
 			return false;
 		}
@@ -244,7 +244,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 		if ($stm !== false && $stm->execute($values)) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -259,7 +259,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 		if ($stm !== false && $stm->execute($values)) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -280,7 +280,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 		if ($stm !== false && $stm->execute($values)) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -460,7 +460,7 @@ SQL;
 		if ($stm !== false && $stm->execute($feedIds)) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -482,14 +482,14 @@ WHERE id_feed=:id_feed1 AND is_read=0 AND id <= (SELECT e3.id FROM (
 	OFFSET :limit) e3)
 SQL;
 
-		if (($stm = $this->pdo->prepare($sql)) &&
+		if (($stm = $this->pdo->prepare($sql)) !== false &&
 			$stm->bindParam(':id_feed1', $id, PDO::PARAM_INT) &&
 			$stm->bindParam(':id_feed2', $id, PDO::PARAM_INT) &&
 			$stm->bindParam(':limit', $n, PDO::PARAM_INT) &&
 			$stm->execute()) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -505,13 +505,13 @@ UPDATE `_entry` SET is_read=1
 WHERE id_feed=:id_feed AND is_read=0 AND (`lastSeen` + 10 < :min_last_seen)
 SQL;
 
-		if (($stm = $this->pdo->prepare($sql)) &&
+		if (($stm = $this->pdo->prepare($sql)) !== false &&
 			$stm->bindValue(':id_feed', $id, PDO::PARAM_INT) &&
 			$stm->bindValue(':min_last_seen', $minLastSeen, PDO::PARAM_INT) &&
 			$stm->execute()) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -524,7 +524,7 @@ SQL;
 		if (!($stm !== false &&
 			$stm->bindParam(':id', $id, PDO::PARAM_INT) &&
 			$stm->execute())) {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			$this->pdo->rollBack();
 			return false;
@@ -536,7 +536,7 @@ SQL;
 		if (!($stm !== false &&
 			$stm->bindParam(':id', $id, PDO::PARAM_INT) &&
 			$stm->execute())) {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			$this->pdo->rollBack();
 			return false;
@@ -550,8 +550,8 @@ SQL;
 		$sql = 'DELETE FROM `_entry`';
 		$stm = $this->pdo->prepare($sql);
 		$this->pdo->beginTransaction();
-		if (!($stm && $stm->execute())) {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		if ($stm === false || !$stm->execute()) {
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . ' A ' . json_encode($info));
 			$this->pdo->rollBack();
 			return false;
@@ -559,8 +559,8 @@ SQL;
 
 		$sql = 'UPDATE `_feed` SET `cache_nbEntries` = 0, `cache_nbUnreads` = 0';
 		$stm = $this->pdo->prepare($sql);
-		if (!($stm && $stm->execute())) {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		if ($stm === false || !$stm->execute()) {
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . ' B ' . json_encode($info));
 			$this->pdo->rollBack();
 			return false;
@@ -618,7 +618,7 @@ SQL;
 	public function count(): int {
 		$sql = 'SELECT COUNT(e.id) AS count FROM `_feed` e';
 		$stm = $this->pdo->query($sql);
-		if ($stm == false) {
+		if ($stm === false) {
 			return -1;
 		}
 		$res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);

+ 1 - 1
app/Models/FeedDAOSQLite.php

@@ -6,7 +6,7 @@ class FreshRSS_FeedDAOSQLite extends FreshRSS_FeedDAO {
 	/** @param array<int|string> $errorInfo */
 	#[\Override]
 	protected function autoUpdateDb(array $errorInfo): bool {
-		if ($tableInfo = $this->pdo->query("PRAGMA table_info('feed')")) {
+		if (($tableInfo = $this->pdo->query("PRAGMA table_info('feed')")) !== false) {
 			$columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1);
 			foreach (['attributes', 'kind'] as $column) {
 				if (!in_array($column, $columns, true)) {

+ 1 - 1
app/Models/FormAuth.php

@@ -32,7 +32,7 @@ class FreshRSS_FormAuth {
 		}
 
 		$credentials = @file_get_contents($token_file);
-		if ($credentials !== false && self::renewCookie($token)) {
+		if ($credentials !== false && self::renewCookie($token) != false) {
 			return explode("\t", $credentials, 2);
 		}
 		return [];

+ 1 - 1
app/Models/LogDAO.php

@@ -13,7 +13,7 @@ final class FreshRSS_LogDAO {
 	public static function lines(?string $logFileName = null): array {
 		$logs = [];
 		$handle = @fopen(self::logPath($logFileName), 'r');
-		if ($handle) {
+		if (is_resource($handle)) {
 			while (($line = fgets($handle)) !== false) {
 				if (preg_match('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) {
 					$myLog = new FreshRSS_Log();

+ 10 - 10
app/Models/TagDAO.php

@@ -34,7 +34,7 @@ SQL;
 			$tagId = $this->pdo->lastInsertId('`_tag_id_seq`');
 			return $tagId === false ? false : (int)$tagId;
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -42,7 +42,7 @@ SQL;
 
 	public function addTagObject(FreshRSS_Tag $tag): int|false {
 		$tag0 = $this->searchByName($tag->name());
-		if (!$tag0) {
+		if ($tag0 === null) {
 			$values = [
 				'name' => $tag->name(),
 				'attributes' => $tag->attributes(),
@@ -68,7 +68,7 @@ SQL;
 			$stm->execute()) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -86,7 +86,7 @@ SQL;
 			$stm->execute()) {
 			return $stm->rowCount();
 		}
-		$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 		Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 		return false;
 	}
@@ -111,7 +111,7 @@ SQL;
 		if ($stm !== false && $stm->execute($values)) {
 			return $stm->rowCount();
 		} else {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 			return false;
 		}
@@ -155,7 +155,7 @@ SQL;
 		$stm = $this->pdo->prepare($sql);
 
 		if ($stm === false || !$stm->execute([$newTagId, $oldTagId])) {
-			$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+			$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 			Minz_Log::error('SQL error ' . __METHOD__ . ' A ' . json_encode($info));
 			return false;
 		}
@@ -166,7 +166,7 @@ SQL;
 		if ($stm !== false && $stm->execute([$newTagId, $oldTagId])) {
 			return $stm->rowCount();
 		}
-		$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 		Minz_Log::error('SQL error ' . __METHOD__ . ' B ' . json_encode($info));
 		return false;
 	}
@@ -285,7 +285,7 @@ SQL;
 		if ($stm !== false && $stm->execute($values)) {
 			return true;
 		}
-		$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 		Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 		return false;
 	}
@@ -341,7 +341,7 @@ SQL;
 			}
 			return $lines;
 		}
-		$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 		Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 		return false;
 	}
@@ -396,7 +396,7 @@ SQL;
 		if ($stm !== false && $stm->execute($values)) {
 			return $stm->fetchAll(PDO::FETCH_ASSOC);
 		}
-		$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 		Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
 		return false;
 	}

+ 2 - 2
app/Models/Themes.php

@@ -21,7 +21,7 @@ class FreshRSS_Themes extends Minz_Model {
 		$list = [];
 		foreach ($themes_list as $theme_dir) {
 			$theme = self::get_infos($theme_dir);
-			if ($theme) {
+			if (is_array($theme)) {
 				$list[$theme_dir] = $theme;
 			}
 		}
@@ -60,7 +60,7 @@ class FreshRSS_Themes extends Minz_Model {
 	 */
 	public static function load(string $theme_id): array|false {
 		$infos = self::get_infos($theme_id);
-		if (!$infos) {
+		if (empty($infos)) {
 			if ($theme_id !== self::$defaultTheme) {	//Fall-back to default theme
 				return self::load(self::$defaultTheme);
 			}

+ 3 - 3
app/Models/View.php

@@ -17,8 +17,8 @@ class FreshRSS_View extends Minz_View {
 	public string $current_user;
 	/** @var iterable<FreshRSS_Entry> */
 	public $entries;
-	public FreshRSS_Entry $entry;
-	public FreshRSS_Feed $feed;
+	public ?FreshRSS_Entry $entry = null;
+	public ?FreshRSS_Feed $feed = null;
 	/** @var array<int,FreshRSS_Feed> */
 	public array $feeds;
 	public int $nbUnreadTags;
@@ -30,7 +30,7 @@ class FreshRSS_View extends Minz_View {
 	public array $tagsForEntries;
 	public bool $excludeMutedFeeds;
 
-	// Substriptions
+	// Subscriptions
 	public bool $displaySlider = false;
 	public bool $load_ok;
 	public bool $onlyFeedsWithError;

+ 1 - 1
app/Models/ViewStats.php

@@ -5,7 +5,7 @@ final class FreshRSS_ViewStats extends FreshRSS_View {
 
 	/** @var array<int,FreshRSS_Category> */
 	public array $categories;
-	public FreshRSS_Feed $feed;
+	public ?FreshRSS_Feed $feed = null;
 	/** @var array<int,FreshRSS_Feed> */
 	public array $feeds;
 	public bool $displaySlider = false;

+ 1 - 1
app/Services/ExportService.php

@@ -130,7 +130,7 @@ class FreshRSS_Export_Service {
 		$exported_files = [];
 		foreach ($feed_ids as $feed_id) {
 			$result = $this->generateFeedEntries($feed_id, $max_number_entries);
-			if (!$result) {
+			if ($result === null) {
 				continue;
 			}
 

+ 4 - 4
app/Services/ImportService.php

@@ -91,7 +91,7 @@ class FreshRSS_Import_Service {
 
 				if ($can_create_category) {
 					$category = $this->createCategory($category_element, $dry_run);
-					if ($category) {
+					if ($category !== null) {
 						$categories_by_names[$category->name()] = $category;
 						$nb_categories++;
 					}
@@ -102,7 +102,7 @@ class FreshRSS_Import_Service {
 				}
 			}
 
-			if (!$category) {
+			if ($category === null) {
 				// Category can be null if the feeds weren't in a category
 				// outline, or if we weren't able to create the category.
 				$category = $default_category;
@@ -121,7 +121,7 @@ class FreshRSS_Import_Service {
 					break;
 				}
 
-				if ($this->createFeed($feed_element, $category, $dry_run)) {
+				if ($this->createFeed($feed_element, $category, $dry_run) !== null) {
 					// TODO what if the feed already exists in the database?
 					$nb_feeds++;
 				} else {
@@ -301,7 +301,7 @@ class FreshRSS_Import_Service {
 				return $feed;
 			}
 
-			if ($feed != null) {
+			if ($feed !== null) {
 				// addFeedObject checks if feed is already in DB
 				$id = $this->feedDAO->addFeedObject($feed);
 				if ($id == false) {

+ 2 - 2
app/views/configure/archiving.phtml

@@ -59,8 +59,8 @@
 			<div class="group-controls">
 				<label class="checkbox" for="enable_keep_period">
 					<input type="checkbox" name="enable_keep_period" id="enable_keep_period" value="1"<?=
-						FreshRSS_Context::userConf()->volatile['enable_keep_period'] ? ' checked="checked"' : '' ?>
-						data-leave-validation="<?= FreshRSS_Context::userConf()->volatile['enable_keep_period'] ? 1 : 0 ?>"/>
+						empty(FreshRSS_Context::userConf()->volatile['enable_keep_period']) ? '' : ' checked="checked"' ?>
+						data-leave-validation="<?= empty(FreshRSS_Context::userConf()->volatile['enable_keep_period']) ? 0 : 1 ?>"/>
 					<?= _t('conf.archiving.keep_period') ?>
 					<input type="number" id="keep_period_count" name="keep_period_count" min="0" value="<?= FreshRSS_Context::userConf()->volatile['keep_period_count'] ?>"
 						data-leave-validation="<?= FreshRSS_Context::userConf()->volatile['keep_period_count'] ?>"/>

+ 2 - 2
app/views/configure/queries.phtml

@@ -49,11 +49,11 @@
 					<li class="item"><?= _t('conf.query.state_' . $query->getState()) ?></li>
 					<?php } ?>
 
-					<?php if ($query->getOrder()) { ?>
+					<?php if ($query->getOrder() !== '') { ?>
 					<li class="item"><?= _t('conf.query.order_' . strtolower($query->getOrder())) ?></li>
 					<?php } ?>
 
-					<?php if ($query->getGet()) { ?>
+					<?php if ($query->getGet() !== '') { ?>
 					<li class="item"><?= _t('conf.query.get_' . $query->getGetType(), $query->getGetName()) ?></li>
 					<?php } ?>
 					<?php } ?>

+ 1 - 1
app/views/configure/query.phtml

@@ -5,6 +5,6 @@ declare(strict_types=1);
 if (!Minz_Request::paramBoolean('ajax')) {
 	$this->partial('aside_configure');
 }
-if ($this->query) {
+if ($this->query !== null) {
 	$this->renderHelper('configure/query');
 }

+ 3 - 0
app/views/helpers/feed/update.phtml

@@ -1,6 +1,9 @@
 <?php
 	declare(strict_types=1);
 	/** @var FreshRSS_View $this */
+	if ($this->feed === null) {
+		return;
+	}
 ?>
 <div class="post" id="feed_update">
 	<h1><?= $this->feed->name() ?></h1>

+ 6 - 3
app/views/helpers/index/article.phtml

@@ -4,6 +4,9 @@
 	/** @var FreshRSS_View $this */
 	$entry = $this->entry;
 	$feed = $this->feed;
+	if ($feed === null || $entry === null) {
+		return;
+	}
 ?>
 <article class="flux_content" dir="auto">
 <div class="content <?= FreshRSS_Context::userConf()->content_width ?>">
@@ -29,7 +32,7 @@
 					<div class="item manage">
 						<a class="bookmark" href="<?= Minz_Url::display($favoriteUrl) ?>" title="<?= _t('conf.shortcut.mark_favorite') ?>"><?= _i($entry->isFavorite() ? 'starred' : 'non-starred') ?></a>
 					</div>
-				<?php } ?>					
+				<?php } ?>
 			<?php } ?>
 			<div class="item">
 				<?php if (FreshRSS_Context::userConf()->show_feed_name === 't') { ?>
@@ -42,7 +45,7 @@
 			<?php
 			if (FreshRSS_Context::userConf()->topline_link && FreshRSS_Context::userConf()->show_article_icons == 't') { ?>
 				<div class="item link">
-					<a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>" class="item-element" title="<?= _t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a>
+					<a target="_blank" rel="noreferrer" href="<?= $entry->link() ?>" class="item-element" title="<?= _t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a>
 				</div>
 			<?php } ?>
 		</div>
@@ -93,7 +96,7 @@
 				<?php
 				if (FreshRSS_Context::userConf()->topline_link && FreshRSS_Context::userConf()->show_article_icons == 'a') { ?>
 					<div class="item link">
-						<a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>" class="item-element" title="<?= _t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a>
+						<a target="_blank" rel="noreferrer" href="<?= $entry->link() ?>" class="item-element" title="<?= _t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a>
 					</div>
 				<?php } ?>
 			</div>

+ 3 - 0
app/views/helpers/index/normal/entry_bottom.phtml

@@ -1,6 +1,9 @@
 <?php
 	declare(strict_types=1);
 	/** @var FreshRSS_View $this */
+	if ($this->entry === null) {
+		return;
+	}
 	$bottomline_read = FreshRSS_Context::userConf()->bottomline_read;
 	$bottomline_favorite = FreshRSS_Context::userConf()->bottomline_favorite;
 	$bottomline_sharing = FreshRSS_Context::userConf()->bottomline_sharing && (count(FreshRSS_Context::userConf()->sharing) > 0);

+ 3 - 0
app/views/helpers/index/normal/entry_header.phtml

@@ -11,6 +11,9 @@
 	$topline_date = FreshRSS_Context::userConf()->topline_date;
 	$topline_link = FreshRSS_Context::userConf()->topline_link;
 	$lazyload = FreshRSS_Context::userConf()->lazyload;
+	if ($this->feed === null || $this->entry === null) {
+		return;
+	}
 ?><ul class="horizontal-list flux_header website<?= $topline_website ?>" data-website-name="<?= $this->feed->name() ?>" data-article-authors="<?= implode(', ', $this->entry->authors()) ?>"><?php
 	if (FreshRSS_Auth::hasAccess()) {
 		if ($topline_read) {

+ 3 - 0
app/views/helpers/index/tags.phtml

@@ -1,6 +1,9 @@
 <?php
 	declare(strict_types=1);
 	/** @var FreshRSS_View $this */
+	if ($this->entry === null) {
+		return;
+	}
 	[$firstTags,$remainingTags] = $this->entry->tagsFormattingHelper();
 ?>
 <div class="tags">

+ 1 - 1
app/views/helpers/stream-footer.phtml

@@ -27,7 +27,7 @@
 <div id="stream-footer">
 <?php }?>
 	<div class="stream-footer-inner">
-	<?php if (FreshRSS_Context::$next_id) { ?>
+	<?php if (FreshRSS_Context::$next_id !== '') { ?>
 		<button id="load_more" type="submit" class="btn" formaction="<?= Minz_Url::display($url_next) ?>"><?= _t('gen.stream.load_more') ?></button>
 	<?php } elseif ($hasAccess) { ?>
 		<?= _t('gen.stream.nothing_to_load') ?><br />

+ 10 - 1
app/views/index/normal.phtml

@@ -74,6 +74,9 @@ $today = @strtotime('today');
 		?>" data-priority="<?= $this->feed->priority()
 		?>"><?php
 			$this->renderHelper('index/normal/entry_header');
+			if ($this->feed === null || $this->entry === null) {
+				throw new Exception('Unexpected side effect!');	// Should never occur. Only for PHPStan
+			}
 		?><article class="flux_content" dir="auto">
 			<div class="content <?= FreshRSS_Context::userConf()->content_width ?>">
 				<header>
@@ -86,6 +89,9 @@ $today = @strtotime('today');
 					<?php } ?>
 					<?php if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') {
 						$this->renderHelper('index/tags');
+						if ($this->feed === null || $this->entry === null) {
+							throw new Exception('Unexpected side effect!');	// Should never occur. Only for PHPStan
+						}
 					} ?>
 					<h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?= $this->entry->link() ?>" title="<?= _t('conf.shortcut.see_on_website')?>"><?= $this->entry->title() ?></a></h1>
 					<?php if (FreshRSS_Context::userConf()->show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?>
@@ -196,4 +202,7 @@ $today = @strtotime('today');
 	<?= _i('close') ?>
 </a>
 
-<?php if ($nbEntries > 0 && FreshRSS_Context::userConf()->show_nav_buttons) $this->partial('nav_entries'); ?>
+<?php
+	if ($nbEntries > 0 && FreshRSS_Context::userConf()->show_nav_buttons) {
+		$this->partial('nav_entries');
+	}

+ 2 - 2
app/views/stats/repartition.phtml

@@ -17,7 +17,7 @@
 		if (!empty($feeds)) {
 			echo '<optgroup label="', $category->name(), '">';
 			foreach ($feeds as $feed) {
-				if ($this->feed && $feed->id() == $this->feed->id()) {
+				if ($this->feed !== null && $feed->id() == $this->feed->id()) {
 					echo '<option value="', $feed->id(), '" selected="selected" data-url="',
 						_url('stats', 'repartition', 'id', $feed->id()), '">', $feed->name(), '</option>';
 				} else {
@@ -30,7 +30,7 @@
 	}?>
 	</select>
 
-	<?php if ($this->feed) {?>
+	<?php if ($this->feed !== null) {?>
 		<a class="btn" href="<?= _url('subscription', 'feed', 'id', $this->feed->id()) ?>">
 			<?= _i('configure') ?> <?= _t('gen.action.manage') ?>
 		</a>

+ 1 - 1
app/views/subscription/feed.phtml

@@ -6,7 +6,7 @@ if (!Minz_Request::paramBoolean('ajax')) {
 	$this->partial('aside_subscription');
 }
 
-if ($this->feed) {
+if ($this->feed !== null) {
 	$this->renderHelper('feed/update');
 } else {
 ?>

+ 6 - 5
cli/CliOptionsParser.php

@@ -11,6 +11,7 @@ abstract class CliOptionsParser {
 	public string $usage = '';
 
 	public function __construct() {
+		/** @var array<string> $argv */
 		global $argv;
 
 		$this->usage = $this->getUsageMessage($argv[0]);
@@ -82,7 +83,7 @@ abstract class CliOptionsParser {
 		foreach ($this->inputs as $name => $input) {
 			$values = $input['values'] ?? $input['defaultInput'] ?? null;
 			$types = $this->options[$name]->getTypes();
-			if ($values) {
+			if (!empty($values)) {
 				$validValues = [];
 				$typedValues = [];
 
@@ -205,8 +206,8 @@ abstract class CliOptionsParser {
 
 		foreach ($this->options as $option) {
 			$long[] = $option->getLongAlias() . $getoptNotation[$option->getValueTaken()];
-			$long[] = $option->getDeprecatedAlias() ? $option->getDeprecatedAlias() . $getoptNotation[$option->getValueTaken()] : '';
-			$short .= $option->getShortAlias() ? $option->getShortAlias() . $getoptNotation[$option->getValueTaken()] : '';
+			$long[] = $option->getDeprecatedAlias() != null ? $option->getDeprecatedAlias() . $getoptNotation[$option->getValueTaken()] : '';
+			$short .= $option->getShortAlias() != null ? $option->getShortAlias() . $getoptNotation[$option->getValueTaken()] : '';
 		}
 
 		return [
@@ -220,7 +221,7 @@ abstract class CliOptionsParser {
 		$optional = [];
 
 		foreach ($this->options as $name => $option) {
-			$shortAlias = $option->getShortAlias() ? '-' . $option->getShortAlias() . ' ' : '';
+			$shortAlias = $option->getShortAlias() != null ? '-' . $option->getShortAlias() . ' ' : '';
 			$longAlias = '--' . $option->getLongAlias() . ($option->getValueTaken() === 'required' ? '=<' . strtolower($name) . '>' : '');
 			if ($this->inputs[$name]['required']) {
 				$required[] = $shortAlias . $longAlias;
@@ -235,7 +236,7 @@ abstract class CliOptionsParser {
 	private function makeInputRegex(): string {
 		$shortWithValues = '';
 		foreach ($this->options as $option) {
-			if (($option->getValueTaken() === 'required' || $option->getValueTaken() === 'optional') && $option->getShortAlias()) {
+			if (($option->getValueTaken() === 'required' || $option->getValueTaken() === 'optional') && $option->getShortAlias() != null) {
 				$shortWithValues .= $option->getShortAlias();
 			}
 		}

+ 1 - 1
cli/create-user.php

@@ -58,7 +58,7 @@ if (!empty($cliOptions->errors)) {
 
 $username = $cliOptions->user;
 
-if (preg_grep("/^$username$/i", listUsers())) {
+if (!empty(preg_grep("/^$username$/i", listUsers()))) {
 	fail('FreshRSS warning: username already exists “' . $username . '”', EXIT_CODE_ALREADY_EXISTS);
 }
 

+ 1 - 1
cli/update-user.php

@@ -80,7 +80,7 @@ if (!$ok) {
 
 if (isset($cliOptions->apiPassword)) {
 	$error = FreshRSS_api_Controller::updatePassword($cliOptions->apiPassword);
-	if ($error) {
+	if ($error !== false) {
 		fail($error);
 	}
 }

+ 1 - 2
composer.json

@@ -77,8 +77,7 @@
             "@phtml-lint",
             "@phpunit",
             "@phpcs",
-            "@phpstan",
-            "@phpstan-next"
+            "@phpstan"
         ],
         "fix": [
             "@translations",

+ 1 - 1
lib/Minz/ModelPdo.php

@@ -224,7 +224,7 @@ class Minz_ModelPdo {
 			$calling .= '|' . $backtrace[$i]['function'];
 		}
 		$calling = trim($calling, '|');
-		$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+		$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
 		Minz_Log::error('SQL error ' . $calling . ' ' . json_encode($info));
 		return null;
 	}

+ 4 - 4
lib/lib_rss.php

@@ -285,9 +285,9 @@ function customSimplePie(array $attributes = [], array $curl_options = []): Simp
 
 	$curl_options = array_replace(FreshRSS_Context::systemConf()->curl_options, $curl_options);
 	if (isset($attributes['ssl_verify'])) {
-		$curl_options[CURLOPT_SSL_VERIFYHOST] = $attributes['ssl_verify'] ? 2 : 0;
+		$curl_options[CURLOPT_SSL_VERIFYHOST] = empty($attributes['ssl_verify']) ? 0 : 2;
 		$curl_options[CURLOPT_SSL_VERIFYPEER] = (bool)$attributes['ssl_verify'];
-		if (!$attributes['ssl_verify']) {
+		if (empty($attributes['ssl_verify'])) {
 			$curl_options[CURLOPT_SSL_CIPHER_LIST] = 'DEFAULT@SECLEVEL=1';
 		}
 	}
@@ -518,9 +518,9 @@ function httpGet(string $url, string $cachePath, string $type = 'html', array $a
 	}
 
 	if (isset($attributes['ssl_verify'])) {
-		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $attributes['ssl_verify'] ? 2 : 0);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, empty($attributes['ssl_verify']) ? 0 : 2);
 		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (bool)$attributes['ssl_verify']);
-		if (!$attributes['ssl_verify']) {
+		if (empty($attributes['ssl_verify'])) {
 			curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'DEFAULT@SECLEVEL=1');
 		}
 	}

+ 1 - 34
phpstan-next.neon

@@ -1,41 +1,8 @@
 includes:
 	- phpstan.neon
+	- vendor/phpstan/phpstan/conf/bleedingEdge.neon
 
 parameters:
-	strictRules:
-		booleansInConditions: true
-	ignoreErrors:
-		- '#Only booleans are allowed in (a negated boolean|a ternary operator condition|an elseif condition|an if condition|&&|\|\|), (bool|false|int(<[0-9, max]+>)?|true|null|\|)+ given.*#'
 	excludePaths:
 		analyse:
 			# TODO: Update files below and remove them from this list
-			- app/Controllers/feedController.php
-			- app/Controllers/importExportController.php
-			- app/Controllers/subscriptionController.php
-			- app/Controllers/tagController.php
-			- app/FreshRSS.php
-			- app/Models/CategoryDAO.php
-			- app/Models/CategoryDAOSQLite.php
-			- app/Models/DatabaseDAOSQLite.php
-			- app/Models/Entry.php
-			- app/Models/EntryDAO.php
-			- app/Models/EntryDAOSQLite.php
-			- app/Models/Feed.php
-			- app/Models/FeedDAO.php
-			- app/Models/FeedDAOSQLite.php
-			- app/Models/FormAuth.php
-			- app/Models/LogDAO.php
-			- app/Models/TagDAO.php
-			- app/Models/Themes.php
-			- app/Services/ExportService.php
-			- app/Services/ImportService.php
-			- app/views/configure/archiving.phtml
-			- app/views/configure/queries.phtml
-			- app/views/configure/query.phtml
-			- app/views/helpers/stream-footer.phtml
-			- app/views/stats/repartition.phtml
-			- app/views/subscription/feed.phtml
-			- cli/CliOptionsParser.php
-			- cli/create-user.php
-			- cli/update-user.php
-			- lib/lib_rss.php

+ 2 - 3
phpstan.neon

@@ -38,7 +38,7 @@ parameters:
 	treatPhpDocTypesAsCertain: false
 	strictRules:
 		allRules: false
-		booleansInConditions: false	# TODO pass
+		booleansInConditions: true
 		closureUsesThis: true
 		disallowedConstructs: false
 		disallowedLooseComparison: false
@@ -58,9 +58,8 @@ parameters:
 		checkedExceptionClasses:
 			- 'Minz_Exception'
 	ignoreErrors:
-		# - '#Only booleans are allowed in (a negated boolean|a ternary operator condition|an elseif condition|an if condition|&&|\|\|), (bool|false|int(<[0-9, max]+>)?|true|null|\|)+ given.*#'
+		- '#Only booleans are allowed in (a negated boolean|a ternary operator condition|an elseif condition|an if condition|&&|\|\|), (bool|false|int(<[0-9, max]+>)?|true|null|\|)+ given.*#'
 includes:
 	- vendor/phpstan/phpstan-phpunit/extension.neon
 	- vendor/phpstan/phpstan-phpunit/rules.neon
 	- vendor/phpstan/phpstan-strict-rules/rules.neon
-	# - vendor/phpstan/phpstan/conf/bleedingEdge.neon