]> git.mxchange.org Git - friendica.git/commitdiff
Fix errors in Module namespace
authorArt4 <art4@wlabs.de>
Fri, 6 Dec 2024 21:12:29 +0000 (21:12 +0000)
committerArt4 <art4@wlabs.de>
Fri, 6 Dec 2024 21:12:29 +0000 (21:12 +0000)
src/BaseEntity.php
src/Module/Admin/Summary.php
src/Module/BaseApi.php
src/Module/OpenSearch.php
src/Module/Security/OpenID.php
src/Module/Special/HTTPException.php
src/Navigation/Notifications/Entity/Notify.php
src/Security/Authentication.php
src/Security/TwoFactor/Model/TrustedBrowser.php

index 09a2562c8e214dcdcffad8caf8ee9124e80614bd..f50e72e837fffab6f7036b9f548a4a9177783e95 100644 (file)
@@ -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
 {
index 736c8b3e2e1b122e7c010e0c7ea9ec632e8f15e0..f07e9720cbf9e4d64fb9ab6ae208a6916097a38b 100644 (file)
@@ -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 <a href="%s">here</a> for more information.<br />', $table_definition_cache, $suggested_definition_cache, 'https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_table_definition_cache');
                                }
index a2efbfc1cc1a76e9edcec5eaa97d4db7ed0097b9..db7328128c0b5ee387260cc76aa30fdc3dd6dd8c 100644 (file)
@@ -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)
index 7ff64ecd677d87283b07175bcf691db3dad5e9a5..4542d0ede14b2a54a4dbdf04ee20de133bffe177 100644 (file)
@@ -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];
index c8b8f9a95c8ee94fc0afec8862b40a1dffbb9689..f120edf81b9a9aa36b4a342504764b28e3efdfa5 100644 (file)
@@ -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) {
index 9a02345ce0ea70a05f3a31936cfbb9c0218fd179..fbc1e2b01ee0f9718de55b8509f0d11a5a354cfa 100644 (file)
@@ -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',
index 6f42fae556171eba10d40a62b0c215fe9f245f8b..3ff478633e1def873faa293b286b5e5dcd0423fc 100644 (file)
@@ -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
  */
index 719873390f8656518435e6037d3d5dc4820baa33..acd3e6d38dbec21b7e9113511110cdb9f4307369 100644 (file)
@@ -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);
index 64d1a9a97533f8aea7bc1f4b007b059c7eb2929d..dccf22d331e28656ee6ccbad2900069ae8e4a0ff 100644 (file)
@@ -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