]> git.mxchange.org Git - friendica.git/commitdiff
Fix errors in Core namespace
authorArt4 <art4@wlabs.de>
Tue, 3 Dec 2024 20:11:46 +0000 (20:11 +0000)
committerArt4 <art4@wlabs.de>
Tue, 3 Dec 2024 20:11:46 +0000 (20:11 +0000)
15 files changed:
src/Content/Text/HTMLPurifier_URIScheme_cid.php
src/Core/ACL.php
src/Core/Cache/Capability/ICanCache.php
src/Core/Config/Model/ConfigTransaction.php
src/Core/L10n.php
src/Core/Lock/Capability/ICanLock.php
src/Core/Lock/Type/CacheLock.php
src/Core/Logger.php
src/Core/Logger/Type/StreamLogger.php
src/Core/Logger/Util/LoggerSettingsCheck.php
src/Core/Storage/Repository/StorageManager.php
src/Core/System.php
src/Core/Worker.php
src/Core/Worker/Repository/Process.php
src/DI.php

index 8ed03f7c5dd90de86441a677d932759f6fad30e6..05d7e27722dd161e10457fbcdffe54bc9afa095c 100644 (file)
@@ -7,7 +7,10 @@
 
 namespace Friendica\Content\Text;
 
-use \HTMLPurifier_URIScheme;
+use HTMLPurifier_Config;
+use HTMLPurifier_Context;
+use HTMLPurifier_URI;
+use HTMLPurifier_URIScheme;
 
 /**
  * Validates content-id ("cid") as used in multi-part MIME messages, as defined by RFC 2392
index bfd751c08608bcc2c5c7cb1c9752ced45199841d..e0ff7e9e6a9d870eb763bf2be8ce64a50bd5b382 100644 (file)
@@ -7,6 +7,7 @@
 
 namespace Friendica\Core;
 
+use Exception;
 use Friendica\App\Page;
 use Friendica\Database\DBA;
 use Friendica\DI;
index 6360342c5e08d21ae2b4ecfd82238d62e420d9de..0b7dc647c362af92e4edcea4aac77f9ab19a873b 100644 (file)
@@ -18,7 +18,7 @@ interface ICanCache
        /**
         * Lists all cache keys
         *
-        * @param string|null prefix optional a prefix to search
+        * @param string|null $prefix optional a prefix to search
         *
         * @return array Empty if it isn't supported by the cache driver
         */
index f832d93e0c7c2e2b8cdd647f147db0282d1c0388..c3703364a8a155b265480e6643353413b4e71b6a 100644 (file)
@@ -7,7 +7,6 @@
 
 namespace Friendica\Core\Config\Model;
 
-use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\Config\Capability\ISetConfigValuesTransactionally;
 use Friendica\Core\Config\Exception\ConfigPersistenceException;
 use Friendica\Core\Config\ValueObject\Cache;
@@ -17,7 +16,7 @@ use Friendica\Core\Config\ValueObject\Cache;
  */
 class ConfigTransaction implements ISetConfigValuesTransactionally
 {
-       /** @var IManageConfigValues */
+       /** @var DatabaseConfig */
        protected $config;
        /** @var Cache */
        protected $setCache;
index fd70063fb6e14077fba159de8d10c37da09dc448..79d83950a9bc0ed12568b75524e7fad740dfd32a 100644 (file)
@@ -345,10 +345,6 @@ class L10n
 
        /**
         * Provide a fallback which will not collide with a function defined in any language file
-        *
-        * @param int $n
-        *
-        * @return bool
         */
        private function stringPluralSelectDefault(float $n): bool
        {
@@ -426,7 +422,7 @@ class L10n
                $iso639 = new \Matriphe\ISO639\ISO639;
 
                // In ISO 639-2 undetermined languages have got the code "und".
-               // There is no official code for ISO 639-1, but "un" is not assigned to any language.   
+               // There is no official code for ISO 639-1, but "un" is not assigned to any language.
                $languages = [self::UNDETERMINED_LANGUAGE => $this->t('Undetermined')];
 
                foreach ($this->getDetectableLanguages() as $code) {
index ef7dfcae775ac4fa219e99085e7c5be96b020d7f..ae15a751acd3221d79df96364aa05abca6bff489 100644 (file)
@@ -65,7 +65,7 @@ interface ICanLock
        /**
         * Lists all locks
         *
-        * @param string prefix optional a prefix to search
+        * @param string $prefix optional a prefix to search
         *
         * @return string[] Empty if it isn't supported by the cache driver
         *
index 65b07b9bfdda4e9418ba69920938489fc260487a..c3794d06a7e9004f7da3182b2158cc0689c4bfa4 100644 (file)
@@ -16,12 +16,14 @@ use Friendica\Core\Lock\Exception\LockPersistenceException;
 class CacheLock extends AbstractLock
 {
        /**
-        * @var string The static prefix of all locks inside the cache
+        * The static prefix of all locks inside the cache
+        *
+        * @var string
         */
        const CACHE_PREFIX = 'lock:';
 
        /**
-        * @var ICanCache;
+        * @var ICanCacheInMemory
         */
        private $cache;
 
index ee6e3df86f49307048dc566e545c8d8ccebc931d..48fd1293b38dffda7d38d6d180db77d465cb5a86 100644 (file)
@@ -18,20 +18,24 @@ use Psr\Log\LogLevel;
 class Logger
 {
        /**
-        * @var LoggerInterface The default Logger type
+        * LoggerInterface The default Logger type
+        *
+        * @var string
         */
        const TYPE_LOGGER = LoggerInterface::class;
        /**
-        * @var WorkerLogger A specific worker logger type, which can be enabled
+        * WorkerLogger A specific worker logger type, which can be enabled
+        *
+        * @var string
         */
        const TYPE_WORKER = WorkerLogger::class;
        /**
-        * @var LoggerInterface The current logger type
+        * @var string $type LoggerInterface The current logger type
         */
        private static $type = self::TYPE_LOGGER;
 
        /**
-        * @return LoggerInterface
+        * @return LoggerInterface|WorkerLogger
         */
        private static function getInstance()
        {
@@ -52,7 +56,7 @@ class Logger
        public static function enableWorker(string $functionName)
        {
                self::$type = self::TYPE_WORKER;
-               self::getInstance()->setFunctionName($functionName);
+               DI::workerLogger()->setFunctionName($functionName);
        }
 
        /**
index 670181c33a719eb19e63e8670519f1aec7f00b7d..81af7e447468089b43d57e60726f7294fd73070d 100644 (file)
@@ -55,7 +55,7 @@ class StreamLogger extends AbstractLogger
 
        /**
         * {@inheritdoc}
-        * @param string          $level  The minimum loglevel at which this logger will be triggered
+        * @param int $logLevel The minimum loglevel at which this logger will be triggered
         *
         * @throws LoggerException
         */
index a62254c04876d42a973b0594c2a99b517b2d28f8..835ba0e61062ad6e944783d5334d66a5d0f50f25 100644 (file)
@@ -17,7 +17,7 @@ class LoggerSettingsCheck implements ICheckLoggerSettings
 {
        /** @var IManageConfigValues */
        protected $config;
-       /** @var $fileSystem */
+       /** @var FileSystem */
        protected $fileSystem;
        /** @var L10n */
        protected $l10n;
@@ -38,10 +38,8 @@ class LoggerSettingsCheck implements ICheckLoggerSettings
 
                        try {
                                $stream = $this->fileSystem->createStream($file);
-
-                               if (!isset($stream)) {
-                                       throw new LoggerUnusableException('Stream is null.');
-                               }
+                       } catch (LoggerUnusableException $exception) {
+                               throw new LoggerUnusableException('Stream is null.', $exception);
                        } catch (\Throwable $exception) {
                                return $this->l10n->t('The logfile \'%s\' is not usable. No logging possible (error: \'%s\')', $file, $exception->getMessage());
                        }
@@ -57,16 +55,14 @@ class LoggerSettingsCheck implements ICheckLoggerSettings
                if ($this->config->get('system', 'debugging')) {
                        $file = $this->config->get('system', 'dlogfile');
 
-                       if (empty($file)) {
+                       if ($file === null || $file === '') {
                                return null;
                        }
 
                        try {
                                $stream = $this->fileSystem->createStream($file);
-
-                               if (!isset($stream)) {
-                                       throw new LoggerUnusableException('Stream is null.');
-                               }
+                       } catch (LoggerUnusableException $exception) {
+                               throw new LoggerUnusableException('Stream is null.', $exception);
                        } catch (\Throwable $exception) {
                                return $this->l10n->t('The debug logfile \'%s\' is not usable. No logging possible (error: \'%s\')', $file, $exception->getMessage());
                        }
index 3ab2022059bed60b1e2ebcfaf6781137f0d8a252..47b3bcca5546cf9afd36e874fd82e6af703466c9 100644 (file)
@@ -274,24 +274,24 @@ class StorageManager
         */
        public function register(string $class): bool
        {
-               if (is_subclass_of($class, ICanReadFromStorage::class)) {
-                       /** @var ICanReadFromStorage $class */
-                       if ($this->isValidBackend($class::getName(), $this->validBackends)) {
-                               return true;
-                       }
+               if (!is_subclass_of($class, ICanReadFromStorage::class)) {
+                       return false;
+               }
 
-                       $backends   = $this->validBackends;
-                       $backends[] = $class::getName();
+               /** @var class-string<ICanReadFromStorage> $class */
+               if ($this->isValidBackend($class::getName(), $this->validBackends)) {
+                       return true;
+               }
 
-                       if ($this->config->set('storage', 'backends', $backends)) {
-                               $this->validBackends = $backends;
-                               return true;
-                       } else {
-                               return false;
-                       }
-               } else {
-                       return false;
+               $backends   = $this->validBackends;
+               $backends[] = $class::getName();
+
+               if ($this->config->set('storage', 'backends', $backends)) {
+                       $this->validBackends = $backends;
+                       return true;
                }
+
+               return false;
        }
 
        /**
@@ -305,30 +305,31 @@ class StorageManager
         */
        public function unregister(string $class): bool
        {
-               if (is_subclass_of($class, ICanReadFromStorage::class)) {
-                       /** @var ICanReadFromStorage $class */
-                       if ($this->currentBackend::getName() == $class::getName()) {
-                               throw new StorageException(sprintf('Cannot unregister %s, because it\'s currently active.', $class::getName()));
-                       }
-
-                       $key = array_search($class::getName(), $this->validBackends);
-
-                       if ($key !== false) {
-                               $backends = $this->validBackends;
-                               unset($backends[$key]);
-                               $backends = array_values($backends);
-                               if ($this->config->set('storage', 'backends', $backends)) {
-                                       $this->validBackends = $backends;
-                                       return true;
-                               } else {
-                                       return false;
-                               }
-                       } else {
-                               return true;
-                       }
-               } else {
+               if (!is_subclass_of($class, ICanReadFromStorage::class)) {
                        return false;
                }
+
+               /** @var class-string<ICanReadFromStorage> $class */
+               if ($this->currentBackend::getName() == $class::getName()) {
+                       throw new StorageException(sprintf('Cannot unregister %s, because it\'s currently active.', $class::getName()));
+               }
+
+               $key = array_search($class::getName(), $this->validBackends);
+
+               if ($key === false) {
+                       return true;
+               }
+
+               $backends = $this->validBackends;
+               unset($backends[$key]);
+               $backends = array_values($backends);
+
+               if ($this->config->set('storage', 'backends', $backends)) {
+                       $this->validBackends = $backends;
+                       return true;
+               }
+
+               return false;
        }
 
        /**
index 3eabf9695d037c699fd920d33ffd9241dabe27d3..95a411f3d193b15a843ce66f69111b9691fc527e 100644 (file)
@@ -8,10 +8,8 @@
 namespace Friendica\Core;
 
 use Friendica\Content\Text\BBCode;
-use Friendica\Content\Text\HTML;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\DI;
-use Friendica\Model\User;
 use Friendica\Module\Response;
 use Friendica\Network\HTTPException\FoundException;
 use Friendica\Network\HTTPException\InternalServerErrorException;
@@ -325,9 +323,9 @@ class System
        /**
         * Send HTTP status header and exit.
         *
-        * @param integer $val     HTTP status result value
-        * @param string  $message Error message. Optional.
-        * @param string  $content Response body. Optional.
+        * @param integer $httpCode HTTP status result value
+        * @param string  $message  Error message. Optional.
+        * @param string  $content  Response body. Optional.
         * @throws \Exception
         * @deprecated since 2023.09 Use BaseModule->httpError instead
         */
index 5d33dc57fef3966bd6d917e01c1427aaae919103..74ca11f098ae09748542faa7f8bc2ae664d169f9 100644 (file)
@@ -824,7 +824,11 @@ class Worker
                                $max_idletime = DI::config()->get('system', 'worker_max_idletime');
                                $last_check   = DI::cache()->get(self::LAST_CHECK);
                                $last_date    = $last_check ? date('c', $last_check) : '';
-                               if (($max_idletime > 0) && (time() > $last_check + $max_idletime) && !DBA::exists('workerqueue', ["`done` AND `executed` > ?", DateTimeFormat::utc('now - ' . $max_idletime . ' second')])) {
+                               if (
+                                       ($max_idletime > 0)
+                                       && (time() > (int) $last_check + (int) $max_idletime)
+                                       && !DBA::exists('workerqueue', ["`done` AND `executed` > ?", DateTimeFormat::utc('now - ' . $max_idletime . ' second')])
+                               ) {
                                        DI::cache()->set(self::LAST_CHECK, time(), Duration::HOUR);
                                        Logger::info('The last worker execution had been too long ago.', ['last' => $last_check, 'last-check' => $last_date, 'seconds' => $max_idletime, 'load' => $load, 'max_load' => $maxsysload, 'active_worker' => $active, 'max_worker' => $maxqueues]);
                                        return false;
@@ -1211,7 +1215,7 @@ class Worker
        /**
         * Adds tasks to the worker queue
         *
-        * @param (integer|array) priority or parameter array, strings are deprecated and are ignored
+        * @param integer|array $args priority or parameter array, strings are deprecated and are ignored
         *
         * next args are passed as $cmd command line
         * or: Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::DELETION, $drop_id);
index 058257ffebb7ba9eb1e67f8f0a83ffe51633aed3..146854234e6d79b038a7b35fb12640fd5478d67c 100644 (file)
@@ -81,7 +81,7 @@ class Process extends BaseRepository
                                'pid'      => $process->pid,
                                'hostname' => $this->currentHost,
                        ])) {
-                               throw new ProcessPersistenceException(sprintf('The process with PID %s doesn\'t exists.', $process->pi));
+                               throw new ProcessPersistenceException(sprintf('The process with PID %d doesn\'t exists.', $process->pid));
                        }
                } catch (\Exception $exception) {
                        throw new ProcessPersistenceException(sprintf('Cannot delete process with PID %s.', $process->pid), $exception);
index 5604fe9df24c6e3e95b224ae780994ea5b5067cf..8e422a129e1521cb2932eef0bd2282b1a8f6e020 100644 (file)
@@ -312,7 +312,7 @@ abstract class DI
        }
 
        /**
-        * @return LoggerInterface
+        * @return \Friendica\Core\Logger\Type\WorkerLogger
         */
        public static function workerLogger()
        {