Merge pull request 'fix-phpstan-error-level-1' (#1579) from MrPetovan/friendica-addons:fix-phpstan-error-level-1 into develop

Reviewed-on: friendica/friendica-addons#1579
This commit is contained in:
Hypolite Petovan 2024-12-12 22:37:42 +01:00
commit 81a84fb895
19 changed files with 62 additions and 45 deletions

View file

@ -683,6 +683,8 @@ function bluesky_create_activity(array $item, stdClass $parent = null)
return;
}
$post = [];
if ($item['verb'] == Activity::LIKE) {
$record = [
'subject' => $parent,
@ -1563,7 +1565,7 @@ function bluesky_get_uri_class(string $uri): ?stdClass
}
$elements = explode(':', $uri);
if (empty($elements) || ($elements[0] != 'at')) {
if ($elements[0] !== 'at') {
$post = Post::selectFirstPost(['extid'], ['uri' => $uri]);
return bluesky_get_uri_class($post['extid'] ?? '');
}

View file

@ -181,7 +181,7 @@ function convert_content() {
}
}
$o .= '<h3>Unit Conversions</h3>';
$o = '<h3>Unit Conversions</h3>';
if (isset($_POST['from_unit']) && isset($_POST['value'])) {
$o .= ($conv->getTable(intval($_POST['value']), $_POST['from_unit'], $_POST['to_unit'], 5)) . '</p>';

View file

@ -2,8 +2,8 @@
usleep(100000);
$fileName;
$fileSize;
$fileName = '';
$fileSize = 0;;
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];

View file

@ -2,7 +2,7 @@
sleep(4);
$fileName;
$fileName = '';
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];

View file

@ -2,7 +2,7 @@
usleep(300);
$fileName;
$fileName = '';
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];

View file

@ -6,7 +6,6 @@
* Author: Ryan <https://verya.pe/profile/ryan>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
@ -92,7 +91,7 @@ function keycloakpassword_authenticate(array &$b)
$client_id,
$secret,
$endpoint . '/logout',
[ 'refresh_token' => res['refresh_token'] ]
[ 'refresh_token' => $res['refresh_token'] ]
);
}
}

View file

@ -7,7 +7,6 @@
* License: MIT
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
@ -148,6 +147,8 @@ function langfilter_prepare_body_content_filter(&$hook_data)
$iso639 = new Matriphe\ISO639\ISO639;
$confidence = null;
// Extract the language of the post
if (!empty($hook_data['item']['language'])) {
$languages = json_decode($hook_data['item']['language'], true);

View file

@ -6,7 +6,6 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\DI;
@ -149,7 +148,7 @@ function leistungsschutzrecht_is_member_site(string $url): bool
$cleanedurlpart = explode('%', $urldata['host']);
$hostname = explode('.', $cleanedurlpart[0]);
if (empty($hostname)) {
if ($hostname === false || $hostname === '') {
return false;
}

View file

@ -401,9 +401,8 @@ class Services_Libravatar
*/
protected function srvGet($domain, $https = false)
{
// Are we going secure? Set up a fallback too.
if (isset($https) && $https === true) {
if ($https === true) {
$subdomain = '_avatars-sec._tcp.';
$fallback = 'seccdn.';
} else {
@ -426,6 +425,7 @@ class Services_Libravatar
$top = $srv[0];
$sum = 0;
$pri = [];
// Try to adhere to RFC2782's weighting algorithm, page 3
// "arrange all SRV RRs (that have not been ordered yet) in any order,

View file

@ -8,7 +8,6 @@
* Author: Cat Gray <https://free-haven.org/profile/catness>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
@ -203,10 +202,12 @@ EOT;
Logger::debug('ljpost: data: ' . $xml);
$x = '';
if ($lj_blog !== 'test') {
$x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
}
Logger::info('posted to livejournal: ' . ($x) ? $x : '');
Logger::info('posted to livejournal: ' . $x);
}
}

View file

@ -3287,7 +3287,7 @@ class PHPMailer
$result = 'localhost.localdomain';
if (!empty($this->Hostname)) {
$result = $this->Hostname;
} elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
} elseif (!empty($_SERVER['SERVER_NAME'])) {
$result = $_SERVER['SERVER_NAME'];
} elseif (function_exists('gethostname') && gethostname() !== false) {
$result = gethostname();

View file

@ -8,7 +8,6 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -119,7 +118,9 @@ function nsfw_prepare_body_content_filter(&$hook_data)
$word_list = ['nsfw'];
}
$found = false;
$found = false;
$tag_search = false;
if (count($word_list)) {
$body = $hook_data['item']['title'] . "\n" . nsfw_extract_photos($hook_data['item']['body']);
@ -129,7 +130,6 @@ function nsfw_prepare_body_content_filter(&$hook_data)
continue;
}
$tag_search = false;
switch ($word[0]) {
case '/'; // Regular expression
$found = @preg_match($word, $body);

View file

@ -1339,6 +1339,8 @@ class phpnut
*/
protected function updateUserImage(string $image, string $which='avatar')
{
$mimeType = '';
$test = @getimagesize($image);
if ($test && array_key_exists('mime', $test)) {
$mimeType = $test['mime'];

View file

@ -6,7 +6,6 @@
* Author: Michael Vogel <http://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
@ -582,6 +581,8 @@ function pumpio_action(int $uid, string $uri, string $action, string $content =
$uri = $orig_post['uri'];
}
$objectType = '';
if (($orig_post['object-type'] != '') && (strstr($orig_post['object-type'], ActivityNamespace::ACTIVITY_SCHEMA))) {
$objectType = str_replace(ActivityNamespace::ACTIVITY_SCHEMA, '', $orig_post['object-type']);
} elseif (strstr($uri, '/api/comment/')) {
@ -827,6 +828,7 @@ function pumpio_dounlike(int $uid, array $self, $post, string $own_id)
}
$contactid = 0;
$contact = [];
if (Strings::compareLink($post->actor->url, $own_id)) {
$contactid = $self['id'];
@ -1430,6 +1432,8 @@ function pumpio_fetchallcomments($uid, $id)
Logger::notice('pumpio_fetchallcomments: fetching comment for user ' . $uid . ', URL ' . $url);
$item = new \stdClass();
if (pumpio_reachable($url)) {
$success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError' => true], $item);
} else {

View file

@ -26,6 +26,7 @@ class RatioedPanel extends Active
$action = $this->parameters['action'] ?? '';
$uid = $this->parameters['uid'] ?? 0;
$user = [];
if ($uid) {
$user = User::getById($uid, ['username', 'blocked']);

View file

@ -31,11 +31,10 @@ use Friendica\Core\System;
/**
* Define constants
*/
$constants = explode(' ', 'OBJECT ARRAY JSON');
foreach ($constants as $i => $id) {
$id = 'CODEBIRD_RETURNFORMAT_' . $id;
defined($id) or define($id, $i);
}
defined('CODEBIRD_RETURNFORMAT_ARRAY') or define('CODEBIRD_RETURNFORMAT_ARRAY', 0);
defined('CODEBIRD_RETURNFORMAT_JSON') or define('CODEBIRD_RETURNFORMAT_JSON', 1);
defined('CODEBIRD_RETURNFORMAT_OBJECT') or define('CODEBIRD_RETURNFORMAT_OBJECT', 2);
$constants = array(
'CURLE_SSL_CERTPROBLEM' => 58,
'CURLE_SSL_CACERT' => 60,
@ -788,6 +787,8 @@ class CodebirdSN
$possible_files = explode(' ', $possible_files[$method]);
$data = '';
$multipart_border = '--------------------' . $this->_nonce();
$multipart_request = '';
foreach ($params as $key => $value) {
@ -917,7 +918,7 @@ class CodebirdSN
$authorization = 'Authorization: Bearer ' . self::$_oauth_bearer_token;
}
$request_headers = array();
if (isset($authorization)) {
if ($authorization !== '') {
$request_headers[] = $authorization;
$request_headers[] = 'Expect:';
}

View file

@ -366,6 +366,8 @@ function statusnet_post_hook(array &$b)
$otoken = DI::pConfig()->get($b['uid'], 'statusnet', 'oauthtoken');
$osecret = DI::pConfig()->get($b['uid'], 'statusnet', 'oauthsecret');
$iscomment = null;
if ($ckey && $csecret && $otoken && $osecret) {
$dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
$max_char = $dent->get_maxlength(); // max. length for a dent

View file

@ -7,7 +7,6 @@
* Status: unsupported
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@ -30,7 +29,12 @@ function tictac_module() {}
function tictac_content() {
$o = '';
$o = '';
$dimen = 3;
$handicap = 0;
$mefirst = 0;
$yours = '';
$mine = '';
if($_POST['move']) {
$handicap = DI::args()->get(1);
@ -45,9 +49,6 @@ function tictac_content() {
$handicap = DI::args()->get(1);
$dimen = 3;
}
else {
$dimen = 3;
}
$o .= '<h3>' . DI::l10n()->t('3D Tic-Tac-Toe') . '</h3><br />';
@ -163,7 +164,7 @@ class tictac {
];
function __construct($dimen, $handicap, $mefirst, $yours, $mine) {
$this->dimen = 3;
$this->dimen = $dimen;
$this->handicap = $handicap ? 1 : 0;
$this->mefirst = $mefirst ? 1 : 0;
$this->yours = str_replace('XXX','',$yours);
@ -228,6 +229,8 @@ class tictac {
}
function parse_moves($player) {
$str = '';
if($player == 'me')
$str = $this->mine;
if($player == 'you')

View file

@ -259,9 +259,11 @@ EOT;
Logger::debug('wppost: data: ' . $xml);
$x = '';
if ($wp_blog !== 'test') {
$x = DI::httpClient()->post($wp_blog, $xml)->getBodyString();
}
Logger::info('posted to wordpress: ' . (($x) ? $x : ''));
Logger::info('posted to wordpress: ' . $x);
}
}