Fix deprecations

add phpstan deprecation rules

Co-authored-by: Sean Molenaar <SMillerDev@users.noreply.github.com>
Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
This commit is contained in:
Benjamin Brahmer 2022-08-06 14:07:36 +02:00
parent df04eb2723
commit c09cca75b5
5 changed files with 85 additions and 16 deletions

View File

@ -61,6 +61,7 @@
"phpstan/phpstan-strict-rules": "^1.3.0",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/extension-installer": "^1.1.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"guzzlehttp/guzzle": "^7.3.0",
"doctrine/dbal": "^3.4.1",
"symfony/console": "^4.4.19",

52
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "be4b7c96428a2a97bc7b232d8f1c66f9",
"content-hash": "9b976f8d731e7bdeb9206e114975dd04",
"packages": [
{
"name": "arthurhoaro/favicon",
@ -1333,6 +1333,56 @@
],
"time": "2022-07-20T09:57:31+00:00"
},
{
"name": "phpstan/phpstan-deprecation-rules",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-deprecation-rules.git",
"reference": "e5ccafb0dd8d835dd65d8d7a1a0d2b1b75414682"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/e5ccafb0dd8d835dd65d8d7a1a0d2b1b75414682",
"reference": "e5ccafb0dd8d835dd65d8d7a1a0d2b1b75414682",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0",
"phpstan/phpstan": "^1.0"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5"
},
"type": "phpstan-extension",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"phpstan": {
"includes": [
"rules.neon"
]
}
},
"autoload": {
"psr-4": {
"PHPStan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.",
"support": {
"issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues",
"source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.0.0"
},
"time": "2021-09-23T11:02:21+00:00"
},
{
"name": "phpstan/phpstan-doctrine",
"version": "1.3.12",

View File

@ -170,10 +170,9 @@ class Item extends Entity implements IAPI, \JsonSerializable
? implode('', $this->getCategories())
: '';
$stripedBody = "";
if (!is_null($this->getBody())) {
$stripedBody = strip_tags($this->getBody());
} else {
$stripedBody = "";
}
$input_list = array($stripedBody, $this->getAuthor(), $this->getTitle(), $categoriesString);
@ -181,17 +180,14 @@ class Item extends Entity implements IAPI, \JsonSerializable
$search_string = "";
foreach ($input_list as $value) {
if (is_null($value)) {
$search_string .= "";
} else {
if (!is_null($value)) {
$search_string .= html_entity_decode($value);
}
}
$search_string .= $this->getUrl();
$search_string .= 'UTF-8';
$this->setSearchIndex(mb_strtolower($search_string));
$this->setSearchIndex(mb_strtolower($search_string, 'UTF-8'));
$this->setFingerprint($this->computeFingerprint());
$this->setContentHash($this->computeContentHash());
}
@ -358,6 +354,9 @@ class Item extends Entity implements IAPI, \JsonSerializable
*/
public function getCategories(): ?array
{
if (is_null($this->getCategoriesJson())) {
return null;
}
return json_decode($this->getCategoriesJson());
}
@ -606,6 +605,10 @@ class Item extends Entity implements IAPI, \JsonSerializable
public function setUrl(string $url = null): self
{
if (is_null($url)) {
return $this;
}
$url = trim($url);
if ((strpos($url, 'http') === 0 || strpos($url, 'magnet') === 0)
&& $this->url !== $url
@ -613,7 +616,7 @@ class Item extends Entity implements IAPI, \JsonSerializable
$this->url = $url;
$this->markFieldUpdated('url');
}
return $this;
}

View File

@ -354,9 +354,14 @@ class FeedFetcher implements IFeedFetcher
*/
protected function getFavicon(FeedInterface $feed, string $url)
{
$favicon = null;
// trim the string because authors do funny things
$favicon = trim($feed->getLogo());
$feed_logo = $feed->getLogo();
if (!is_null($feed_logo)) {
$favicon = trim($feed_logo);
}
ini_set('user_agent', 'NextCloud-News/1.0');
$base_url = new Net_URL2($url);

View File

@ -90,11 +90,21 @@ class OPMLExporter
protected function createFeedOutline(Feed $feed, DOMDocument $document)
{
$feedOutline = $document->createElement('outline');
$feedOutline->setAttribute('title', $feed->getTitle());
$feedOutline->setAttribute('text', $feed->getTitle());
$feedOutline->setAttribute('type', 'rss');
$feedOutline->setAttribute('xmlUrl', $feed->getUrl());
$feedOutline->setAttribute('htmlUrl', $feed->getLink());
$attributes = [
['title', $feed->getTitle()],
['text', $feed->getTitle()],
['type', 'rss'],
['xmlUrl', $feed->getUrl()],
['htmlUrl', $feed->getLink()],
];
foreach ($attributes as $attribute) {
if (is_null($attribute[1])) {
$feedOutline->setAttribute($attribute[0], "");
} else {
$feedOutline->setAttribute($attribute[0], $attribute[1]);
}
}
return $feedOutline;
}