Просмотр исходного кода

Pass PHPStan checkBenevolentUnionTypes (#7270)

Alexandre Alapetite 1 год назад
Родитель
Сommit
e749490693
4 измененных файлов с 11 добавлено и 5 удалено
  1. 8 0
      app/Models/Feed.php
  2. 1 0
      cli/CliOptionsParser.php
  3. 0 3
      phpstan-next.neon
  4. 2 2
      phpstan.dist.neon

+ 8 - 0
app/Models/Feed.php

@@ -1149,6 +1149,10 @@ class FreshRSS_Feed extends Minz_Model {
 				file_put_contents($hubFilename, json_encode($hubJson));
 			}
 			$ch = curl_init();
+			if ($ch === false) {
+				Minz_Log::warning('curl_init() failed in ' . __METHOD__);
+				return false;
+			}
 			curl_setopt_array($ch, [
 				CURLOPT_URL => $hubJson['hub'],
 				CURLOPT_RETURNTRANSFER => true,
@@ -1166,6 +1170,10 @@ class FreshRSS_Feed extends Minz_Model {
 			]);
 			$response = curl_exec($ch);
 			$info = curl_getinfo($ch);
+			if (!is_array($info)) {
+				Minz_Log::warning('curl_getinfo() failed in ' . __METHOD__);
+				return false;
+			}
 
 			Minz_Log::warning('WebSub ' . ($state ? 'subscribe' : 'unsubscribe') . ' to ' . $url .
 				' via hub ' . $hubJson['hub'] .

+ 1 - 0
cli/CliOptionsParser.php

@@ -24,6 +24,7 @@ abstract class CliOptionsParser {
 
 	private function parseInput(): void {
 		$getoptInputs = $this->getGetoptInputs();
+		// @phpstan-ignore argument.type
 		$this->getoptOutputTransformer(getopt($getoptInputs['short'], $getoptInputs['long']));
 		$this->checkForDeprecatedAliasUse();
 	}

+ 0 - 3
phpstan-next.neon

@@ -4,7 +4,6 @@ includes:
 
 parameters:
 	level: max
-	checkBenevolentUnionTypes: true	# TODO pass
 	checkImplicitMixed: true	# TODO pass
 	strictRules:
 		strictArrayFilter: false	# TODO pass maybe
@@ -13,10 +12,8 @@ parameters:
 			# TODO: Update files below and remove them from this list
 			- app/Models/Entry.php
 			- app/Models/EntryDAO.php
-			- app/Models/Feed.php
 			- app/Models/FeedDAO.php
 			- app/Models/TagDAO.php
 			- app/Models/Themes.php
 			- app/Services/ImportService.php
 			- app/views/helpers/feed/update.phtml
-			- cli/CliOptionsParser.php

+ 2 - 2
phpstan.dist.neon

@@ -14,13 +14,13 @@ parameters:
 			- lib/phpgt/*
 			- lib/phpmailer/*
 			- lib/simplepie/*
-			- vendor/*
 		analyseAndScan:
 			- .git/*?
 			- extensions/node_modules?
 			- extensions/symbolic?
 			- extensions/vendor?
 			- node_modules/*?
+			- vendor/*
 	bootstrapFiles:
 		- cli/_cli.php
 		- lib/favicons.php
@@ -36,7 +36,7 @@ parameters:
 		- STDOUT
 		- TMP_PATH
 		- USERS_PATH
-	checkBenevolentUnionTypes: false	# TODO pass
+	checkBenevolentUnionTypes: true
 	checkImplicitMixed: false	# TODO pass
 	checkMissingOverrideMethodAttribute: true
 	checkTooWideReturnTypesInProtectedAndPublicMethods: true