forked from GNUsocial/gnu-social
[TOOLS] Fix all errors found by PHPStan level 1
This commit is contained in:
@@ -199,7 +199,7 @@ abstract class Cache
|
||||
->lTrim($key, -$max_count ?? 0, -1)
|
||||
->exec();
|
||||
} else {
|
||||
self::set($key, $value, $pool, $beta);
|
||||
self::set($key, $value, $pool);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ abstract class Cache
|
||||
$count = count($res);
|
||||
$res = array_slice($res, $count - $max_count, $count); // Trim the older values
|
||||
}
|
||||
self::set($key, $res, $pool, $beta);
|
||||
self::set($key, $res, $pool);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -46,6 +46,11 @@ use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Event\ViewEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
/**
|
||||
* @method int int(string $param)
|
||||
* @method bool bool(string $param)
|
||||
* @method string string(string $param)
|
||||
*/
|
||||
class Controller extends AbstractController implements EventSubscriberInterface
|
||||
{
|
||||
private array $vars = [];
|
||||
|
@@ -42,7 +42,10 @@ use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
use Functional as F;
|
||||
|
||||
abstract class DB
|
||||
/**
|
||||
* @mixin EntityManagerInterface
|
||||
*/
|
||||
class DB
|
||||
{
|
||||
private static ?EntityManagerInterface $em;
|
||||
public static function setManager($m): void
|
||||
|
@@ -20,13 +20,25 @@
|
||||
namespace App\Core;
|
||||
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @mixin HttpClientInterface
|
||||
*
|
||||
* @method static ResponseInterface head(string $url, array $options = [])
|
||||
* @method static ResponseInterface get(string $url, array $options = [])
|
||||
* @method static ResponseInterface post(string $url, array $options = [])
|
||||
* @method static ResponseInterface put(string $url, array $options = [])
|
||||
* @method static ResponseInterface delete(string $url, array $options = [])
|
||||
* @method static ResponseInterface connect(string $url, array $options = [])
|
||||
* @method static ResponseInterface options(string $url, array $options = [])
|
||||
* @method static ResponseInterface trace(string $url, array $options = [])
|
||||
* @method static ResponseInterface patch(string $url, array $options = [])
|
||||
*/
|
||||
abstract class HTTPClient
|
||||
{
|
||||
private static ?Httpclientinterface $client;
|
||||
private static ?HttpClientInterface $client;
|
||||
public static function setClient(HttpClientInterface $client)
|
||||
{
|
||||
self::$client = $client;
|
||||
|
@@ -316,7 +316,7 @@ function _m(...$args): string
|
||||
// Get the file where this function was called from, reducing the
|
||||
// memory and performance impact by not returning the arguments,
|
||||
// and only 2 frames (this and previous)
|
||||
$domain = I18n::_mdomain(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[0]['file'], 2);
|
||||
$domain = I18n::_mdomain(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[0]['file']);
|
||||
switch (count($args)) {
|
||||
case 1:
|
||||
// Empty parameters, simple message
|
||||
|
@@ -34,6 +34,9 @@ namespace App\Core;
|
||||
use App\Util\Exception\ServerException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* @mixin LoggerInterface
|
||||
*/
|
||||
abstract class Log
|
||||
{
|
||||
private static ?LoggerInterface $logger;
|
||||
|
@@ -46,13 +46,6 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class ModuleManager
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
if (!defined('CACHE_FILE')) {
|
||||
define('CACHE_FILE', INSTALLDIR . '/var/cache/module_manager.php');
|
||||
}
|
||||
}
|
||||
|
||||
protected static $loader;
|
||||
/** @codeCoverageIgnore */
|
||||
public static function setLoader($l)
|
||||
@@ -128,7 +121,7 @@ class ModuleManager
|
||||
|
||||
$module_manager->preRegisterEvents();
|
||||
|
||||
file_put_contents(CACHE_FILE, "<?php\nreturn " . var_export($module_manager, true) . ';');
|
||||
file_put_contents(MODULE_CACHE_FILE, "<?php\nreturn " . var_export($module_manager, true) . ';');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,7 +143,7 @@ class ModuleManager
|
||||
*/
|
||||
public function loadModules()
|
||||
{
|
||||
if ($_ENV['APP_ENV'] === 'prod' && !file_exists(CACHE_FILE)) {
|
||||
if ($_ENV['APP_ENV'] === 'prod' && !file_exists(MODULE_CACHE_FILE)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
throw new \Exception('The application needs to be compiled before using in production');
|
||||
// @codeCoverageIgnoreEnd
|
||||
@@ -158,7 +151,7 @@ class ModuleManager
|
||||
$rdi = new AppendIterator();
|
||||
$rdi->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(INSTALLDIR . '/components', FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS)));
|
||||
$rdi->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(INSTALLDIR . '/plugins', FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS)));
|
||||
$time = file_exists(CACHE_FILE) ? filemtime(CACHE_FILE) : 0;
|
||||
$time = file_exists(MODULE_CACHE_FILE) ? filemtime(MODULE_CACHE_FILE) : 0;
|
||||
|
||||
if ($_ENV['APP_ENV'] === 'test' || F\some($rdi, function ($e) use ($time) { return $e->getMTime() > $time; })) {
|
||||
Log::info('Rebuilding plugin cache at runtime. This means we can\'t update DB definitions');
|
||||
@@ -166,7 +159,7 @@ class ModuleManager
|
||||
}
|
||||
}
|
||||
|
||||
$obj = require CACHE_FILE;
|
||||
$obj = require MODULE_CACHE_FILE;
|
||||
|
||||
foreach ($obj->modules as $module) {
|
||||
$module->loadConfig();
|
||||
|
@@ -31,8 +31,11 @@
|
||||
namespace App\Core\Router;
|
||||
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\Router as SRouter;
|
||||
use Symfony\Component\Routing\Router as SymfonyRouter;
|
||||
|
||||
/**
|
||||
* @mixin SymfonyRouter
|
||||
*/
|
||||
abstract class Router
|
||||
{
|
||||
/**
|
||||
@@ -58,7 +61,7 @@ abstract class Router
|
||||
*/
|
||||
const NETWORK_PATH = UrlGeneratorInterface::NETWORK_PATH;
|
||||
|
||||
public static ?SRouter $router = null;
|
||||
public static ?SymfonyRouter $router = null;
|
||||
public static ?UrlGeneratorInterface $url_gen = null;
|
||||
|
||||
public static function setServices($rtr, $gen): void
|
||||
|
@@ -31,17 +31,19 @@
|
||||
namespace App\Core;
|
||||
|
||||
use HtmlSanitizer\SanitizerInterface;
|
||||
use Symfony\Component\Security\Core\Security as SSecurity;
|
||||
use Symfony\Component\Security\Core\Security as SymfonySecurity;
|
||||
|
||||
/**
|
||||
* Forwards method calls to either Symfony\Component\Security\Core\Security or
|
||||
* HtmlSanitizer\SanitizerInterface, calling the first existing method, in that order
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @mixin SymfonySecurity
|
||||
* @mixin SanitizerInterface
|
||||
*/
|
||||
abstract class Security
|
||||
{
|
||||
private static ?SSecurity $security;
|
||||
private static ?SymfonySecurity $security;
|
||||
private static ?SanitizerInterface $sanitizer;
|
||||
|
||||
public static function setHelper($sec, $san): void
|
||||
|
Reference in New Issue
Block a user