diff --git a/src/BaseEntity.php b/src/BaseEntity.php
index 09a2562c8e..f50e72e837 100644
--- a/src/BaseEntity.php
+++ b/src/BaseEntity.php
@@ -7,7 +7,9 @@
namespace Friendica;
+use DateTime;
use Friendica\Network\HTTPException\InternalServerErrorException;
+use Psr\Http\Message\UriInterface;
/**
* The Entity classes directly inheriting from this abstract class are meant to represent a single business entity.
@@ -24,16 +26,32 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
* Since these objects aren't meant to be using any dependency, including logging, unit tests can and must be
* written for each and all of their methods
*
- * @property-read int $id
+ * @property-read int|null $id
* @property-read int $uid
* @property-read string $verb
- * @property-read int $type
+ * @property-read int|string $type
* @property-read int $actorId
* @property-read int $targetUriId
- * @property-read int $parentUriId
- * @property-read \DateTime $created
+ * @property-read int|null $parentUriId
+ * @property-read \DateTime|string $created
* @property-read bool $seen
* @property-read bool $dismissed
+ * @property-read string $name
+ * @property-read UriInterface $url
+ * @property-read UriInterface $photo
+ * @property-read DateTime $date
+ * @property-read string|null $msg
+ * @property-read UriInterface $link
+ * @property-read int|null $itemId
+ * @property-read int|null $parent
+ * @property-read string|null $otype
+ * @property-read string|null $name_cache
+ * @property-read string|null $msg_cache
+ * @property-read int|null $uriId
+ * @property-read string $cookie_hash
+ * @property-read string $user_agent
+ * @property-read bool $trusted
+ * @property-read string|null $last_used
*/
abstract class BaseEntity extends BaseDataTransferObject
{
diff --git a/src/Module/Admin/Summary.php b/src/Module/Admin/Summary.php
index 736c8b3e2e..f07e9720cb 100644
--- a/src/Module/Admin/Summary.php
+++ b/src/Module/Admin/Summary.php
@@ -9,7 +9,6 @@ namespace Friendica\Module\Admin;
use Friendica\App;
use Friendica\Core\Addon;
-use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Renderer;
use Friendica\Core\Update;
@@ -19,7 +18,6 @@ use Friendica\DI;
use Friendica\Core\Config\Factory\Config;
use Friendica\Module\BaseAdmin;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
-use Friendica\Network\HTTPException\ServiceUnavailableException;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
@@ -55,7 +53,7 @@ class Summary extends BaseAdmin
$table_definition_cache = DBA::getVariable('table_definition_cache');
$table_open_cache = DBA::getVariable('table_open_cache');
if (!empty($table_definition_cache) && !empty($table_open_cache)) {
- $suggested_definition_cache = min(400 + round($table_open_cache / 2, 1), 2000);
+ $suggested_definition_cache = min(400 + round((int) $table_open_cache / 2, 1), 2000);
if ($suggested_definition_cache > $table_definition_cache) {
$warningtext[] = DI::l10n()->t('Your table_definition_cache is too low (%d). This can lead to the database error "Prepared statement needs to be re-prepared". Please set it at least to %d. See here for more information.
', $table_definition_cache, $suggested_definition_cache, 'https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_table_definition_cache');
}
diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php
index a2efbfc1cc..db7328128c 100644
--- a/src/Module/BaseApi.php
+++ b/src/Module/BaseApi.php
@@ -252,7 +252,7 @@ class BaseApi extends BaseModule
/**
* Set boundaries for the "link" header
- * @param array $boundaries
+ *
* @param int|\DateTime $id
*/
protected static function setBoundaries($id)
diff --git a/src/Module/OpenSearch.php b/src/Module/OpenSearch.php
index 7ff64ecd67..4542d0ede1 100644
--- a/src/Module/OpenSearch.php
+++ b/src/Module/OpenSearch.php
@@ -9,7 +9,8 @@ namespace Friendica\Module;
use DOMDocument;
use DOMElement;
-use Friendica\App;
+use Friendica\App\Arguments;
+use Friendica\App\BaseURL;
use Friendica\BaseModule;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
@@ -30,7 +31,7 @@ class OpenSearch extends BaseModule
/** @var string */
private $basePath;
- public function __construct(BasePath $basePath, IManageConfigValues $config, L10n $l10n, App\baseUrl $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+ public function __construct(BasePath $basePath, IManageConfigValues $config, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
@@ -43,20 +44,23 @@ class OpenSearch extends BaseModule
*/
protected function rawContent(array $request = [])
{
- /** @var DOMDocument $xml */
- XML::fromArray([
- 'OpenSearchDescription' => [
- '@attributes' => [
- 'xmlns' => 'http://a9.com/-/spec/opensearch/1.1/',
+ XML::fromArray(
+ [
+ 'OpenSearchDescription' => [
+ '@attributes' => [
+ 'xmlns' => 'http://a9.com/-/spec/opensearch/1.1/',
+ ],
+ 'ShortName' => $this->baseUrl->getHost(),
+ 'Description' => $this->l10n->t('Search in Friendica %s', $this->baseUrl->getHost()),
+ 'Contact' => 'https://github.com/friendica/friendica/issues',
+ 'InputEncoding' => 'UTF-8',
+ 'OutputEncoding' => 'UTF-8',
+ 'Developer' => 'Friendica Developer Team',
],
- 'ShortName' => $this->baseUrl->getHost(),
- 'Description' => $this->l10n->t('Search in Friendica %s', $this->baseUrl->getHost()),
- 'Contact' => 'https://github.com/friendica/friendica/issues',
- 'InputEncoding' => 'UTF-8',
- 'OutputEncoding' => 'UTF-8',
- 'Developer' => 'Friendica Developer Team',
],
- ], $xml);
+ /** @var DOMDocument $xml */
+ $xml
+ );
/** @var DOMElement $parent */
$parent = $xml->getElementsByTagName('OpenSearchDescription')[0];
diff --git a/src/Module/Security/OpenID.php b/src/Module/Security/OpenID.php
index c8b8f9a95c..f120edf81b 100644
--- a/src/Module/Security/OpenID.php
+++ b/src/Module/Security/OpenID.php
@@ -69,7 +69,9 @@ class OpenID extends BaseModule
// Detect the server URL
$open_id_obj = new LightOpenID(DI::baseUrl()->getHost());
+ /** @phpstan-ignore-next-line $openid->identity is private, but will be set via magic setter */
$open_id_obj->identity = $authId;
+ /** @phpstan-ignore-next-line $openid->identity is private, but will be set via magic setter */
$session->set('openid_server', $open_id_obj->discover($open_id_obj->identity));
if (\Friendica\Module\Register::getPolicy() === \Friendica\Module\Register::CLOSED) {
diff --git a/src/Module/Special/HTTPException.php b/src/Module/Special/HTTPException.php
index 9a02345ce0..fbc1e2b01e 100644
--- a/src/Module/Special/HTTPException.php
+++ b/src/Module/Special/HTTPException.php
@@ -7,12 +7,14 @@
namespace Friendica\Module\Special;
-use Friendica\App;
+use Friendica\App\Arguments;
+use Friendica\App\Request;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Model\UserSession;
use Friendica\Core\System;
use Friendica\Module\Response;
+use Friendica\Network\HTTPException as NetworkHTTPException;
use Psr\Log\LoggerInterface;
/**
@@ -26,7 +28,7 @@ class HTTPException
protected $l10n;
/** @var LoggerInterface */
protected $logger;
- /** @var App\Arguments */
+ /** @var Arguments */
protected $args;
/** @var bool */
protected $isSiteAdmin;
@@ -35,7 +37,7 @@ class HTTPException
/** @var string */
protected $requestId;
- public function __construct(L10n $l10n, LoggerInterface $logger, App\Arguments $args, UserSession $session, App\Request $request, array $server = [])
+ public function __construct(L10n $l10n, LoggerInterface $logger, Arguments $args, UserSession $session, Request $request, array $server = [])
{
$this->logger = $logger;
$this->l10n = $l10n;
@@ -50,11 +52,9 @@ class HTTPException
*
* Fills in the blanks if title or descriptions aren't provided by the exception.
*
- * @param \Friendica\Network\HTTPException $e
- *
* @return array ['$title' => ..., '$description' => ...]
*/
- private function getVars(\Friendica\Network\HTTPException $e)
+ private function getVars(NetworkHTTPException $e)
{
// Explanations are mostly taken from https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
$vars = [
@@ -76,11 +76,9 @@ class HTTPException
/**
* Displays a bare message page with no theming at all.
*
- * @param \Friendica\Network\HTTPException $e
- *
* @throws \Exception
*/
- public function rawContent(\Friendica\Network\HTTPException $e)
+ public function rawContent(NetworkHTTPException $e)
{
$content = '';
@@ -101,8 +99,9 @@ class HTTPException
// We can't use a constructor parameter for this response object because we
// are in an Exception context where we don't want an existing Response.
+ $reason = ($e instanceof NetworkHTTPException) ? $e->getDescription() : $e->getMessage();
$response = new Response();
- $response->setStatus($e->getCode(), $e->getDescription());
+ $response->setStatus($e->getCode(), $reason);
$response->addContent($content);
System::echoResponse($response->generate());
System::exit();
@@ -111,12 +110,10 @@ class HTTPException
/**
* Returns a content string that can be integrated in the current theme.
*
- * @param \Friendica\Network\HTTPException $e
- *
* @return string
* @throws \Exception
*/
- public function content(\Friendica\Network\HTTPException $e): string
+ public function content(NetworkHTTPException $e): string
{
if ($e->getCode() >= 400) {
$this->logger->debug('Exit with error',
diff --git a/src/Navigation/Notifications/Entity/Notify.php b/src/Navigation/Notifications/Entity/Notify.php
index 6f42fae556..3ff478633e 100644
--- a/src/Navigation/Notifications/Entity/Notify.php
+++ b/src/Navigation/Notifications/Entity/Notify.php
@@ -14,24 +14,24 @@ use Friendica\Core\Renderer;
use Psr\Http\Message\UriInterface;
/**
- * @property-read $type
- * @property-read $name
- * @property-read $url
- * @property-read $photo
- * @property-read $date
- * @property-read $msg
- * @property-read $uid
- * @property-read $link
- * @property-read $itemId
- * @property-read $parent
- * @property-read $seen
- * @property-read $verb
- * @property-read $otype
- * @property-read $name_cache
- * @property-read $msg_cache
- * @property-read $uriId
- * @property-read $parentUriId
- * @property-read $id
+ * @property-read string $type
+ * @property-read string $name
+ * @property-read UriInterface $url
+ * @property-read UriInterface $photo
+ * @property-read DateTime $date
+ * @property-read string|null $msg
+ * @property-read int $uid
+ * @property-read UriInterface $link
+ * @property-read int|null $itemId
+ * @property-read int|null $parent
+ * @property-read bool $seen
+ * @property-read string $verb
+ * @property-read string|null $otype
+ * @property-read string|null $name_cache
+ * @property-read string|null $msg_cache
+ * @property-read int|null $uriId
+ * @property-read int|null $parentUriId
+ * @property-read int|null $id
*
* @deprecated since 2022.05 Use \Friendica\Navigation\Notifications\Entity\Notification instead
*/
diff --git a/src/Security/Authentication.php b/src/Security/Authentication.php
index 719873390f..acd3e6d38d 100644
--- a/src/Security/Authentication.php
+++ b/src/Security/Authentication.php
@@ -220,6 +220,7 @@ class Authentication
// Otherwise it's probably an openid.
try {
$openid = new LightOpenID($this->baseUrl->getHost());
+ /** @phpstan-ignore-next-line $openid->identity is private, but will be set via magic setter */
$openid->identity = $openid_url;
$this->session->set('openid', $openid_url);
$this->session->set('remember', $remember);
diff --git a/src/Security/TwoFactor/Model/TrustedBrowser.php b/src/Security/TwoFactor/Model/TrustedBrowser.php
index 64d1a9a975..dccf22d331 100644
--- a/src/Security/TwoFactor/Model/TrustedBrowser.php
+++ b/src/Security/TwoFactor/Model/TrustedBrowser.php
@@ -14,12 +14,12 @@ use Friendica\Util\DateTimeFormat;
* Class TrustedBrowser
*
*
- * @property-read $cookie_hash
- * @property-read $uid
- * @property-read $user_agent
- * @property-read $trusted
- * @property-read $created
- * @property-read $last_used
+ * @property-read string $cookie_hash
+ * @property-read int $uid
+ * @property-read string $user_agent
+ * @property-read bool $trusted
+ * @property-read string $created
+ * @property-read string|null $last_used
* @package Friendica\Model\TwoFactor
*/
class TrustedBrowser extends BaseEntity