diff --git a/doc/Addons.md b/doc/Addons.md index 6b3cd169bf..230e9e93b9 100644 --- a/doc/Addons.md +++ b/doc/Addons.md @@ -566,7 +566,6 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep- Hook::callAll($a->module.'_mod_init', $placeholder); Hook::callAll($a->module.'_mod_init', $placeholder); Hook::callAll($a->module.'_mod_post', $_POST); - Hook::callAll($a->module.'_mod_afterpost', $placeholder); Hook::callAll($a->module.'_mod_content', $arr); Hook::callAll($a->module.'_mod_aftercontent', $arr); Hook::callAll('page_end', DI::page()['content']); diff --git a/doc/de/Addons.md b/doc/de/Addons.md index a20cf4a594..3381ef48f1 100644 --- a/doc/de/Addons.md +++ b/doc/de/Addons.md @@ -202,7 +202,6 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap Hook::callAll($a->module.'_mod_init', $placeholder); Hook::callAll($a->module.'_mod_init', $placeholder); Hook::callAll($a->module.'_mod_post', $_POST); - Hook::callAll($a->module.'_mod_afterpost', $placeholder); Hook::callAll($a->module.'_mod_content', $arr); Hook::callAll($a->module.'_mod_aftercontent', $arr); Hook::callAll('page_end', DI::page()['content']); diff --git a/index.php b/index.php index 4f690ed518..0afd2c7d3e 100644 --- a/index.php +++ b/index.php @@ -41,10 +41,11 @@ $a = \Friendica\DI::app(); \Friendica\DI::mode()->setExecutor(\Friendica\App\Mode::INDEX); $a->runFrontend( - $dice->create(\Friendica\App\Module::class), + $dice->create(\Friendica\App\ModuleController::class), $dice->create(\Friendica\App\Router::class), $dice->create(\Friendica\Core\PConfig\Capability\IManagePersonalConfigValues::class), $dice->create(\Friendica\Security\Authentication::class), $dice->create(\Friendica\App\Page::class), + $dice, $start_time ); diff --git a/mod/display.php b/mod/display.php index b53dd35438..dce2a10ce7 100644 --- a/mod/display.php +++ b/mod/display.php @@ -40,7 +40,7 @@ use Friendica\Protocol\DFRN; function display_init(App $a) { if (ActivityPub::isRequest()) { - Objects::rawContent(['guid' => DI::args()->getArgv()[1] ?? null]); + (new Objects(['guid' => DI::args()->getArgv()[1] ?? null]))->rawContent(); } if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { diff --git a/mod/unfollow.php b/mod/unfollow.php index 92bded2faa..6337211648 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -122,7 +122,7 @@ function unfollow_process(string $url) $owner = User::getOwnerDataById($uid); if (!$owner) { - \Friendica\Module\Security\Logout::init(); + (new \Friendica\Module\Security\Logout())->init(); // NOTREACHED } diff --git a/src/App.php b/src/App.php index 75f5314af5..2dd8f9d1ab 100644 --- a/src/App.php +++ b/src/App.php @@ -21,10 +21,11 @@ namespace Friendica; +use Dice\Dice; use Exception; use Friendica\App\Arguments; use Friendica\App\BaseURL; -use Friendica\App\Module; +use Friendica\App\ModuleController; use Friendica\Core\Config\Factory\Config; use Friendica\Module\Maintenance; use Friendica\Security\Authentication; @@ -566,16 +567,16 @@ class App * * This probably should change to limit the size of this monster method. * - * @param App\Module $module The determined module + * @param App\ModuleController $module The determined module * @param App\Router $router * @param IManagePersonalConfigValues $pconfig - * @param Authentication $auth The Authentication backend of the node - * @param App\Page $page The Friendica page printing container + * @param Authentication $auth The Authentication backend of the node + * @param App\Page $page The Friendica page printing container * * @throws HTTPException\InternalServerErrorException * @throws \ImagickException */ - public function runFrontend(App\Module $module, App\Router $router, IManagePersonalConfigValues $pconfig, Authentication $auth, App\Page $page, float $start_time) + public function runFrontend(App\ModuleController $module, App\Router $router, IManagePersonalConfigValues $pconfig, Authentication $auth, App\Page $page, Dice $dice, float $start_time) { $this->profiler->set($start_time, 'start'); $this->profiler->set(microtime(true), 'classinit'); @@ -702,11 +703,11 @@ class App $page['page_title'] = $moduleName; if (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED)) { - $module = new Module('maintenance', Maintenance::class); + $module = new ModuleController('maintenance', new Maintenance()); } else { // determine the module class and save it to the module instance // @todo there's an implicit dependency due SESSION::start(), so it has to be called here (yet) - $module = $module->determineClass($this->args, $router, $this->config); + $module = $module->determineClass($this->args, $router, $this->config, $dice); } // Let the module run it's internal process (init, get, post, ...) diff --git a/src/App/Mode.php b/src/App/Mode.php index 1087b08a05..4a1213ae12 100644 --- a/src/App/Mode.php +++ b/src/App/Mode.php @@ -139,14 +139,14 @@ class Mode /** * Checks if the site is called via a backend process * - * @param bool $isBackend True, if the call is from a backend script (daemon, worker, ...) - * @param Module $module The pre-loaded module (just name, not class!) - * @param array $server The $_SERVER variable - * @param MobileDetect $mobileDetect The mobile detection library + * @param bool $isBackend True, if the call is from a backend script (daemon, worker, ...) + * @param ModuleController $module The pre-loaded module (just name, not class!) + * @param array $server The $_SERVER variable + * @param MobileDetect $mobileDetect The mobile detection library * * @return Mode returns the determined mode */ - public function determineRunMode(bool $isBackend, Module $module, array $server, MobileDetect $mobileDetect) + public function determineRunMode(bool $isBackend, ModuleController $module, array $server, MobileDetect $mobileDetect) { foreach (self::BACKEND_CONTENT_TYPES as $type) { if (strpos(strtolower($server['HTTP_ACCEPT'] ?? ''), $type) !== false) { diff --git a/src/App/Module.php b/src/App/ModuleController.php similarity index 73% rename from src/App/Module.php rename to src/App/ModuleController.php index 5b7c3d1500..6e3a106b5b 100644 --- a/src/App/Module.php +++ b/src/App/ModuleController.php @@ -21,8 +21,9 @@ namespace Friendica\App; +use Dice\Dice; use Friendica\App; -use Friendica\BaseModule; +use Friendica\Capabilities\ICanHandleRequests; use Friendica\Core; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\LegacyModule; @@ -38,7 +39,7 @@ use Psr\Log\LoggerInterface; /** * Holds the common context of the current, loaded module */ -class Module +class ModuleController { const DEFAULT = 'home'; const DEFAULT_CLASS = Home::class; @@ -77,18 +78,13 @@ class Module /** * @var string The module name */ + private $moduleName; + + /** + * @var ICanHandleRequests The module object + */ private $module; - /** - * @var BaseModule The module class - */ - private $module_class; - - /** - * @var array The module parameters - */ - private $module_parameters; - /** * @var bool true, if the module is a backend module */ @@ -103,40 +99,33 @@ class Module * @return string */ public function getName() + { + return $this->moduleName; + } + + /** + * @return ICanHandleRequests The base module object + */ + public function getModule(): ICanHandleRequests { return $this->module; } - /** - * @return string The base class name - */ - public function getClassName() - { - return $this->module_class; - } - - /** - * @return array The module parameters extracted from the route - */ - public function getParameters() - { - return $this->module_parameters; - } - /** * @return bool True, if the current module is a backend module - * @see Module::BACKEND_MODULES for a list + * @see ModuleController::BACKEND_MODULES for a list */ public function isBackend() { return $this->isBackend; } - public function __construct(string $module = self::DEFAULT, string $moduleClass = self::DEFAULT_CLASS, array $moduleParameters = [], bool $isBackend = false, bool $printNotAllowedAddon = false) + public function __construct(string $moduleName = self::DEFAULT, ICanHandleRequests $module = null, bool $isBackend = false, bool $printNotAllowedAddon = false) { - $this->module = $module; - $this->module_class = $moduleClass; - $this->module_parameters = $moduleParameters; + $defaultClass = static::DEFAULT_CLASS; + + $this->moduleName = $moduleName; + $this->module = $module ?? new $defaultClass(); $this->isBackend = $isBackend; $this->printNotAllowedAddon = $printNotAllowedAddon; } @@ -146,9 +135,9 @@ class Module * * @param Arguments $args The Friendica arguments * - * @return Module The module with the determined module + * @return ModuleController The module with the determined module */ - public function determineModule(Arguments $args) + public function determineName(Arguments $args) { if ($args->getArgc() > 0) { $module = str_replace('.', '_', $args->get(0)); @@ -162,27 +151,28 @@ class Module $module = "login"; } - $isBackend = in_array($module, Module::BACKEND_MODULES);; + $isBackend = in_array($module, ModuleController::BACKEND_MODULES); - return new Module($module, $this->module_class, [], $isBackend, $this->printNotAllowedAddon); + return new ModuleController($module, null, $isBackend, $this->printNotAllowedAddon); } /** * Determine the class of the current module * - * @param Arguments $args The Friendica execution arguments - * @param Router $router The Friendica routing instance + * @param Arguments $args The Friendica execution arguments + * @param Router $router The Friendica routing instance * @param IManageConfigValues $config The Friendica Configuration + * @param Dice $dice The Dependency Injection container * - * @return Module The determined module of this call + * @return ModuleController The determined module of this call * * @throws \Exception */ - public function determineClass(Arguments $args, Router $router, IManageConfigValues $config) + public function determineClass(Arguments $args, Router $router, IManageConfigValues $config, Dice $dice) { $printNotAllowedAddon = false; - $module_class = null; + $module_class = null; $module_parameters = []; /** * ROUTING @@ -191,22 +181,22 @@ class Module * post() and/or content() static methods can be respectively called to produce a data change or an output. **/ try { - $module_class = $router->getModuleClass($args->getCommand()); - $module_parameters = $router->getModuleParameters(); + $module_class = $router->getModuleClass($args->getCommand()); + $module_parameters[] = $router->getModuleParameters(); } catch (MethodNotAllowedException $e) { $module_class = MethodNotAllowed::class; } catch (NotFoundException $e) { // Then we try addon-provided modules that we wrap in the LegacyModule class - if (Core\Addon::isEnabled($this->module) && file_exists("addon/{$this->module}/{$this->module}.php")) { + if (Core\Addon::isEnabled($this->moduleName) && file_exists("addon/{$this->moduleName}/{$this->moduleName}.php")) { //Check if module is an app and if public access to apps is allowed or not $privateapps = $config->get('config', 'private_addons', false); - if ((!local_user()) && Core\Hook::isAddonApp($this->module) && $privateapps) { + if ((!local_user()) && Core\Hook::isAddonApp($this->moduleName) && $privateapps) { $printNotAllowedAddon = true; } else { - include_once "addon/{$this->module}/{$this->module}.php"; - if (function_exists($this->module . '_module')) { - LegacyModule::setModuleFile("addon/{$this->module}/{$this->module}.php"); - $module_class = LegacyModule::class; + include_once "addon/{$this->moduleName}/{$this->moduleName}.php"; + if (function_exists($this->moduleName . '_module')) { + $module_parameters[] = "addon/{$this->moduleName}/{$this->moduleName}.php"; + $module_class = LegacyModule::class; } } } @@ -214,15 +204,18 @@ class Module /* Finally, we look for a 'standard' program module in the 'mod' directory * We emulate a Module class through the LegacyModule class */ - if (!$module_class && file_exists("mod/{$this->module}.php")) { - LegacyModule::setModuleFile("mod/{$this->module}.php"); - $module_class = LegacyModule::class; + if (!$module_class && file_exists("mod/{$this->moduleName}.php")) { + $module_parameters[] = "mod/{$this->moduleName}.php"; + $module_class = LegacyModule::class; } $module_class = $module_class ?: PageNotFound::class; } - return new Module($this->module, $module_class, $module_parameters, $this->isBackend, $printNotAllowedAddon); + /** @var ICanHandleRequests $module */ + $module = $dice->create($module_class, $module_parameters); + + return new ModuleController($this->moduleName, $module, $this->isBackend, $printNotAllowedAddon); } /** @@ -251,7 +244,7 @@ class Module * * Otherwise we are going to emit a 404 not found. */ - if ($this->module_class === PageNotFound::class) { + if ($this->module === PageNotFound::class) { $queryString = $server['QUERY_STRING']; // Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit. if (!empty($queryString) && preg_match('/{[0-9]}/', $queryString) !== 0) { @@ -302,34 +295,31 @@ class Module $profiler->set(microtime(true), 'ready'); $timestamp = microtime(true); - Core\Hook::callAll($this->module . '_mod_init', $placeholder); + Core\Hook::callAll($this->moduleName . '_mod_init', $placeholder); - call_user_func([$this->module_class, 'init'], $this->module_parameters); + $this->module->init(); $profiler->set(microtime(true) - $timestamp, 'init'); if ($server['REQUEST_METHOD'] === Router::DELETE) { - call_user_func([$this->module_class, 'delete'], $this->module_parameters); + $this->module->delete(); } if ($server['REQUEST_METHOD'] === Router::PATCH) { - call_user_func([$this->module_class, 'patch'], $this->module_parameters); + $this->module->patch(); } if ($server['REQUEST_METHOD'] === Router::POST) { - Core\Hook::callAll($this->module . '_mod_post', $post); - call_user_func([$this->module_class, 'post'], $this->module_parameters); + Core\Hook::callAll($this->moduleName . '_mod_post', $post); + $this->module->post(); } if ($server['REQUEST_METHOD'] === Router::PUT) { - call_user_func([$this->module_class, 'put'], $this->module_parameters); + $this->module->put(); } - Core\Hook::callAll($this->module . '_mod_afterpost', $placeholder); - call_user_func([$this->module_class, 'afterpost'], $this->module_parameters); - // "rawContent" is especially meant for technical endpoints. // This endpoint doesn't need any theme initialization or other comparable stuff. - call_user_func([$this->module_class, 'rawContent'], $this->module_parameters); + $this->module->rawContent(); } } diff --git a/src/App/Page.php b/src/App/Page.php index fcb2d18533..f410f6aa28 100644 --- a/src/App/Page.php +++ b/src/App/Page.php @@ -191,14 +191,14 @@ class Page implements ArrayAccess * - head.tpl template * * @param App $app The Friendica App instance - * @param Module $module The loaded Friendica module + * @param ModuleController $module The loaded Friendica module * @param L10n $l10n The l10n language instance * @param IManageConfigValues $config The Friendica configuration * @param IManagePersonalConfigValues $pConfig The Friendica personal configuration (for user) * * @throws HTTPException\InternalServerErrorException */ - private function initHead(App $app, Module $module, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig) + private function initHead(App $app, ModuleController $module, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig) { $interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000); @@ -337,26 +337,23 @@ class Page implements ArrayAccess * - module content * - hooks for content * - * @param Module $module The module - * @param Mode $mode The Friendica execution mode + * @param ModuleController $module The module + * @param Mode $mode The Friendica execution mode * * @throws HTTPException\InternalServerErrorException */ - private function initContent(Module $module, Mode $mode) + private function initContent(ModuleController $module, Mode $mode) { $content = ''; try { - $moduleClass = $module->getClassName(); + $moduleClass = $module->getModule(); $arr = ['content' => $content]; - Hook::callAll($moduleClass . '_mod_content', $arr); + Hook::callAll($moduleClass->getClassName() . '_mod_content', $arr); $content = $arr['content']; - $arr = ['content' => call_user_func([$moduleClass, 'content'], $module->getParameters())]; - Hook::callAll($moduleClass . '_mod_aftercontent', $arr); - $content .= $arr['content']; } catch (HTTPException $e) { - $content = ModuleHTTPException::content($e); + $content = (new ModuleHTTPException())->content($e); } // initialise content region @@ -392,14 +389,14 @@ class Page implements ArrayAccess * @param App $app The Friendica App * @param BaseURL $baseURL The Friendica Base URL * @param Mode $mode The current node mode - * @param Module $module The loaded Friendica module + * @param ModuleController $module The loaded Friendica module * @param L10n $l10n The l10n language class * @param IManageConfigValues $config The Configuration of this node * @param IManagePersonalConfigValues $pconfig The personal/user configuration * * @throws HTTPException\InternalServerErrorException */ - public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig) + public function run(App $app, BaseURL $baseURL, Mode $mode, ModuleController $module, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig) { $moduleName = $module->getName(); diff --git a/src/BaseModule.php b/src/BaseModule.php index ced1e55c39..aaca6c5311 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -21,6 +21,7 @@ namespace Friendica; +use Friendica\Capabilities\ICanHandleRequests; use Friendica\Core\Logger; use Friendica\Model\User; @@ -33,94 +34,73 @@ use Friendica\Model\User; * * @author Hypolite Petovan */ -abstract class BaseModule +abstract class BaseModule implements ICanHandleRequests { + /** @var array */ + protected $parameters = []; + + public function __construct(array $parameters = []) + { + $this->parameters = $parameters; + } + /** - * Initialization method common to both content() and post() - * - * Extend this method if you need to do any shared processing before both - * content() or post() + * {@inheritDoc} */ - public static function init(array $parameters = []) + public function init() { } /** - * Module GET method to display raw content from technical endpoints - * - * Extend this method if the module is supposed to return communication data, - * e.g. from protocol implementations. + * {@inheritDoc} */ - public static function rawContent(array $parameters = []) + public function rawContent() { // echo ''; // exit; } /** - * Module GET method to display any content - * - * Extend this method if the module is supposed to return any display - * through a GET request. It can be an HTML page through templating or a - * XML feed or a JSON output. - * - * @return string + * {@inheritDoc} */ - public static function content(array $parameters = []) + public function content(): string { - $o = ''; - - return $o; + return ''; } /** - * Module DELETE method to process submitted data - * - * Extend this method if the module is supposed to process DELETE requests. - * Doesn't display any content + * {@inheritDoc} */ - public static function delete(array $parameters = []) + public function delete() { } /** - * Module PATCH method to process submitted data - * - * Extend this method if the module is supposed to process PATCH requests. - * Doesn't display any content + * {@inheritDoc} */ - public static function patch(array $parameters = []) + public function patch() { } /** - * Module POST method to process submitted data - * - * Extend this method if the module is supposed to process POST requests. - * Doesn't display any content + * {@inheritDoc} */ - public static function post(array $parameters = []) + public function post() { // DI::baseurl()->redirect('module'); } /** - * Called after post() - * - * Unknown purpose + * {@inheritDoc} */ - public static function afterpost(array $parameters = []) + public function put() { } - /** - * Module PUT method to process submitted data - * - * Extend this method if the module is supposed to process PUT requests. - * Doesn't display any content - */ - public static function put(array $parameters = []) + /** Gets the name of the current class */ + public function getClassName(): string { + return static::class; } /* diff --git a/src/Capabilities/ICanHandleRequests.php b/src/Capabilities/ICanHandleRequests.php new file mode 100644 index 0000000000..1d02be4397 --- /dev/null +++ b/src/Capabilities/ICanHandleRequests.php @@ -0,0 +1,68 @@ +create(App\Module::class); + return self::$dice->create(App\ModuleController::class); } /** diff --git a/src/LegacyModule.php b/src/LegacyModule.php index 224b94debe..53f7676604 100644 --- a/src/LegacyModule.php +++ b/src/LegacyModule.php @@ -35,7 +35,14 @@ class LegacyModule extends BaseModule * * @var string */ - private static $moduleName = ''; + private $moduleName = ''; + + public function __construct(string $file_path = '', array $parameters = []) + { + parent::__construct($parameters); + + $this->setModuleFile($file_path); + } /** * The only method that needs to be called, with the module/addon file name. @@ -43,35 +50,30 @@ class LegacyModule extends BaseModule * @param string $file_path * @throws \Exception */ - public static function setModuleFile($file_path) + private function setModuleFile($file_path) { if (!is_readable($file_path)) { throw new \Exception(DI::l10n()->t('Legacy module file not found: %s', $file_path)); } - self::$moduleName = basename($file_path, '.php'); + $this->moduleName = basename($file_path, '.php'); require_once $file_path; } - public static function init(array $parameters = []) + public function init() { - self::runModuleFunction('init', $parameters); + $this->runModuleFunction('init'); } - public static function content(array $parameters = []) + public function content(): string { - return self::runModuleFunction('content', $parameters); + return $this->runModuleFunction('content'); } - public static function post(array $parameters = []) + public function post() { - self::runModuleFunction('post', $parameters); - } - - public static function afterpost(array $parameters = []) - { - self::runModuleFunction('afterpost', $parameters); + $this->runModuleFunction('post'); } /** @@ -81,15 +83,15 @@ class LegacyModule extends BaseModule * @return string * @throws \Exception */ - private static function runModuleFunction($function_suffix, array $parameters = []) + private function runModuleFunction(string $function_suffix) { - $function_name = static::$moduleName . '_' . $function_suffix; + $function_name = $this->moduleName . '_' . $function_suffix; if (\function_exists($function_name)) { $a = DI::app(); return $function_name($a); } else { - return parent::{$function_suffix}($parameters); + return parent::{$function_suffix}(); } } } diff --git a/src/Module/AccountManagementControlDocument.php b/src/Module/AccountManagementControlDocument.php index ddd22dc3df..8de9e80afb 100644 --- a/src/Module/AccountManagementControlDocument.php +++ b/src/Module/AccountManagementControlDocument.php @@ -30,7 +30,7 @@ use Friendica\BaseModule; */ class AccountManagementControlDocument extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $output = [ 'version' => 1, diff --git a/src/Module/Acctlink.php b/src/Module/Acctlink.php index 898386f3fd..81b2c2391c 100644 --- a/src/Module/Acctlink.php +++ b/src/Module/Acctlink.php @@ -24,22 +24,25 @@ namespace Friendica\Module; use Friendica\BaseModule; use Friendica\Core\System; use Friendica\Model\Contact; +use Friendica\Network\HTTPException\NotFoundException; /** * Redirects to another URL based on the parameter 'addr' */ class Acctlink extends BaseModule { - public static function content(array $parameters = []) + public function rawContent() { $addr = trim($_GET['addr'] ?? ''); - - if ($addr) { - $url = Contact::getByURL($addr)['url'] ?? ''; - if ($url) { - System::externalRedirect($url['url']); - exit(); - } + if (!$addr) { + throw new NotFoundException('Parameter "addr" is missing or empty'); } + + $contact = Contact::getByURL($addr, null, ['url']) ?? ''; + if (!$contact) { + throw new NotFoundException('Contact not found'); + } + + System::externalRedirect($contact['url']); } } diff --git a/src/Module/ActivityPub/Followers.php b/src/Module/ActivityPub/Followers.php index e1f1ccc4c1..d25e4693c9 100644 --- a/src/Module/ActivityPub/Followers.php +++ b/src/Module/ActivityPub/Followers.php @@ -31,14 +31,14 @@ use Friendica\Protocol\ActivityPub; */ class Followers extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { - if (empty($parameters['nickname'])) { + if (empty($this->parameters['nickname'])) { throw new \Friendica\Network\HTTPException\NotFoundException(); } // @TODO: Replace with parameter from router - $owner = User::getOwnerDataByNick($parameters['nickname']); + $owner = User::getOwnerDataByNick($this->parameters['nickname']); if (empty($owner)) { throw new \Friendica\Network\HTTPException\NotFoundException(); } diff --git a/src/Module/ActivityPub/Following.php b/src/Module/ActivityPub/Following.php index e9cb10be1f..3b45cf09a6 100644 --- a/src/Module/ActivityPub/Following.php +++ b/src/Module/ActivityPub/Following.php @@ -31,13 +31,13 @@ use Friendica\Protocol\ActivityPub; */ class Following extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { - if (empty($parameters['nickname'])) { + if (empty($this->parameters['nickname'])) { throw new \Friendica\Network\HTTPException\NotFoundException(); } - $owner = User::getOwnerDataByNick($parameters['nickname']); + $owner = User::getOwnerDataByNick($this->parameters['nickname']); if (empty($owner)) { throw new \Friendica\Network\HTTPException\NotFoundException(); } diff --git a/src/Module/ActivityPub/Inbox.php b/src/Module/ActivityPub/Inbox.php index 2ef12a83d8..149e511069 100644 --- a/src/Module/ActivityPub/Inbox.php +++ b/src/Module/ActivityPub/Inbox.php @@ -35,7 +35,7 @@ use Friendica\Util\Network; */ class Inbox extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $postdata = Network::postdata(); @@ -50,12 +50,12 @@ class Inbox extends BaseModule $filename = 'failed-activitypub'; } $tempfile = tempnam(System::getTempPath(), $filename); - file_put_contents($tempfile, json_encode(['parameters' => $parameters, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); + file_put_contents($tempfile, json_encode(['parameters' => $this->parameters, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); Logger::notice('Incoming message stored', ['file' => $tempfile]); } - if (!empty($parameters['nickname'])) { - $user = DBA::selectFirst('user', ['uid'], ['nickname' => $parameters['nickname']]); + if (!empty($this->parameters['nickname'])) { + $user = DBA::selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname']]); if (!DBA::isResult($user)) { throw new \Friendica\Network\HTTPException\NotFoundException(); } diff --git a/src/Module/ActivityPub/Objects.php b/src/Module/ActivityPub/Objects.php index 232c80e5bd..5798c5685d 100644 --- a/src/Module/ActivityPub/Objects.php +++ b/src/Module/ActivityPub/Objects.php @@ -41,9 +41,9 @@ use Friendica\Util\Strings; */ class Objects extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { - if (empty($parameters['guid'])) { + if (empty($this->parameters['guid'])) { throw new HTTPException\BadRequestException(); } @@ -51,10 +51,10 @@ class Objects extends BaseModule DI::baseUrl()->redirect(str_replace('objects/', 'display/', DI::args()->getQueryString())); } - $itemuri = DBA::selectFirst('item-uri', ['id'], ['guid' => $parameters['guid']]); + $itemuri = DBA::selectFirst('item-uri', ['id'], ['guid' => $this->parameters['guid']]); if (DBA::isResult($itemuri)) { - Logger::info('Provided GUID found.', ['guid' => $parameters['guid'], 'uri-id' => $itemuri['id']]); + Logger::info('Provided GUID found.', ['guid' => $this->parameters['guid'], 'uri-id' => $itemuri['id']]); } else { // The item URI does not always contain the GUID. This means that we have to search the URL instead $url = DI::baseUrl()->get() . '/' . DI::args()->getQueryString(); @@ -104,11 +104,11 @@ class Objects extends BaseModule throw new HTTPException\NotFoundException(); } - $etag = md5($parameters['guid'] . '-' . $item['changed']); + $etag = md5($this->parameters['guid'] . '-' . $item['changed']); $last_modified = $item['changed']; Network::checkEtagModified($etag, $last_modified); - if (empty($parameters['activity']) && ($item['gravity'] != GRAVITY_ACTIVITY)) { + if (empty($this->parameters['activity']) && ($item['gravity'] != GRAVITY_ACTIVITY)) { $activity = ActivityPub\Transmitter::createActivityFromItem($item['id'], true); if (empty($activity['type'])) { throw new HTTPException\NotFoundException(); @@ -123,16 +123,16 @@ class Objects extends BaseModule $data = ['@context' => ActivityPub::CONTEXT]; $data = array_merge($data, $activity['object']); - } elseif (empty($parameters['activity']) || in_array($parameters['activity'], + } elseif (empty($this->parameters['activity']) || in_array($this->parameters['activity'], ['Create', 'Announce', 'Update', 'Like', 'Dislike', 'Accept', 'Reject', 'TentativeAccept', 'Follow', 'Add'])) { $data = ActivityPub\Transmitter::createActivityFromItem($item['id']); if (empty($data)) { throw new HTTPException\NotFoundException(); } - if (!empty($parameters['activity']) && ($parameters['activity'] != 'Create')) { - $data['type'] = $parameters['activity']; - $data['id'] = str_replace('/Create', '/' . $parameters['activity'], $data['id']); + if (!empty($this->parameters['activity']) && ($this->parameters['activity'] != 'Create')) { + $data['type'] = $this->parameters['activity']; + $data['id'] = str_replace('/Create', '/' . $this->parameters['activity'], $data['id']); } } else { throw new HTTPException\NotFoundException(); diff --git a/src/Module/ActivityPub/Outbox.php b/src/Module/ActivityPub/Outbox.php index fe838960d5..c459a55e30 100644 --- a/src/Module/ActivityPub/Outbox.php +++ b/src/Module/ActivityPub/Outbox.php @@ -31,13 +31,13 @@ use Friendica\Util\HTTPSignature; */ class Outbox extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { - if (empty($parameters['nickname'])) { + if (empty($this->parameters['nickname'])) { throw new \Friendica\Network\HTTPException\NotFoundException(); } - $owner = User::getOwnerDataByNick($parameters['nickname']); + $owner = User::getOwnerDataByNick($this->parameters['nickname']); if (empty($owner)) { throw new \Friendica\Network\HTTPException\NotFoundException(); } diff --git a/src/Module/Admin/Addons/Details.php b/src/Module/Admin/Addons/Details.php index 79660dee38..bab52fb0de 100644 --- a/src/Module/Admin/Addons/Details.php +++ b/src/Module/Admin/Addons/Details.php @@ -30,11 +30,11 @@ use Friendica\Util\Strings; class Details extends BaseAdmin { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); - $addon = Strings::sanitizeFilePathItem($parameters['addon']); + $addon = Strings::sanitizeFilePathItem($this->parameters['addon']); $redirect = 'admin/addons/' . $addon; @@ -52,15 +52,15 @@ class Details extends BaseAdmin DI::baseUrl()->redirect($redirect); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $a = DI::app(); $addons_admin = Addon::getAdminList(); - $addon = Strings::sanitizeFilePathItem($parameters['addon']); + $addon = Strings::sanitizeFilePathItem($this->parameters['addon']); if (!is_file("addon/$addon/$addon.php")) { notice(DI::l10n()->t('Addon not found.')); Addon::uninstall($addon); diff --git a/src/Module/Admin/Addons/Index.php b/src/Module/Admin/Addons/Index.php index 56d570b28e..6330ee2cfa 100644 --- a/src/Module/Admin/Addons/Index.php +++ b/src/Module/Admin/Addons/Index.php @@ -28,9 +28,9 @@ use Friendica\Module\BaseAdmin; class Index extends BaseAdmin { - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); // reload active themes if (!empty($_GET['action'])) { diff --git a/src/Module/Admin/Blocklist/Contact.php b/src/Module/Admin/Blocklist/Contact.php index bd30e2f8dd..a0a5c282f8 100644 --- a/src/Module/Admin/Blocklist/Contact.php +++ b/src/Module/Admin/Blocklist/Contact.php @@ -32,7 +32,7 @@ use Friendica\Util\Network; class Contact extends BaseAdmin { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -76,9 +76,9 @@ class Contact extends BaseAdmin DI::baseUrl()->redirect('admin/blocklist/contact'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $condition = ['uid' => 0, 'blocked' => true]; diff --git a/src/Module/Admin/Blocklist/Server/Add.php b/src/Module/Admin/Blocklist/Server/Add.php index 03f1026401..47c9016d90 100644 --- a/src/Module/Admin/Blocklist/Server/Add.php +++ b/src/Module/Admin/Blocklist/Server/Add.php @@ -32,7 +32,7 @@ use GuzzleHttp\Psr7\Uri; class Add extends BaseAdmin { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -66,9 +66,9 @@ class Add extends BaseAdmin DI::baseUrl()->redirect('admin/blocklist/server'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $gservers = []; diff --git a/src/Module/Admin/Blocklist/Server/Index.php b/src/Module/Admin/Blocklist/Server/Index.php index 7dd59678a4..ebd39d36a8 100644 --- a/src/Module/Admin/Blocklist/Server/Index.php +++ b/src/Module/Admin/Blocklist/Server/Index.php @@ -27,7 +27,7 @@ use Friendica\Module\BaseAdmin; class Index extends BaseAdmin { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -56,9 +56,9 @@ class Index extends BaseAdmin DI::baseUrl()->redirect('admin/blocklist/server'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $blocklist = DI::config()->get('system', 'blocklist'); $blocklistform = []; diff --git a/src/Module/Admin/DBSync.php b/src/Module/Admin/DBSync.php index 9449e3be70..6ef8d804ae 100644 --- a/src/Module/Admin/DBSync.php +++ b/src/Module/Admin/DBSync.php @@ -30,14 +30,14 @@ use Friendica\Module\BaseAdmin; class DBSync extends BaseAdmin { - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $a = DI::app(); - $action = $parameters['action'] ?? ''; - $update = $parameters['update'] ?? 0; + $action = $this->parameters['action'] ?? ''; + $update = $this->parameters['update'] ?? 0; switch ($action) { case 'mark': diff --git a/src/Module/Admin/Features.php b/src/Module/Admin/Features.php index d3af3ebc02..d2c8e2d83a 100644 --- a/src/Module/Admin/Features.php +++ b/src/Module/Admin/Features.php @@ -28,7 +28,7 @@ use Friendica\Module\BaseAdmin; class Features extends BaseAdmin { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -60,9 +60,9 @@ class Features extends BaseAdmin DI::baseUrl()->redirect('admin/features'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $features = []; diff --git a/src/Module/Admin/Federation.php b/src/Module/Admin/Federation.php index 4be2319759..65d0453d93 100644 --- a/src/Module/Admin/Federation.php +++ b/src/Module/Admin/Federation.php @@ -28,9 +28,9 @@ use Friendica\Module\BaseAdmin; class Federation extends BaseAdmin { - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); // get counts on active federation systems this node is knowing // We list the more common systems by name. The rest is counted as "other" diff --git a/src/Module/Admin/Item/Delete.php b/src/Module/Admin/Item/Delete.php index 7afc3b0903..91bb71932e 100644 --- a/src/Module/Admin/Item/Delete.php +++ b/src/Module/Admin/Item/Delete.php @@ -29,7 +29,7 @@ use Friendica\Util\Strings; class Delete extends BaseAdmin { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -55,9 +55,9 @@ class Delete extends BaseAdmin DI::baseUrl()->redirect('admin/item/delete'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $t = Renderer::getMarkupTemplate('admin/item/delete.tpl'); diff --git a/src/Module/Admin/Item/Source.php b/src/Module/Admin/Item/Source.php index 61e598a68f..c1edabf608 100644 --- a/src/Module/Admin/Item/Source.php +++ b/src/Module/Admin/Item/Source.php @@ -29,11 +29,11 @@ use Friendica\Module\BaseAdmin; class Source extends BaseAdmin { - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); - $guid = basename($_REQUEST['guid'] ?? $parameters['guid'] ?? ''); + $guid = basename($_REQUEST['guid'] ?? $this->parameters['guid'] ?? ''); $source = ''; $item_uri = ''; diff --git a/src/Module/Admin/Logs/Settings.php b/src/Module/Admin/Logs/Settings.php index b0fcaebc33..aaf603f825 100644 --- a/src/Module/Admin/Logs/Settings.php +++ b/src/Module/Admin/Logs/Settings.php @@ -29,7 +29,7 @@ use Psr\Log\LogLevel; class Settings extends BaseAdmin { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -56,9 +56,9 @@ class Settings extends BaseAdmin DI::baseUrl()->redirect('admin/logs'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $log_choices = [ LogLevel::ERROR => 'Error', diff --git a/src/Module/Admin/Logs/View.php b/src/Module/Admin/Logs/View.php index e0e12760bc..3e312204b0 100644 --- a/src/Module/Admin/Logs/View.php +++ b/src/Module/Admin/Logs/View.php @@ -31,9 +31,9 @@ class View extends BaseAdmin { const LIMIT = 500; - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $t = Renderer::getMarkupTemplate('admin/logs/view.tpl'); DI::page()->registerFooterScript(Theme::getPathForFile('js/module/admin/logs/view.js')); @@ -75,7 +75,7 @@ class View extends BaseAdmin ->withLimit(self::LIMIT) ->withFilters($filters) ->withSearch($search); - } catch (Exception $e) { + } catch (\Exception $e) { $error = DI::l10n()->t('Couldn\'t open %1$s log file.
Check to see if file %1$s is readable.', $f); } } diff --git a/src/Module/Admin/PhpInfo.php b/src/Module/Admin/PhpInfo.php index 74cbc3d901..e6cad66c76 100644 --- a/src/Module/Admin/PhpInfo.php +++ b/src/Module/Admin/PhpInfo.php @@ -25,7 +25,7 @@ use Friendica\Module\BaseAdmin; class PhpInfo extends BaseAdmin { - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAdminAccess(); diff --git a/src/Module/Admin/Queue.php b/src/Module/Admin/Queue.php index f0883b361f..f43dfdc095 100644 --- a/src/Module/Admin/Queue.php +++ b/src/Module/Admin/Queue.php @@ -38,11 +38,11 @@ use Friendica\Util\DateTimeFormat; */ class Queue extends BaseAdmin { - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); - $status = $parameters['status'] ?? ''; + $status = $this->parameters['status'] ?? ''; // get jobs from the workerqueue table if ($status == 'deferred') { diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index 0edc713ae6..27623880ae 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -43,7 +43,7 @@ require_once __DIR__ . '/../../../boot.php'; class Site extends BaseAdmin { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -384,9 +384,9 @@ class Site extends BaseAdmin DI::baseUrl()->redirect('admin/site' . $active_panel); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); /* Installed langs */ $lang_choices = DI::l10n()->getAvailableLanguages(); diff --git a/src/Module/Admin/Storage.php b/src/Module/Admin/Storage.php index 51e70d841e..68d7d065d0 100644 --- a/src/Module/Admin/Storage.php +++ b/src/Module/Admin/Storage.php @@ -31,13 +31,13 @@ use Friendica\Util\Strings; class Storage extends BaseAdmin { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); self::checkFormSecurityTokenRedirectOnError('/admin/storage', 'admin_storage'); - $storagebackend = trim($parameters['name'] ?? ''); + $storagebackend = trim($this->parameters['name'] ?? ''); try { /** @var ICanConfigureStorage|false $newStorageConfig */ @@ -91,9 +91,9 @@ class Storage extends BaseAdmin DI::baseUrl()->redirect('admin/storage'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $current_storage_backend = DI::storage(); $available_storage_forms = []; diff --git a/src/Module/Admin/Summary.php b/src/Module/Admin/Summary.php index ca244260f6..5b2efca1e0 100644 --- a/src/Module/Admin/Summary.php +++ b/src/Module/Admin/Summary.php @@ -37,9 +37,9 @@ use Friendica\Util\DateTimeFormat; class Summary extends BaseAdmin { - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $a = DI::app(); diff --git a/src/Module/Admin/Themes/Details.php b/src/Module/Admin/Themes/Details.php index b8ecfe1ce6..b7161d1b96 100644 --- a/src/Module/Admin/Themes/Details.php +++ b/src/Module/Admin/Themes/Details.php @@ -30,11 +30,11 @@ use Friendica\Util\Strings; class Details extends BaseAdmin { - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); - $theme = Strings::sanitizeFilePathItem($parameters['theme']); + $theme = Strings::sanitizeFilePathItem($this->parameters['theme']); if (!is_dir("view/theme/$theme")) { notice(DI::l10n()->t("Item not found.")); return ''; diff --git a/src/Module/Admin/Themes/Embed.php b/src/Module/Admin/Themes/Embed.php index dabc9209e6..bf4e5b5560 100644 --- a/src/Module/Admin/Themes/Embed.php +++ b/src/Module/Admin/Themes/Embed.php @@ -28,19 +28,19 @@ use Friendica\Util\Strings; class Embed extends BaseAdmin { - public static function init(array $parameters = []) + public function init() { - $theme = Strings::sanitizeFilePathItem($parameters['theme']); + $theme = Strings::sanitizeFilePathItem($this->parameters['theme']); if (is_file("view/theme/$theme/config.php")) { DI::app()->setCurrentTheme($theme); } } - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); - $theme = Strings::sanitizeFilePathItem($parameters['theme']); + $theme = Strings::sanitizeFilePathItem($this->parameters['theme']); if (is_file("view/theme/$theme/config.php")) { require_once "view/theme/$theme/config.php"; if (function_exists('theme_admin_post')) { @@ -56,11 +56,11 @@ class Embed extends BaseAdmin DI::baseUrl()->redirect('admin/themes/' . $theme . '/embed?mode=minimal'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); - $theme = Strings::sanitizeFilePathItem($parameters['theme']); + $theme = Strings::sanitizeFilePathItem($this->parameters['theme']); if (!is_dir("view/theme/$theme")) { notice(DI::l10n()->t('Unknown theme.')); return ''; diff --git a/src/Module/Admin/Themes/Index.php b/src/Module/Admin/Themes/Index.php index d9cb326b44..ad4dfef94e 100644 --- a/src/Module/Admin/Themes/Index.php +++ b/src/Module/Admin/Themes/Index.php @@ -29,9 +29,9 @@ use Friendica\Util\Strings; class Index extends BaseAdmin { - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $allowed_themes = Theme::getAllowedList(); diff --git a/src/Module/Admin/Tos.php b/src/Module/Admin/Tos.php index 282e5daf1d..17c8372b00 100644 --- a/src/Module/Admin/Tos.php +++ b/src/Module/Admin/Tos.php @@ -27,7 +27,7 @@ use Friendica\Module\BaseAdmin; class Tos extends BaseAdmin { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -48,11 +48,11 @@ class Tos extends BaseAdmin DI::baseUrl()->redirect('admin/tos'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); - $tos = new \Friendica\Module\Tos(); + $tos = new \Friendica\Module\Tos($this->parameters); $t = Renderer::getMarkupTemplate('admin/tos.tpl'); return Renderer::replaceMacros($t, [ '$title' => DI::l10n()->t('Administration'), diff --git a/src/Module/Admin/Users/Active.php b/src/Module/Admin/Users/Active.php index 7eac47d116..6bcd22be4e 100644 --- a/src/Module/Admin/Users/Active.php +++ b/src/Module/Admin/Users/Active.php @@ -30,7 +30,7 @@ use Friendica\Module\Admin\BaseUsers; class Active extends BaseUsers { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -60,12 +60,12 @@ class Active extends BaseUsers DI::baseUrl()->redirect(DI::args()->getQueryString()); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); - $action = $parameters['action'] ?? ''; - $uid = $parameters['uid'] ?? 0; + $action = $this->parameters['action'] ?? ''; + $uid = $this->parameters['uid'] ?? 0; if ($uid) { $user = User::getById($uid, ['username', 'blocked']); diff --git a/src/Module/Admin/Users/Blocked.php b/src/Module/Admin/Users/Blocked.php index 35e7c25bfa..a24c95df0b 100644 --- a/src/Module/Admin/Users/Blocked.php +++ b/src/Module/Admin/Users/Blocked.php @@ -31,7 +31,7 @@ use Friendica\Util\Temporal; class Blocked extends BaseUsers { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -61,12 +61,12 @@ class Blocked extends BaseUsers DI::baseUrl()->redirect('admin/users/blocked'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); - $action = $parameters['action'] ?? ''; - $uid = $parameters['uid'] ?? 0; + $action = $this->parameters['action'] ?? ''; + $uid = $this->parameters['uid'] ?? 0; if ($uid) { $user = User::getById($uid, ['username', 'blocked']); diff --git a/src/Module/Admin/Users/Create.php b/src/Module/Admin/Users/Create.php index 078547f469..71ab5b4cb9 100644 --- a/src/Module/Admin/Users/Create.php +++ b/src/Module/Admin/Users/Create.php @@ -28,7 +28,7 @@ use Friendica\Module\Admin\BaseUsers; class Create extends BaseUsers { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -51,9 +51,9 @@ class Create extends BaseUsers DI::baseUrl()->redirect('admin/users/create'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $t = Renderer::getMarkupTemplate('admin/users/create.tpl'); return self::getTabsHTML('all') . Renderer::replaceMacros($t, [ diff --git a/src/Module/Admin/Users/Deleted.php b/src/Module/Admin/Users/Deleted.php index 2ebaec8b7f..6357b23963 100644 --- a/src/Module/Admin/Users/Deleted.php +++ b/src/Module/Admin/Users/Deleted.php @@ -33,7 +33,7 @@ use Friendica\Util\Temporal; class Deleted extends BaseUsers { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -44,9 +44,9 @@ class Deleted extends BaseUsers DI::baseUrl()->redirect('admin/users/deleted'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 100); diff --git a/src/Module/Admin/Users/Index.php b/src/Module/Admin/Users/Index.php index d391feb447..eb7b57c25c 100644 --- a/src/Module/Admin/Users/Index.php +++ b/src/Module/Admin/Users/Index.php @@ -30,7 +30,7 @@ use Friendica\Module\Admin\BaseUsers; class Index extends BaseUsers { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -67,12 +67,12 @@ class Index extends BaseUsers DI::baseUrl()->redirect(DI::args()->getQueryString()); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); - $action = $parameters['action'] ?? ''; - $uid = $parameters['uid'] ?? 0; + $action = $this->parameters['action'] ?? ''; + $uid = $this->parameters['uid'] ?? 0; if ($uid) { $user = User::getById($uid, ['username', 'blocked']); diff --git a/src/Module/Admin/Users/Pending.php b/src/Module/Admin/Users/Pending.php index 14381682fd..801c159742 100644 --- a/src/Module/Admin/Users/Pending.php +++ b/src/Module/Admin/Users/Pending.php @@ -33,7 +33,7 @@ use Friendica\Util\Temporal; class Pending extends BaseUsers { - public static function post(array $parameters = []) + public function post() { self::checkAdminAccess(); @@ -58,12 +58,12 @@ class Pending extends BaseUsers DI::baseUrl()->redirect('admin/users/pending'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); - $action = $parameters['action'] ?? ''; - $uid = $parameters['uid'] ?? 0; + $action = $this->parameters['action'] ?? ''; + $uid = $this->parameters['uid'] ?? 0; if ($uid) { $user = User::getById($uid, ['username', 'blocked']); diff --git a/src/Module/Api/Friendica/Activity.php b/src/Module/Api/Friendica/Activity.php index 00228c0ccc..1b2b95d06a 100644 --- a/src/Module/Api/Friendica/Activity.php +++ b/src/Module/Api/Friendica/Activity.php @@ -40,7 +40,7 @@ use Friendica\Module\BaseApi; */ class Activity extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -49,17 +49,17 @@ class Activity extends BaseApi 'id' => 0, // Id of the post ]); - $res = Item::performActivity($request['id'], $parameters['verb'], $uid); + $res = Item::performActivity($request['id'], $this->parameters['verb'], $uid); if ($res) { - if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) { + if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) { $ok = 'true'; } else { $ok = 'ok'; } - DI::apiResponse()->exit('ok', ['ok' => $ok], $parameters['extension'] ?? null); + DI::apiResponse()->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null); } else { - DI::apiResponse()->error(500, 'Error adding activity', '', $parameters['extension'] ?? null); + DI::apiResponse()->error(500, 'Error adding activity', '', $this->parameters['extension'] ?? null); } } } diff --git a/src/Module/Api/Friendica/DirectMessages/Setseen.php b/src/Module/Api/Friendica/DirectMessages/Setseen.php index e55ad74b96..600d5fe171 100644 --- a/src/Module/Api/Friendica/DirectMessages/Setseen.php +++ b/src/Module/Api/Friendica/DirectMessages/Setseen.php @@ -30,7 +30,7 @@ use Friendica\Module\BaseApi; */ class Setseen extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -42,13 +42,13 @@ class Setseen extends BaseApi // return error if id is zero if (empty($request['id'])) { $answer = ['result' => 'error', 'message' => 'message id not specified']; - DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $parameters['extension'] ?? null); + DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null); } // error message if specified id is not in database if (!DBA::exists('mail', ['id' => $request['id'], 'uid' => $uid])) { $answer = ['result' => 'error', 'message' => 'message id not in database']; - DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $parameters['extension'] ?? null); + DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null); } // update seen indicator @@ -58,6 +58,6 @@ class Setseen extends BaseApi $answer = ['result' => 'error', 'message' => 'unknown error']; } - DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $parameters['extension'] ?? null); + DI::apiResponse()->exit('direct_messages_setseen', ['$result' => $answer], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Friendica/Events/Index.php b/src/Module/Api/Friendica/Events/Index.php index 31c55069da..b6cfdd0982 100644 --- a/src/Module/Api/Friendica/Events/Index.php +++ b/src/Module/Api/Friendica/Events/Index.php @@ -33,7 +33,7 @@ use Friendica\Module\BaseApi; */ class Index extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); @@ -70,6 +70,6 @@ class Index extends BaseApi ]; } - DI::apiResponse()->exit('events', ['events' => $items], $parameters['extension'] ?? null); + DI::apiResponse()->exit('events', ['events' => $items], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Friendica/Group/Delete.php b/src/Module/Api/Friendica/Group/Delete.php index 7d27222f40..d78ea658e2 100644 --- a/src/Module/Api/Friendica/Group/Delete.php +++ b/src/Module/Api/Friendica/Group/Delete.php @@ -22,6 +22,7 @@ namespace Friendica\Module\Api\Friendica\Group; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Group; use Friendica\Module\BaseApi; use Friendica\Network\HTTPException\BadRequestException; @@ -31,7 +32,7 @@ use Friendica\Network\HTTPException\BadRequestException; */ class Delete extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -69,7 +70,7 @@ class Delete extends BaseApi if ($ret) { // return success $success = ['success' => $ret, 'gid' => $request['gid'], 'name' => $request['name'], 'status' => 'deleted', 'wrong users' => []]; - self::exit('group_delete', ['$result' => $success], $parameters['extension'] ?? null); + DI::apiResponse()->exit('group_delete', ['$result' => $success], $parameters['extension'] ?? null); } else { throw new BadRequestException('other API error'); } diff --git a/src/Module/Api/Friendica/Index.php b/src/Module/Api/Friendica/Index.php index 8891d218a9..dbe45f545f 100644 --- a/src/Module/Api/Friendica/Index.php +++ b/src/Module/Api/Friendica/Index.php @@ -31,17 +31,17 @@ use Friendica\Module\BaseApi; */ class Index extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); } - public static function delete(array $parameters = []) + public function delete() { self::checkAllowedScope(self::SCOPE_WRITE); } - public static function rawContent(array $parameters = []) + public function rawContent() { echo api_call(DI::app()); exit(); diff --git a/src/Module/Api/Friendica/Notification.php b/src/Module/Api/Friendica/Notification.php index 2a50bde7b5..9d316d94da 100644 --- a/src/Module/Api/Friendica/Notification.php +++ b/src/Module/Api/Friendica/Notification.php @@ -31,7 +31,7 @@ use Friendica\Object\Api\Friendica\Notification as ApiNotification; */ class Notification extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); @@ -43,7 +43,7 @@ class Notification extends BaseApi $notifications[] = new ApiNotification($Notify); } - if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) { + if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) { $xmlnotes = []; foreach ($notifications as $notification) { $xmlnotes[] = ['@attributes' => $notification->toArray()]; @@ -56,6 +56,6 @@ class Notification extends BaseApi $result = false; } - DI::apiResponse()->exit('notes', ['note' => $result], $parameters['extension'] ?? null); + DI::apiResponse()->exit('notes', ['note' => $result], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Friendica/Photo/Delete.php b/src/Module/Api/Friendica/Photo/Delete.php index cf287d3d33..ab749b4e87 100644 --- a/src/Module/Api/Friendica/Photo/Delete.php +++ b/src/Module/Api/Friendica/Photo/Delete.php @@ -33,7 +33,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException; */ class Delete extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -64,7 +64,7 @@ class Delete extends BaseApi Item::deleteForUser($condition, $uid); $result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.']; - DI::apiResponse()->exit('photo_delete', ['$result' => $result], $parameters['extension'] ?? null); + DI::apiResponse()->exit('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null); } else { throw new InternalServerErrorException("unknown error on deleting photo from database table"); } diff --git a/src/Module/Api/Friendica/Photoalbum/Delete.php b/src/Module/Api/Friendica/Photoalbum/Delete.php index dd18365b46..0a403270d1 100644 --- a/src/Module/Api/Friendica/Photoalbum/Delete.php +++ b/src/Module/Api/Friendica/Photoalbum/Delete.php @@ -34,7 +34,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException; */ class Delete extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -67,7 +67,7 @@ class Delete extends BaseApi // return success of deletion or error message if ($result) { $answer = ['result' => 'deleted', 'message' => 'album `' . $request['album'] . '` with all containing photos has been deleted.']; - DI::apiResponse()->exit('photoalbum_delete', ['$result' => $answer], $parameters['extension'] ?? null); + DI::apiResponse()->exit('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null); } else { throw new InternalServerErrorException("unknown error - deleting from database failed"); } diff --git a/src/Module/Api/Friendica/Photoalbum/Update.php b/src/Module/Api/Friendica/Photoalbum/Update.php index 369d33e825..9fc89dbf6d 100644 --- a/src/Module/Api/Friendica/Photoalbum/Update.php +++ b/src/Module/Api/Friendica/Photoalbum/Update.php @@ -32,7 +32,7 @@ use Friendica\Network\HTTPException\InternalServerErrorException; */ class Update extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -59,7 +59,7 @@ class Update extends BaseApi // return success of updating or error message if ($result) { $answer = ['result' => 'updated', 'message' => 'album `' . $request['album'] . '` with all containing photos has been renamed to `' . $request['album_new'] . '`.']; - DI::apiResponse()->exit('photoalbum_update', ['$result' => $answer], $parameters['extension'] ?? null); + DI::apiResponse()->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null); } else { throw new InternalServerErrorException("unknown error - updating in database failed"); } diff --git a/src/Module/Api/Friendica/Profile/Show.php b/src/Module/Api/Friendica/Profile/Show.php index e388405eff..fe0315a84d 100644 --- a/src/Module/Api/Friendica/Profile/Show.php +++ b/src/Module/Api/Friendica/Profile/Show.php @@ -34,7 +34,7 @@ use Friendica\Network\HTTPException; */ class Show extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); @@ -49,7 +49,7 @@ class Show extends BaseApi $profile = self::formatProfile($profile, $profileFields); $profiles = []; - if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) { + if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) { $profiles['0:profile'] = $profile; } else { $profiles[] = $profile; @@ -65,7 +65,7 @@ class Show extends BaseApi 'profiles' => $profiles ]; - DI::apiResponse()->exit('friendica_profiles', ['$result' => $result], $parameters['extension'] ?? null); + DI::apiResponse()->exit('friendica_profiles', ['$result' => $result], $this->parameters['extension'] ?? null); } /** diff --git a/src/Module/Api/GNUSocial/GNUSocial/Config.php b/src/Module/Api/GNUSocial/GNUSocial/Config.php index 3ec6cdbce1..6e661d2d72 100644 --- a/src/Module/Api/GNUSocial/GNUSocial/Config.php +++ b/src/Module/Api/GNUSocial/GNUSocial/Config.php @@ -31,7 +31,7 @@ use Friendica\Module\Register; */ class Config extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { $config = [ 'site' => [ @@ -61,6 +61,6 @@ class Config extends BaseApi ], ]; - self::exit('config', ['config' => $config], $parameters['extension'] ?? null); + DI::apiResponse()->exit('config', ['config' => $config], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/GNUSocial/GNUSocial/Version.php b/src/Module/Api/GNUSocial/GNUSocial/Version.php index 52393702f9..c9c7b98fd1 100644 --- a/src/Module/Api/GNUSocial/GNUSocial/Version.php +++ b/src/Module/Api/GNUSocial/GNUSocial/Version.php @@ -29,8 +29,8 @@ use Friendica\DI; */ class Version extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { - DI::apiResponse()->exit('version', ['version' => '0.9.7'], $parameters['extension'] ?? null); + DI::apiResponse()->exit('version', ['version' => '0.9.7'], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/GNUSocial/Help/Test.php b/src/Module/Api/GNUSocial/Help/Test.php index 3df694c859..78f18c3e60 100644 --- a/src/Module/Api/GNUSocial/Help/Test.php +++ b/src/Module/Api/GNUSocial/Help/Test.php @@ -29,14 +29,14 @@ use Friendica\DI; */ class Test extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { - if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) { + if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) { $ok = 'true'; } else { $ok = 'ok'; } - DI::apiResponse()->exit('ok', ['ok' => $ok], $parameters['extension'] ?? null); + DI::apiResponse()->exit('ok', ['ok' => $ok], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Mastodon/Accounts.php b/src/Module/Api/Mastodon/Accounts.php index 781547854a..552889661b 100644 --- a/src/Module/Api/Mastodon/Accounts.php +++ b/src/Module/Api/Mastodon/Accounts.php @@ -33,27 +33,26 @@ use Friendica\Module\BaseApi; class Accounts extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { $uid = self::getCurrentUserID(); - if (empty($parameters['id']) && empty($parameters['name'])) { + if (empty($this->parameters['id']) && empty($this->parameters['name'])) { DI::mstdnError()->UnprocessableEntity(); } - if (!empty($parameters['id'])) { - $id = $parameters['id']; + if (!empty($this->parameters['id'])) { + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } } else { - $contact = Contact::selectFirst(['id'], ['nick' => $parameters['name'], 'uid' => 0]); + $contact = Contact::selectFirst(['id'], ['nick' => $this->parameters['name'], 'uid' => 0]); if (!empty($contact['id'])) { $id = $contact['id']; - } elseif (!($id = Contact::getIdForURL($parameters['name'], 0, false))) { + } elseif (!($id = Contact::getIdForURL($this->parameters['name'], 0, false))) { DI::mstdnError()->RecordNotFound(); } } diff --git a/src/Module/Api/Mastodon/Accounts/Block.php b/src/Module/Api/Mastodon/Accounts/Block.php index 463383df71..b2ae98bd56 100644 --- a/src/Module/Api/Mastodon/Accounts/Block.php +++ b/src/Module/Api/Mastodon/Accounts/Block.php @@ -32,12 +32,12 @@ use Friendica\Module\BaseApi; */ class Block extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } @@ -46,7 +46,7 @@ class Block extends BaseApi DI::mstdnError()->Forbidden(); } - $cdata = Contact::getPublicAndUserContactID($parameters['id'], $uid); + $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); if (empty($cdata['user'])) { DI::mstdnError()->RecordNotFound(); } @@ -62,6 +62,6 @@ class Block extends BaseApi Contact::terminateFriendship($owner, $contact); Contact::revokeFollow($contact); - System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Accounts/FeaturedTags.php b/src/Module/Api/Mastodon/Accounts/FeaturedTags.php index c4a4a561c6..fe92696a08 100644 --- a/src/Module/Api/Mastodon/Accounts/FeaturedTags.php +++ b/src/Module/Api/Mastodon/Accounts/FeaturedTags.php @@ -30,10 +30,9 @@ use Friendica\Module\BaseApi; class FeaturedTags extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); diff --git a/src/Module/Api/Mastodon/Accounts/Follow.php b/src/Module/Api/Mastodon/Accounts/Follow.php index ab7038e979..86b932421d 100644 --- a/src/Module/Api/Mastodon/Accounts/Follow.php +++ b/src/Module/Api/Mastodon/Accounts/Follow.php @@ -31,16 +31,16 @@ use Friendica\Module\BaseApi; */ class Follow extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $cid = Contact::follow($parameters['id'], $uid); + $cid = Contact::follow($this->parameters['id'], $uid); System::jsonExit(DI::mstdnRelationship()->createFromContactId($cid, $uid)->toArray()); } diff --git a/src/Module/Api/Mastodon/Accounts/Followers.php b/src/Module/Api/Mastodon/Accounts/Followers.php index e1f864acbe..981d2c715d 100644 --- a/src/Module/Api/Mastodon/Accounts/Followers.php +++ b/src/Module/Api/Mastodon/Accounts/Followers.php @@ -32,19 +32,18 @@ use Friendica\Module\BaseApi; class Followers extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = $parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } @@ -73,7 +72,7 @@ class Followers extends BaseApi $params['order'] = ['cid']; } - $followers = DBA::select('contact-relation', ['relation-cid'], $condition, $parameters); + $followers = DBA::select('contact-relation', ['relation-cid'], $condition, $this->parameters); while ($follower = DBA::fetch($followers)) { self::setBoundaries($follower['relation-cid']); $accounts[] = DI::mstdnAccount()->createFromContactId($follower['relation-cid'], $uid); diff --git a/src/Module/Api/Mastodon/Accounts/Following.php b/src/Module/Api/Mastodon/Accounts/Following.php index e2b963e0c3..41352ddaf5 100644 --- a/src/Module/Api/Mastodon/Accounts/Following.php +++ b/src/Module/Api/Mastodon/Accounts/Following.php @@ -32,19 +32,18 @@ use Friendica\Module\BaseApi; class Following extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = $parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } @@ -73,7 +72,7 @@ class Following extends BaseApi $params['order'] = ['cid']; } - $followers = DBA::select('contact-relation', ['cid'], $condition, $parameters); + $followers = DBA::select('contact-relation', ['cid'], $condition, $this->parameters); while ($follower = DBA::fetch($followers)) { self::setBoundaries($follower['cid']); $accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid); diff --git a/src/Module/Api/Mastodon/Accounts/IdentityProofs.php b/src/Module/Api/Mastodon/Accounts/IdentityProofs.php index 6abb416d1d..88379440ab 100644 --- a/src/Module/Api/Mastodon/Accounts/IdentityProofs.php +++ b/src/Module/Api/Mastodon/Accounts/IdentityProofs.php @@ -30,10 +30,9 @@ use Friendica\Module\BaseApi; class IdentityProofs extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); diff --git a/src/Module/Api/Mastodon/Accounts/Lists.php b/src/Module/Api/Mastodon/Accounts/Lists.php index 9086749405..f34b961b63 100644 --- a/src/Module/Api/Mastodon/Accounts/Lists.php +++ b/src/Module/Api/Mastodon/Accounts/Lists.php @@ -33,19 +33,18 @@ use Friendica\Module\BaseApi; class Lists extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = $parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } diff --git a/src/Module/Api/Mastodon/Accounts/Mute.php b/src/Module/Api/Mastodon/Accounts/Mute.php index 1d878269dc..1c711db750 100644 --- a/src/Module/Api/Mastodon/Accounts/Mute.php +++ b/src/Module/Api/Mastodon/Accounts/Mute.php @@ -31,17 +31,17 @@ use Friendica\Module\BaseApi; */ class Mute extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - Contact\User::setIgnored($parameters['id'], $uid, true); + Contact\User::setIgnored($this->parameters['id'], $uid, true); - System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Accounts/Note.php b/src/Module/Api/Mastodon/Accounts/Note.php index e631922024..fe4611754d 100644 --- a/src/Module/Api/Mastodon/Accounts/Note.php +++ b/src/Module/Api/Mastodon/Accounts/Note.php @@ -32,12 +32,12 @@ use Friendica\Module\BaseApi; */ class Note extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } @@ -45,13 +45,13 @@ class Note extends BaseApi 'comment' => '', ]); - $cdata = Contact::getPublicAndUserContactID($parameters['id'], $uid); + $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); if (empty($cdata['user'])) { DI::mstdnError()->RecordNotFound(); } Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]); - System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Accounts/Relationships.php b/src/Module/Api/Mastodon/Accounts/Relationships.php index 5631952d2a..451b7b49ec 100644 --- a/src/Module/Api/Mastodon/Accounts/Relationships.php +++ b/src/Module/Api/Mastodon/Accounts/Relationships.php @@ -32,10 +32,9 @@ use Friendica\Module\BaseApi; class Relationships extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Search.php b/src/Module/Api/Mastodon/Accounts/Search.php index c31189a424..fb3aafaec2 100644 --- a/src/Module/Api/Mastodon/Accounts/Search.php +++ b/src/Module/Api/Mastodon/Accounts/Search.php @@ -35,10 +35,9 @@ use Friendica\Object\Search\ContactResult; class Search extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/Statuses.php b/src/Module/Api/Mastodon/Accounts/Statuses.php index 0e7a7fb337..5bf7b49346 100644 --- a/src/Module/Api/Mastodon/Accounts/Statuses.php +++ b/src/Module/Api/Mastodon/Accounts/Statuses.php @@ -37,18 +37,17 @@ use Friendica\Protocol\Activity; class Statuses extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = $parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } diff --git a/src/Module/Api/Mastodon/Accounts/Unblock.php b/src/Module/Api/Mastodon/Accounts/Unblock.php index b1c93ea362..ae2414b8ac 100644 --- a/src/Module/Api/Mastodon/Accounts/Unblock.php +++ b/src/Module/Api/Mastodon/Accounts/Unblock.php @@ -31,17 +31,17 @@ use Friendica\Module\BaseApi; */ class Unblock extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - Contact\User::setBlocked($parameters['id'], $uid, false); + Contact\User::setBlocked($this->parameters['id'], $uid, false); - System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Accounts/Unfollow.php b/src/Module/Api/Mastodon/Accounts/Unfollow.php index 447b1cd652..a15c946bb6 100644 --- a/src/Module/Api/Mastodon/Accounts/Unfollow.php +++ b/src/Module/Api/Mastodon/Accounts/Unfollow.php @@ -31,17 +31,17 @@ use Friendica\Module\BaseApi; */ class Unfollow extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - Contact::unfollow($parameters['id'], $uid); + Contact::unfollow($this->parameters['id'], $uid); - System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Accounts/Unmute.php b/src/Module/Api/Mastodon/Accounts/Unmute.php index bc2e50be91..d1410f7824 100644 --- a/src/Module/Api/Mastodon/Accounts/Unmute.php +++ b/src/Module/Api/Mastodon/Accounts/Unmute.php @@ -31,17 +31,17 @@ use Friendica\Module\BaseApi; */ class Unmute extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - Contact\User::setIgnored($parameters['id'], $uid, false); + Contact\User::setIgnored($this->parameters['id'], $uid, false); - System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php b/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php index 449e26fb96..2c55bff43e 100644 --- a/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php +++ b/src/Module/Api/Mastodon/Accounts/UpdateCredentials.php @@ -32,7 +32,7 @@ use Friendica\Util\HTTPInputData; */ class UpdateCredentials extends BaseApi { - public static function patch(array $parameters = []) + public function patch() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php b/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php index 1c1945438b..0cce460375 100644 --- a/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php +++ b/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php @@ -33,10 +33,9 @@ use Friendica\Module\BaseApi; class VerifyCredentials extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Announcements.php b/src/Module/Api/Mastodon/Announcements.php index 5a414fda10..b8d231df6a 100644 --- a/src/Module/Api/Mastodon/Announcements.php +++ b/src/Module/Api/Mastodon/Announcements.php @@ -30,10 +30,9 @@ use Friendica\Module\BaseApi; class Announcements extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); diff --git a/src/Module/Api/Mastodon/Apps.php b/src/Module/Api/Mastodon/Apps.php index 040607137c..a00bd40857 100644 --- a/src/Module/Api/Mastodon/Apps.php +++ b/src/Module/Api/Mastodon/Apps.php @@ -33,10 +33,9 @@ use Friendica\Util\Network; class Apps extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function post(array $parameters = []) + public function post() { $request = self::getRequest([ 'client_name' => '', diff --git a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php index e4105f142f..e9720da0f8 100644 --- a/src/Module/Api/Mastodon/Apps/VerifyCredentials.php +++ b/src/Module/Api/Mastodon/Apps/VerifyCredentials.php @@ -30,7 +30,7 @@ use Friendica\Module\BaseApi; */ class VerifyCredentials extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $application = self::getCurrentApplication(); diff --git a/src/Module/Api/Mastodon/Blocks.php b/src/Module/Api/Mastodon/Blocks.php index 305914c1aa..b6a26d9733 100644 --- a/src/Module/Api/Mastodon/Blocks.php +++ b/src/Module/Api/Mastodon/Blocks.php @@ -32,19 +32,18 @@ use Friendica\Module\BaseApi; class Blocks extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = $parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } @@ -73,7 +72,7 @@ class Blocks extends BaseApi $params['order'] = ['cid']; } - $followers = DBA::select('user-contact', ['cid'], $condition, $parameters); + $followers = DBA::select('user-contact', ['cid'], $condition, $this->parameters); while ($follower = DBA::fetch($followers)) { self::setBoundaries($follower['cid']); $accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid); diff --git a/src/Module/Api/Mastodon/Bookmarks.php b/src/Module/Api/Mastodon/Bookmarks.php index a7141e3dcb..7b51e4316c 100644 --- a/src/Module/Api/Mastodon/Bookmarks.php +++ b/src/Module/Api/Mastodon/Bookmarks.php @@ -34,10 +34,9 @@ use Friendica\Network\HTTPException; class Bookmarks extends BaseApi { /** - * @param array $parameters * @throws HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Conversations.php b/src/Module/Api/Mastodon/Conversations.php index 22774b57ce..a3f6a26a28 100644 --- a/src/Module/Api/Mastodon/Conversations.php +++ b/src/Module/Api/Mastodon/Conversations.php @@ -31,26 +31,25 @@ use Friendica\Module\BaseApi; */ class Conversations extends BaseApi { - public static function delete(array $parameters = []) + public function delete() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (!empty($parameters['id'])) { + if (!empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - DBA::delete('conv', ['id' => $parameters['id'], 'uid' => $uid]); - DBA::delete('mail', ['convid' => $parameters['id'], 'uid' => $uid]); + DBA::delete('conv', ['id' => $this->parameters['id'], 'uid' => $uid]); + DBA::delete('mail', ['convid' => $this->parameters['id'], 'uid' => $uid]); System::jsonExit([]); } /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Conversations/Read.php b/src/Module/Api/Mastodon/Conversations/Read.php index c469eea346..1eadc671c1 100644 --- a/src/Module/Api/Mastodon/Conversations/Read.php +++ b/src/Module/Api/Mastodon/Conversations/Read.php @@ -31,17 +31,17 @@ use Friendica\Module\BaseApi; */ class Read extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (!empty($parameters['id'])) { + if (!empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - DBA::update('mail', ['seen' => true], ['convid' => $parameters['id'], 'uid' => $uid]); + DBA::update('mail', ['seen' => true], ['convid' => $this->parameters['id'], 'uid' => $uid]); - System::jsonExit(DI::mstdnConversation()->CreateFromConvId($parameters['id'])->toArray()); + System::jsonExit(DI::mstdnConversation()->CreateFromConvId($this->parameters['id'])->toArray()); } } diff --git a/src/Module/Api/Mastodon/CustomEmojis.php b/src/Module/Api/Mastodon/CustomEmojis.php index a9723414d2..1fedf53482 100644 --- a/src/Module/Api/Mastodon/CustomEmojis.php +++ b/src/Module/Api/Mastodon/CustomEmojis.php @@ -33,12 +33,11 @@ use Friendica\Network\HTTPException; class CustomEmojis extends BaseApi { /** - * @param array $parameters * @throws HTTPException\InternalServerErrorException * @throws \ImagickException * @see https://docs.joinmastodon.org/methods/accounts/follow_requests#pending-follows */ - public static function rawContent(array $parameters = []) + public function rawContent() { $emojis = DI::mstdnEmoji()->createCollectionFromSmilies(Smilies::getList()); diff --git a/src/Module/Api/Mastodon/Directory.php b/src/Module/Api/Mastodon/Directory.php index 115b02a86f..e48a709596 100644 --- a/src/Module/Api/Mastodon/Directory.php +++ b/src/Module/Api/Mastodon/Directory.php @@ -35,12 +35,11 @@ use Friendica\Network\HTTPException; class Directory extends BaseApi { /** - * @param array $parameters * @throws HTTPException\InternalServerErrorException * @throws \ImagickException * @see https://docs.joinmastodon.org/methods/instance/directory/ */ - public static function rawContent(array $parameters = []) + public function rawContent() { $request = self::getRequest([ 'offset' => 0, // How many accounts to skip before returning results. Default 0. diff --git a/src/Module/Api/Mastodon/Endorsements.php b/src/Module/Api/Mastodon/Endorsements.php index 9c5e853bc7..b9a5bc2cdb 100644 --- a/src/Module/Api/Mastodon/Endorsements.php +++ b/src/Module/Api/Mastodon/Endorsements.php @@ -30,10 +30,9 @@ use Friendica\Module\BaseApi; class Endorsements extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { System::jsonExit([]); } diff --git a/src/Module/Api/Mastodon/Favourited.php b/src/Module/Api/Mastodon/Favourited.php index 31e760d3b8..48aa452f24 100644 --- a/src/Module/Api/Mastodon/Favourited.php +++ b/src/Module/Api/Mastodon/Favourited.php @@ -35,10 +35,9 @@ use Friendica\Protocol\Activity; class Favourited extends BaseApi { /** - * @param array $parameters * @throws HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Filters.php b/src/Module/Api/Mastodon/Filters.php index f14b74a0bd..5bf50db1ab 100644 --- a/src/Module/Api/Mastodon/Filters.php +++ b/src/Module/Api/Mastodon/Filters.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Filters extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); @@ -39,10 +39,9 @@ class Filters extends BaseApi } /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); diff --git a/src/Module/Api/Mastodon/FollowRequests.php b/src/Module/Api/Mastodon/FollowRequests.php index bc7cc31bbe..af4ac5771f 100644 --- a/src/Module/Api/Mastodon/FollowRequests.php +++ b/src/Module/Api/Mastodon/FollowRequests.php @@ -33,7 +33,6 @@ use Friendica\Network\HTTPException; class FollowRequests extends BaseApi { /** - * @param array $parameters * @throws HTTPException\BadRequestException * @throws HTTPException\InternalServerErrorException * @throws HTTPException\NotFoundException @@ -43,16 +42,16 @@ class FollowRequests extends BaseApi * @see https://docs.joinmastodon.org/methods/accounts/follow_requests#accept-follow * @see https://docs.joinmastodon.org/methods/accounts/follow_requests#reject-follow */ - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); - $introduction = DI::intro()->selectOneById($parameters['id'], $uid); + $introduction = DI::intro()->selectOneById($this->parameters['id'], $uid); $contactId = $introduction->cid; - switch ($parameters['action']) { + switch ($this->parameters['action']) { case 'authorize': Contact\Introduction::confirm($introduction); $relationship = DI::mstdnRelationship()->createFromContactId($contactId, $uid); @@ -79,12 +78,11 @@ class FollowRequests extends BaseApi } /** - * @param array $parameters * @throws HTTPException\InternalServerErrorException * @throws \ImagickException * @see https://docs.joinmastodon.org/methods/accounts/follow_requests/ */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Instance.php b/src/Module/Api/Mastodon/Instance.php index 2e73a440d0..b7dc7d700d 100644 --- a/src/Module/Api/Mastodon/Instance.php +++ b/src/Module/Api/Mastodon/Instance.php @@ -31,10 +31,9 @@ use Friendica\Object\Api\Mastodon\Instance as InstanceEntity; class Instance extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { System::jsonExit(InstanceEntity::get()); } diff --git a/src/Module/Api/Mastodon/Instance/Peers.php b/src/Module/Api/Mastodon/Instance/Peers.php index be18a5aa14..b1fdd062bd 100644 --- a/src/Module/Api/Mastodon/Instance/Peers.php +++ b/src/Module/Api/Mastodon/Instance/Peers.php @@ -34,10 +34,9 @@ use Friendica\Util\Network; class Peers extends BaseApi { /** - * @param array $parameters * @throws HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { $return = []; diff --git a/src/Module/Api/Mastodon/Instance/Rules.php b/src/Module/Api/Mastodon/Instance/Rules.php index 9b7d2dc77f..3063bf9ead 100644 --- a/src/Module/Api/Mastodon/Instance/Rules.php +++ b/src/Module/Api/Mastodon/Instance/Rules.php @@ -34,10 +34,9 @@ use Friendica\Network\HTTPException; class Rules extends BaseApi { /** - * @param array $parameters * @throws HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { $rules = []; $id = 0; diff --git a/src/Module/Api/Mastodon/Lists.php b/src/Module/Api/Mastodon/Lists.php index 8be4207eae..e7a66f04db 100644 --- a/src/Module/Api/Mastodon/Lists.php +++ b/src/Module/Api/Mastodon/Lists.php @@ -31,27 +31,27 @@ use Friendica\Model\Group; */ class Lists extends BaseApi { - public static function delete(array $parameters = []) + public function delete() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - if (!Group::exists($parameters['id'], $uid)) { + if (!Group::exists($this->parameters['id'], $uid)) { DI::mstdnError()->RecordNotFound(); } - if (!Group::remove($parameters['id'])) { + if (!Group::remove($this->parameters['id'])) { DI::mstdnError()->InternalError(); } System::jsonExit([]); } - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -74,30 +74,29 @@ class Lists extends BaseApi System::jsonExit(DI::mstdnList()->createFromGroupId($id)); } - public static function put(array $parameters = []) + public function put() { $request = self::getRequest([ 'title' => '', // The title of the list to be updated. 'replies_policy' => '', // One of: "followed", "list", or "none". ]); - if (empty($request['title']) || empty($parameters['id'])) { + if (empty($request['title']) || empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - Group::update($parameters['id'], $request['title']); + Group::update($this->parameters['id'], $request['title']); } /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { $lists = []; $groups = Group::getByUserId($uid); @@ -106,7 +105,7 @@ class Lists extends BaseApi $lists[] = DI::mstdnList()->createFromGroupId($group['id']); } } else { - $id = $parameters['id']; + $id = $this->parameters['id']; if (!Group::exists($id, $uid)) { DI::mstdnError()->RecordNotFound(); diff --git a/src/Module/Api/Mastodon/Lists/Accounts.php b/src/Module/Api/Mastodon/Lists/Accounts.php index b83f4903a9..c70e20349b 100644 --- a/src/Module/Api/Mastodon/Lists/Accounts.php +++ b/src/Module/Api/Mastodon/Lists/Accounts.php @@ -35,30 +35,29 @@ use Friendica\Module\BaseApi; */ class Accounts extends BaseApi { - public static function delete(array $parameters = []) + public function delete() { DI::apiResponse()->unsupported(Router::DELETE); } - public static function post(array $parameters = []) + public function post() { DI::apiResponse()->unsupported(Router::POST); } /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = $parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('group', ['id' => $id, 'uid' => $uid])) { DI::mstdnError()->RecordNotFound(); } diff --git a/src/Module/Api/Mastodon/Markers.php b/src/Module/Api/Mastodon/Markers.php index 394d508d77..6a01a30cfa 100644 --- a/src/Module/Api/Mastodon/Markers.php +++ b/src/Module/Api/Mastodon/Markers.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class Markers extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); @@ -39,10 +39,9 @@ class Markers extends BaseApi } /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); diff --git a/src/Module/Api/Mastodon/Media.php b/src/Module/Api/Mastodon/Media.php index b93a06288f..dc31bdec68 100644 --- a/src/Module/Api/Mastodon/Media.php +++ b/src/Module/Api/Mastodon/Media.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Media extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -53,7 +53,7 @@ class Media extends BaseApi System::jsonExit(DI::mstdnAttachment()->createFromPhoto($media['id'])); } - public static function put(array $parameters = []) + public function put() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -65,34 +65,33 @@ class Media extends BaseApi 'focus' => '', // Two floating points (x,y), comma-delimited ranging from -1.0 to 1.0 ]); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $photo = Photo::selectFirst(['resource-id'], ['id' => $parameters['id'], 'uid' => $uid]); + $photo = Photo::selectFirst(['resource-id'], ['id' => $this->parameters['id'], 'uid' => $uid]); if (empty($photo['resource-id'])) { DI::mstdnError()->RecordNotFound(); } Photo::update(['desc' => $request['description']], ['resource-id' => $photo['resource-id']]); - System::jsonExit(DI::mstdnAttachment()->createFromPhoto($parameters['id'])); + System::jsonExit(DI::mstdnAttachment()->createFromPhoto($this->parameters['id'])); } /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = $parameters['id']; + $id = $this->parameters['id']; if (!Photo::exists(['id' => $id, 'uid' => $uid])) { DI::mstdnError()->RecordNotFound(); } diff --git a/src/Module/Api/Mastodon/Mutes.php b/src/Module/Api/Mastodon/Mutes.php index 7939da114b..3c24071f07 100644 --- a/src/Module/Api/Mastodon/Mutes.php +++ b/src/Module/Api/Mastodon/Mutes.php @@ -32,19 +32,18 @@ use Friendica\Module\BaseApi; class Mutes extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = $parameters['id']; + $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } @@ -73,7 +72,7 @@ class Mutes extends BaseApi $params['order'] = ['cid']; } - $followers = DBA::select('user-contact', ['cid'], $condition, $parameters); + $followers = DBA::select('user-contact', ['cid'], $condition, $this->parameters); while ($follower = DBA::fetch($followers)) { self::setBoundaries($follower['cid']); $accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid); diff --git a/src/Module/Api/Mastodon/Notifications.php b/src/Module/Api/Mastodon/Notifications.php index a6a024d9b1..274a857866 100644 --- a/src/Module/Api/Mastodon/Notifications.php +++ b/src/Module/Api/Mastodon/Notifications.php @@ -38,16 +38,15 @@ use Friendica\Protocol\Activity; class Notifications extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (!empty($parameters['id'])) { - $id = $parameters['id']; + if (!empty($this->parameters['id'])) { + $id = $this->parameters['id']; try { $notification = DI::notification()->selectOneForUser($uid, ['id' => $id]); System::jsonExit(DI::mstdnNotification()->createFromNotification($notification)); diff --git a/src/Module/Api/Mastodon/Notifications/Clear.php b/src/Module/Api/Mastodon/Notifications/Clear.php index 9dca0bf655..4249791579 100644 --- a/src/Module/Api/Mastodon/Notifications/Clear.php +++ b/src/Module/Api/Mastodon/Notifications/Clear.php @@ -30,7 +30,7 @@ use Friendica\Module\BaseApi; */ class Clear extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Notifications/Dismiss.php b/src/Module/Api/Mastodon/Notifications/Dismiss.php index b615c5e890..b978e46eee 100644 --- a/src/Module/Api/Mastodon/Notifications/Dismiss.php +++ b/src/Module/Api/Mastodon/Notifications/Dismiss.php @@ -32,16 +32,16 @@ use Friendica\Network\HTTPException\ForbiddenException; */ class Dismiss extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $Notification = DI::notification()->selectOneForUser($uid, $parameters['id']); + $Notification = DI::notification()->selectOneForUser($uid, $this->parameters['id']); $Notification->setSeen(); DI::notification()->save($Notification); diff --git a/src/Module/Api/Mastodon/Preferences.php b/src/Module/Api/Mastodon/Preferences.php index d54bd85fa1..6d846c35bc 100644 --- a/src/Module/Api/Mastodon/Preferences.php +++ b/src/Module/Api/Mastodon/Preferences.php @@ -32,10 +32,9 @@ use Friendica\Module\BaseApi; class Preferences extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Proofs.php b/src/Module/Api/Mastodon/Proofs.php index 1d09a92113..c9b92246a8 100644 --- a/src/Module/Api/Mastodon/Proofs.php +++ b/src/Module/Api/Mastodon/Proofs.php @@ -30,10 +30,9 @@ use Friendica\Module\BaseApi; class Proofs extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { System::jsonError(404, ['error' => 'Record not found']); } diff --git a/src/Module/Api/Mastodon/PushSubscription.php b/src/Module/Api/Mastodon/PushSubscription.php index 3bc77aeb6f..e45c943f52 100644 --- a/src/Module/Api/Mastodon/PushSubscription.php +++ b/src/Module/Api/Mastodon/PushSubscription.php @@ -33,7 +33,7 @@ use Friendica\Object\Api\Mastodon\Notification; */ class PushSubscription extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); @@ -66,7 +66,7 @@ class PushSubscription extends BaseApi return DI::mstdnSubscription()->createForApplicationIdAndUserId($application['id'], $uid)->toArray(); } - public static function put(array $parameters = []) + public function put() { self::checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); @@ -99,7 +99,7 @@ class PushSubscription extends BaseApi return DI::mstdnSubscription()->createForApplicationIdAndUserId($application['id'], $uid)->toArray(); } - public static function delete(array $parameters = []) + public function delete() { self::checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); @@ -112,7 +112,7 @@ class PushSubscription extends BaseApi System::jsonExit([]); } - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_PUSH); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/ScheduledStatuses.php b/src/Module/Api/Mastodon/ScheduledStatuses.php index 82be0d6e7b..bfb2cff455 100644 --- a/src/Module/Api/Mastodon/ScheduledStatuses.php +++ b/src/Module/Api/Mastodon/ScheduledStatuses.php @@ -34,7 +34,7 @@ use Friendica\Module\BaseApi; */ class ScheduledStatuses extends BaseApi { - public static function put(array $parameters = []) + public function put() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -42,35 +42,34 @@ class ScheduledStatuses extends BaseApi DI::apiResponse()->unsupported(Router::PUT); } - public static function delete(array $parameters = []) + public function delete() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - if (!DBA::exists('delayed-post', ['id' => $parameters['id'], 'uid' => $uid])) { + if (!DBA::exists('delayed-post', ['id' => $this->parameters['id'], 'uid' => $uid])) { DI::mstdnError()->RecordNotFound(); } - Post\Delayed::deleteById($parameters['id']); + Post\Delayed::deleteById($this->parameters['id']); System::jsonExit([]); } /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (isset($parameters['id'])) { - System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($parameters['id'], $uid)->toArray()); + if (isset($this->parameters['id'])) { + System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($this->parameters['id'], $uid)->toArray()); } $request = self::getRequest([ diff --git a/src/Module/Api/Mastodon/Search.php b/src/Module/Api/Mastodon/Search.php index 63190151d7..6753b09098 100644 --- a/src/Module/Api/Mastodon/Search.php +++ b/src/Module/Api/Mastodon/Search.php @@ -38,10 +38,9 @@ use Friendica\Object\Search\ContactResult; class Search extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); @@ -74,7 +73,7 @@ class Search extends BaseApi $result['statuses'] = self::searchStatuses($uid, $request['q'], $request['account_id'], $request['max_id'], $request['min_id'], $limit, $request['offset']); } if ((empty($request['type']) || ($request['type'] == 'hashtags')) && (strpos($request['q'], '@') == false)) { - $result['hashtags'] = self::searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], $parameters['version']); + $result['hashtags'] = self::searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], $this->parameters['version']); } System::jsonExit($result); diff --git a/src/Module/Api/Mastodon/Statuses.php b/src/Module/Api/Mastodon/Statuses.php index ed5abf1996..50c35f3477 100644 --- a/src/Module/Api/Mastodon/Statuses.php +++ b/src/Module/Api/Mastodon/Statuses.php @@ -41,7 +41,7 @@ use Friendica\Util\Images; */ class Statuses extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); @@ -207,16 +207,16 @@ class Statuses extends BaseApi DI::mstdnError()->InternalError(); } - public static function delete(array $parameters = []) + public function delete() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $parameters['id'], 'uid' => $uid]); + $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => $uid]); if (empty($item['id'])) { DI::mstdnError()->RecordNotFound(); } @@ -229,17 +229,16 @@ class Statuses extends BaseApi } /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)); } } diff --git a/src/Module/Api/Mastodon/Statuses/Bookmark.php b/src/Module/Api/Mastodon/Statuses/Bookmark.php index 79be11a4a2..de0ef641d3 100644 --- a/src/Module/Api/Mastodon/Statuses/Bookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Bookmark.php @@ -33,16 +33,16 @@ use Friendica\Module\BaseApi; */ class Bookmark extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -53,6 +53,6 @@ class Bookmark extends BaseApi Item::update(['starred' => true], ['id' => $item['id']]); - System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Card.php b/src/Module/Api/Mastodon/Statuses/Card.php index 2fe4825544..d3c1801a29 100644 --- a/src/Module/Api/Mastodon/Statuses/Card.php +++ b/src/Module/Api/Mastodon/Statuses/Card.php @@ -33,18 +33,17 @@ use Friendica\Network\HTTPException; class Card extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = $parameters['id']; + $id = $this->parameters['id']; if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) { throw new HTTPException\NotFoundException('Item with URI ID ' . $id . ' not found' . ($uid ? ' for user ' . $uid : '.')); diff --git a/src/Module/Api/Mastodon/Statuses/Context.php b/src/Module/Api/Mastodon/Statuses/Context.php index 62397afdbc..03782ef1ce 100644 --- a/src/Module/Api/Mastodon/Statuses/Context.php +++ b/src/Module/Api/Mastodon/Statuses/Context.php @@ -33,14 +33,13 @@ use Friendica\Module\BaseApi; class Context extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } @@ -48,7 +47,7 @@ class Context extends BaseApi 'limit' => 40, // Maximum number of results to return. Defaults to 40. ]); - $id = $parameters['id']; + $id = $this->parameters['id']; $parents = []; $children = []; diff --git a/src/Module/Api/Mastodon/Statuses/Favourite.php b/src/Module/Api/Mastodon/Statuses/Favourite.php index a30ad0fe78..8ec818a8ff 100644 --- a/src/Module/Api/Mastodon/Statuses/Favourite.php +++ b/src/Module/Api/Mastodon/Statuses/Favourite.php @@ -33,22 +33,22 @@ use Friendica\Module\BaseApi; */ class Favourite extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } Item::performActivity($item['id'], 'like', $uid); - System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/FavouritedBy.php b/src/Module/Api/Mastodon/Statuses/FavouritedBy.php index 67dc4b67fb..37d9e7521a 100644 --- a/src/Module/Api/Mastodon/Statuses/FavouritedBy.php +++ b/src/Module/Api/Mastodon/Statuses/FavouritedBy.php @@ -33,18 +33,17 @@ use Friendica\Protocol\Activity; class FavouritedBy extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = $parameters['id']; + $id = $this->parameters['id']; if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) { DI::mstdnError()->RecordNotFound(); } diff --git a/src/Module/Api/Mastodon/Statuses/Mute.php b/src/Module/Api/Mastodon/Statuses/Mute.php index 812daff4d4..4a0e943f34 100644 --- a/src/Module/Api/Mastodon/Statuses/Mute.php +++ b/src/Module/Api/Mastodon/Statuses/Mute.php @@ -32,16 +32,16 @@ use Friendica\Module\BaseApi; */ class Mute extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -50,8 +50,8 @@ class Mute extends BaseApi DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be muted')); } - Post\ThreadUser::setIgnored($parameters['id'], $uid, true); + Post\ThreadUser::setIgnored($this->parameters['id'], $uid, true); - System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Pin.php b/src/Module/Api/Mastodon/Statuses/Pin.php index 1d5498167e..7648d12a0b 100644 --- a/src/Module/Api/Mastodon/Statuses/Pin.php +++ b/src/Module/Api/Mastodon/Statuses/Pin.php @@ -32,16 +32,16 @@ use Friendica\Module\BaseApi; */ class Pin extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -50,8 +50,8 @@ class Pin extends BaseApi DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be pinned')); } - Post\ThreadUser::setPinned($parameters['id'], $uid, true); + Post\ThreadUser::setPinned($this->parameters['id'], $uid, true); - System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Reblog.php b/src/Module/Api/Mastodon/Statuses/Reblog.php index 1af7efb827..d10149616a 100644 --- a/src/Module/Api/Mastodon/Statuses/Reblog.php +++ b/src/Module/Api/Mastodon/Statuses/Reblog.php @@ -35,16 +35,16 @@ use Friendica\Module\BaseApi; */ class Reblog extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => $parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -55,6 +55,6 @@ class Reblog extends BaseApi Item::performActivity($item['id'], 'announce', $uid); - System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/RebloggedBy.php b/src/Module/Api/Mastodon/Statuses/RebloggedBy.php index 11c15b41e1..52f1e2f67d 100644 --- a/src/Module/Api/Mastodon/Statuses/RebloggedBy.php +++ b/src/Module/Api/Mastodon/Statuses/RebloggedBy.php @@ -33,18 +33,17 @@ use Friendica\Protocol\Activity; class RebloggedBy extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $id = $parameters['id']; + $id = $this->parameters['id']; if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) { DI::mstdnError()->RecordNotFound(); } diff --git a/src/Module/Api/Mastodon/Statuses/Unbookmark.php b/src/Module/Api/Mastodon/Statuses/Unbookmark.php index f65b07a345..9279fec60e 100644 --- a/src/Module/Api/Mastodon/Statuses/Unbookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Unbookmark.php @@ -33,16 +33,16 @@ use Friendica\Module\BaseApi; */ class Unbookmark extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -53,6 +53,6 @@ class Unbookmark extends BaseApi Item::update(['starred' => false], ['id' => $item['id']]); - System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unfavourite.php b/src/Module/Api/Mastodon/Statuses/Unfavourite.php index b3fee36822..7898647acc 100644 --- a/src/Module/Api/Mastodon/Statuses/Unfavourite.php +++ b/src/Module/Api/Mastodon/Statuses/Unfavourite.php @@ -33,22 +33,22 @@ use Friendica\Module\BaseApi; */ class Unfavourite extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } Item::performActivity($item['id'], 'unlike', $uid); - System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unmute.php b/src/Module/Api/Mastodon/Statuses/Unmute.php index ee9b85cc4b..80b9c2c541 100644 --- a/src/Module/Api/Mastodon/Statuses/Unmute.php +++ b/src/Module/Api/Mastodon/Statuses/Unmute.php @@ -32,16 +32,16 @@ use Friendica\Module\BaseApi; */ class Unmute extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -50,8 +50,8 @@ class Unmute extends BaseApi DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unmuted')); } - Post\ThreadUser::setIgnored($parameters['id'], $uid, false); + Post\ThreadUser::setIgnored($this->parameters['id'], $uid, false); - System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unpin.php b/src/Module/Api/Mastodon/Statuses/Unpin.php index 1f4195cca3..21f44b7cbb 100644 --- a/src/Module/Api/Mastodon/Statuses/Unpin.php +++ b/src/Module/Api/Mastodon/Statuses/Unpin.php @@ -32,16 +32,16 @@ use Friendica\Module\BaseApi; */ class Unpin extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -50,8 +50,8 @@ class Unpin extends BaseApi DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be pinned')); } - Post\ThreadUser::setPinned($parameters['id'], $uid, false); + Post\ThreadUser::setPinned($this->parameters['id'], $uid, false); - System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unreblog.php b/src/Module/Api/Mastodon/Statuses/Unreblog.php index 9450e0f413..972a6aa1af 100644 --- a/src/Module/Api/Mastodon/Statuses/Unreblog.php +++ b/src/Module/Api/Mastodon/Statuses/Unreblog.php @@ -35,16 +35,16 @@ use Friendica\Module\BaseApi; */ class Unreblog extends BaseApi { - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => $parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectFirstForUser($uid, ['id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -55,6 +55,6 @@ class Unreblog extends BaseApi Item::performActivity($item['id'], 'unannounce', $uid); - System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Suggestions.php b/src/Module/Api/Mastodon/Suggestions.php index e0bb75b2de..b80c239f63 100644 --- a/src/Module/Api/Mastodon/Suggestions.php +++ b/src/Module/Api/Mastodon/Suggestions.php @@ -32,10 +32,9 @@ use Friendica\Module\BaseApi; class Suggestions extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Timelines/Direct.php b/src/Module/Api/Mastodon/Timelines/Direct.php index 3c3b9c052b..d50c97f47e 100644 --- a/src/Module/Api/Mastodon/Timelines/Direct.php +++ b/src/Module/Api/Mastodon/Timelines/Direct.php @@ -33,10 +33,9 @@ use Friendica\Network\HTTPException; class Direct extends BaseApi { /** - * @param array $parameters * @throws HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Timelines/Home.php b/src/Module/Api/Mastodon/Timelines/Home.php index 2b556d7ce7..de21bb2a12 100644 --- a/src/Module/Api/Mastodon/Timelines/Home.php +++ b/src/Module/Api/Mastodon/Timelines/Home.php @@ -34,10 +34,9 @@ use Friendica\Network\HTTPException; class Home extends BaseApi { /** - * @param array $parameters * @throws HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Timelines/ListTimeline.php b/src/Module/Api/Mastodon/Timelines/ListTimeline.php index 8d4a432c57..c9316fdf53 100644 --- a/src/Module/Api/Mastodon/Timelines/ListTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/ListTimeline.php @@ -34,15 +34,14 @@ use Friendica\Network\HTTPException; class ListTimeline extends BaseApi { /** - * @param array $parameters * @throws HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } @@ -61,7 +60,7 @@ class ListTimeline extends BaseApi $params = ['order' => ['uri-id' => true], 'limit' => $request['limit']]; $condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)", - $uid, GRAVITY_PARENT, GRAVITY_COMMENT, $parameters['id']]; + $uid, GRAVITY_PARENT, GRAVITY_COMMENT, $this->parameters['id']]; if (!empty($request['max_id'])) { $condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $request['max_id']]); diff --git a/src/Module/Api/Mastodon/Timelines/PublicTimeline.php b/src/Module/Api/Mastodon/Timelines/PublicTimeline.php index ca0141691b..162236d1ea 100644 --- a/src/Module/Api/Mastodon/Timelines/PublicTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/PublicTimeline.php @@ -37,10 +37,9 @@ use Friendica\Network\HTTPException; class PublicTimeline extends BaseApi { /** - * @param array $parameters * @throws HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { $uid = self::getCurrentUserID(); diff --git a/src/Module/Api/Mastodon/Timelines/Tag.php b/src/Module/Api/Mastodon/Timelines/Tag.php index 0437be2771..3571dd7333 100644 --- a/src/Module/Api/Mastodon/Timelines/Tag.php +++ b/src/Module/Api/Mastodon/Timelines/Tag.php @@ -35,15 +35,14 @@ use Friendica\Network\HTTPException; class Tag extends BaseApi { /** - * @param array $parameters * @throws HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); - if (empty($parameters['hashtag'])) { + if (empty($this->parameters['hashtag'])) { DI::mstdnError()->UnprocessableEntity(); } @@ -70,7 +69,7 @@ class Tag extends BaseApi $condition = ["`name` = ? AND (`uid` = ? OR (`uid` = ? AND NOT `global`)) AND (`network` IN (?, ?, ?, ?) OR (`uid` = ? AND `uid` != ?))", - $parameters['hashtag'], 0, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, $uid, 0]; + $this->parameters['hashtag'], 0, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, $uid, 0]; if ($request['local']) { $condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]); diff --git a/src/Module/Api/Mastodon/Trends.php b/src/Module/Api/Mastodon/Trends.php index 505cdbabd1..3536e737cb 100644 --- a/src/Module/Api/Mastodon/Trends.php +++ b/src/Module/Api/Mastodon/Trends.php @@ -32,10 +32,9 @@ use Friendica\Module\BaseApi; class Trends extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { $request = self::getRequest([ 'limit' => 20, // Maximum number of results to return. Defaults to 10. diff --git a/src/Module/Api/Mastodon/Unimplemented.php b/src/Module/Api/Mastodon/Unimplemented.php index 6a0a100c31..f5f76afd57 100644 --- a/src/Module/Api/Mastodon/Unimplemented.php +++ b/src/Module/Api/Mastodon/Unimplemented.php @@ -31,46 +31,41 @@ use Friendica\Module\BaseApi; class Unimplemented extends BaseApi { /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function delete(array $parameters = []) + public function delete() { DI::apiResponse()->unsupported(Router::DELETE); } /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function patch(array $parameters = []) + public function patch() { DI::apiResponse()->unsupported(Router::PATCH); } /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function post(array $parameters = []) + public function post() { DI::apiResponse()->unsupported(Router::POST); } /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function put(array $parameters = []) + public function put() { DI::apiResponse()->unsupported(Router::PUT); } /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { DI::apiResponse()->unsupported(Router::GET); } diff --git a/src/Module/Api/Twitter/Account/RateLimitStatus.php b/src/Module/Api/Twitter/Account/RateLimitStatus.php index fe422c79f1..e38ffb061a 100644 --- a/src/Module/Api/Twitter/Account/RateLimitStatus.php +++ b/src/Module/Api/Twitter/Account/RateLimitStatus.php @@ -30,9 +30,9 @@ use Friendica\Util\DateTimeFormat; */ class RateLimitStatus extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { - if (!empty($parameters['extension']) && ($parameters['extension'] == 'xml')) { + if (!empty($this->parameters['extension']) && ($this->parameters['extension'] == 'xml')) { $hash = [ 'remaining-hits' => '150', '@attributes' => ["type" => "integer"], @@ -52,6 +52,6 @@ class RateLimitStatus extends BaseApi ]; } - DI::apiResponse()->exit('hash', ['hash' => $hash], $parameters['extension'] ?? null); + DI::apiResponse()->exit('hash', ['hash' => $hash], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Api/Twitter/ContactEndpoint.php b/src/Module/Api/Twitter/ContactEndpoint.php index 7e5f11cc65..39e6d2d457 100644 --- a/src/Module/Api/Twitter/ContactEndpoint.php +++ b/src/Module/Api/Twitter/ContactEndpoint.php @@ -35,9 +35,9 @@ abstract class ContactEndpoint extends BaseApi const DEFAULT_COUNT = 20; const MAX_COUNT = 200; - public static function init(array $parameters = []) + public function init() { - parent::init($parameters); + parent::init(); self::checkAllowedScope(self::SCOPE_READ); } diff --git a/src/Module/Api/Twitter/FollowersIds.php b/src/Module/Api/Twitter/FollowersIds.php index 01be503de0..f4287dc440 100644 --- a/src/Module/Api/Twitter/FollowersIds.php +++ b/src/Module/Api/Twitter/FollowersIds.php @@ -29,7 +29,7 @@ use Friendica\Model\Contact; */ class FollowersIds extends ContactEndpoint { - public static function rawContent(array $parameters = []) + public function rawContent() { // Expected value for user_id parameter: public/user contact id $contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT); diff --git a/src/Module/Api/Twitter/FollowersList.php b/src/Module/Api/Twitter/FollowersList.php index 8e39f22019..72d2bbdcb0 100644 --- a/src/Module/Api/Twitter/FollowersList.php +++ b/src/Module/Api/Twitter/FollowersList.php @@ -29,7 +29,7 @@ use Friendica\Model\Contact; */ class FollowersList extends ContactEndpoint { - public static function rawContent(array $parameters = []) + public function rawContent() { // Expected value for user_id parameter: public/user contact id $contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT); diff --git a/src/Module/Api/Twitter/FriendsIds.php b/src/Module/Api/Twitter/FriendsIds.php index 3500a4043b..e3e9a35a38 100644 --- a/src/Module/Api/Twitter/FriendsIds.php +++ b/src/Module/Api/Twitter/FriendsIds.php @@ -29,7 +29,7 @@ use Friendica\Model\Contact; */ class FriendsIds extends ContactEndpoint { - public static function rawContent(array $parameters = []) + public function rawContent() { // Expected value for user_id parameter: public/user contact id $contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT); diff --git a/src/Module/Api/Twitter/FriendsList.php b/src/Module/Api/Twitter/FriendsList.php index 114e391cc3..764bfd8078 100644 --- a/src/Module/Api/Twitter/FriendsList.php +++ b/src/Module/Api/Twitter/FriendsList.php @@ -29,7 +29,7 @@ use Friendica\Model\Contact; */ class FriendsList extends ContactEndpoint { - public static function rawContent(array $parameters = []) + public function rawContent() { // Expected value for user_id parameter: public/user contact id $contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT); diff --git a/src/Module/Api/Twitter/SavedSearches.php b/src/Module/Api/Twitter/SavedSearches.php index b2e2c5f0d6..ac75316710 100644 --- a/src/Module/Api/Twitter/SavedSearches.php +++ b/src/Module/Api/Twitter/SavedSearches.php @@ -31,7 +31,7 @@ use Friendica\Module\BaseApi; */ class SavedSearches extends BaseApi { - public static function rawContent(array $parameters = []) + public function rawContent() { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); @@ -45,6 +45,6 @@ class SavedSearches extends BaseApi DBA::close($terms); - DI::apiResponse()->exit('terms', ['terms' => $result], $parameters['extension'] ?? null); + DI::apiResponse()->exit('terms', ['terms' => $result], $this->parameters['extension'] ?? null); } } diff --git a/src/Module/Apps.php b/src/Module/Apps.php index 46dfe41c95..1d6144f16d 100644 --- a/src/Module/Apps.php +++ b/src/Module/Apps.php @@ -31,7 +31,7 @@ use Friendica\DI; */ class Apps extends BaseModule { - public static function init(array $parameters = []) + public function init() { $privateaddons = DI::config()->get('config', 'private_addons'); if ($privateaddons === "1" && !local_user()) { @@ -39,7 +39,7 @@ class Apps extends BaseModule } } - public static function content(array $parameters = []) + public function content(): string { $apps = Nav::getAppMenu(); diff --git a/src/Module/Attach.php b/src/Module/Attach.php index a4bb9b4221..c35e6b9ba3 100644 --- a/src/Module/Attach.php +++ b/src/Module/Attach.php @@ -34,14 +34,14 @@ class Attach extends BaseModule /** * Return to user an attached file given the id */ - public static function rawContent(array $parameters = []) + public function rawContent() { $a = DI::app(); - if (empty($parameters['item'])) { + if (empty($this->parameters['item'])) { throw new \Friendica\Network\HTTPException\BadRequestException(); } - $item_id = intval($parameters['item']); + $item_id = intval($this->parameters['item']); // Check for existence $item = MAttach::exists(['id' => $item_id]); diff --git a/src/Module/BaseAdmin.php b/src/Module/BaseAdmin.php index 69c2879de6..83e3ca0b17 100644 --- a/src/Module/BaseAdmin.php +++ b/src/Module/BaseAdmin.php @@ -68,7 +68,7 @@ abstract class BaseAdmin extends BaseModule } } - public static function content(array $parameters = []) + public function content(): string { self::checkAdminAccess(true); diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php index a0a94c336f..87a6908142 100644 --- a/src/Module/BaseApi.php +++ b/src/Module/BaseApi.php @@ -53,7 +53,7 @@ class BaseApi extends BaseModule */ protected static $request = []; - public static function delete(array $parameters = []) + public function delete() { self::checkAllowedScope(self::SCOPE_WRITE); @@ -62,7 +62,7 @@ class BaseApi extends BaseModule } } - public static function patch(array $parameters = []) + public function patch() { self::checkAllowedScope(self::SCOPE_WRITE); @@ -71,7 +71,7 @@ class BaseApi extends BaseModule } } - public static function post(array $parameters = []) + public function post() { self::checkAllowedScope(self::SCOPE_WRITE); @@ -80,7 +80,7 @@ class BaseApi extends BaseModule } } - public static function put(array $parameters = []) + public function put() { self::checkAllowedScope(self::SCOPE_WRITE); @@ -139,7 +139,6 @@ class BaseApi extends BaseModule * Set boundaries for the "link" header * @param array $boundaries * @param int $id - * @return array */ protected static function setBoundaries(int $id) { diff --git a/src/Module/BaseNotifications.php b/src/Module/BaseNotifications.php index e7f9bdabe3..685337699b 100644 --- a/src/Module/BaseNotifications.php +++ b/src/Module/BaseNotifications.php @@ -82,7 +82,7 @@ abstract class BaseNotifications extends BaseModule */ abstract public static function getNotifications(); - public static function init(array $parameters = []) + public function init() { if (!local_user()) { throw new ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -94,7 +94,7 @@ abstract class BaseNotifications extends BaseModule self::$showAll = ($_REQUEST['show'] ?? '') === 'all'; } - public static function rawContent(array $parameters = []) + public function rawContent() { // If the last argument of the query is NOT json, return if (DI::args()->get(DI::args()->getArgc() - 1) !== 'json') { diff --git a/src/Module/BaseSettings.php b/src/Module/BaseSettings.php index c2516e134c..7afaa35d0a 100644 --- a/src/Module/BaseSettings.php +++ b/src/Module/BaseSettings.php @@ -28,7 +28,7 @@ use Friendica\DI; class BaseSettings extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $a = DI::app(); @@ -125,5 +125,7 @@ class BaseSettings extends BaseModule '$class' => 'settings-widget', '$items' => $tabs, ]); + + return ''; } } diff --git a/src/Module/Bookmarklet.php b/src/Module/Bookmarklet.php index 3551cfd175..5061254aa1 100644 --- a/src/Module/Bookmarklet.php +++ b/src/Module/Bookmarklet.php @@ -34,7 +34,7 @@ use Friendica\Util\Strings; */ class Bookmarklet extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $_GET['mode'] = 'minimal'; diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 4f13b28433..243ec4be3e 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -96,7 +96,7 @@ class Contact extends BaseModule DI::baseUrl()->redirect($redirectUrl); } - public static function post(array $parameters = []) + public function post() { if (!local_user()) { return; @@ -226,7 +226,7 @@ class Contact extends BaseModule Model\Contact\User::setIgnored($contact_id, local_user(), $ignored); } - public static function content(array $parameters = [], $update = 0) + public function content($update = 0): string { if (!local_user()) { return Login::form($_SERVER['REQUEST_URI']); diff --git a/src/Module/Contact/Advanced.php b/src/Module/Contact/Advanced.php index 29de7bd6fe..fb3aa62f4f 100644 --- a/src/Module/Contact/Advanced.php +++ b/src/Module/Contact/Advanced.php @@ -38,16 +38,16 @@ use Friendica\Util\Strings; */ class Advanced extends BaseModule { - public static function init(array $parameters = []) + public function init() { if (!Session::isAuthenticated()) { throw new ForbiddenException(DI::l10n()->t('Permission denied.')); } } - public static function post(array $parameters = []) + public function post() { - $cid = $parameters['id']; + $cid = $this->parameters['id']; $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => local_user()]); if (empty($contact)) { @@ -96,9 +96,9 @@ class Advanced extends BaseModule return; } - public static function content(array $parameters = []) + public function content(): string { - $cid = $parameters['id']; + $cid = $this->parameters['id']; $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => local_user()]); if (empty($contact)) { diff --git a/src/Module/Contact/Contacts.php b/src/Module/Contact/Contacts.php index b75dea43db..bfe689c1e3 100644 --- a/src/Module/Contact/Contacts.php +++ b/src/Module/Contact/Contacts.php @@ -14,7 +14,7 @@ use Friendica\Network\HTTPException; class Contacts extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $app = DI::app(); @@ -22,8 +22,8 @@ class Contacts extends BaseModule throw new HTTPException\ForbiddenException(); } - $cid = $parameters['id']; - $type = $parameters['type'] ?? 'all'; + $cid = $this->parameters['id']; + $type = $this->parameters['type'] ?? 'all'; $accounttype = $_GET['accounttype'] ?? ''; $accounttypeid = User::getAccountTypeByString($accounttype); diff --git a/src/Module/Contact/Hovercard.php b/src/Module/Contact/Hovercard.php index 57d4ac6ab6..34560313d7 100644 --- a/src/Module/Contact/Hovercard.php +++ b/src/Module/Contact/Hovercard.php @@ -35,7 +35,7 @@ use Friendica\Util\Strings; */ class Hovercard extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $contact_url = $_REQUEST['url'] ?? ''; diff --git a/src/Module/Contact/Media.php b/src/Module/Contact/Media.php index 956c33ac8d..a3a498b6d1 100644 --- a/src/Module/Contact/Media.php +++ b/src/Module/Contact/Media.php @@ -34,9 +34,9 @@ use Friendica\Network\HTTPException\BadRequestException; */ class Media extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { - $cid = $parameters['id']; + $cid = $this->parameters['id']; $contact = Model\Contact::selectFirst([], ['id' => $cid]); if (empty($contact)) { diff --git a/src/Module/Contact/Poke.php b/src/Module/Contact/Poke.php index d9dd7e27aa..23ec95a435 100644 --- a/src/Module/Contact/Poke.php +++ b/src/Module/Contact/Poke.php @@ -18,9 +18,9 @@ use Friendica\Util\XML; class Poke extends BaseModule { - public static function post(array $parameters = []) + public function post() { - if (!local_user() || empty($parameters['id'])) { + if (!local_user() || empty($this->parameters['id'])) { return self::postReturn(false); } @@ -39,14 +39,14 @@ class Poke extends BaseModule $activity = Activity::POKE . '#' . urlencode($verbs[$verb][0]); - $contact_id = intval($parameters['id']); + $contact_id = intval($this->parameters['id']); if (!$contact_id) { return self::postReturn(false); } Logger::info('verb ' . $verb . ' contact ' . $contact_id); - $contact = DBA::selectFirst('contact', ['id', 'name', 'url', 'photo'], ['id' => $parameters['id'], 'uid' => local_user()]); + $contact = DBA::selectFirst('contact', ['id', 'name', 'url', 'photo'], ['id' => $this->parameters['id'], 'uid' => local_user()]); if (!DBA::isResult($contact)) { return self::postReturn(false); } @@ -123,17 +123,17 @@ class Poke extends BaseModule return $success; } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.')); } - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { throw new HTTPException\BadRequestException(); } - $contact = DBA::selectFirst('contact', ['id', 'url', 'name'], ['id' => $parameters['id'], 'uid' => local_user()]); + $contact = DBA::selectFirst('contact', ['id', 'url', 'name'], ['id' => $this->parameters['id'], 'uid' => local_user()]); if (!DBA::isResult($contact)) { throw new HTTPException\NotFoundException(); } diff --git a/src/Module/Contact/Revoke.php b/src/Module/Contact/Revoke.php index e9b5a44243..07fe7779b5 100644 --- a/src/Module/Contact/Revoke.php +++ b/src/Module/Contact/Revoke.php @@ -37,13 +37,13 @@ class Revoke extends BaseModule /** @var array */ private static $contact; - public static function init(array $parameters = []) + public function init() { if (!local_user()) { return; } - $data = Model\Contact::getPublicAndUserContactID($parameters['id'], local_user()); + $data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], local_user()); if (!DBA::isResult($data)) { throw new HTTPException\NotFoundException(DI::l10n()->t('Unknown contact.')); } @@ -63,13 +63,13 @@ class Revoke extends BaseModule } } - public static function post(array $parameters = []) + public function post() { if (!local_user()) { throw new HTTPException\UnauthorizedException(); } - self::checkFormSecurityTokenRedirectOnError('contact/' . $parameters['id'], 'contact_revoke'); + self::checkFormSecurityTokenRedirectOnError('contact/' . $this->parameters['id'], 'contact_revoke'); $result = Model\Contact::revokeFollow(self::$contact); if ($result === true) { @@ -80,10 +80,10 @@ class Revoke extends BaseModule notice(DI::l10n()->t('Unable to revoke follow, please try again later or contact the administrator.')); } - DI::baseUrl()->redirect('contact/' . $parameters['id']); + DI::baseUrl()->redirect('contact/' . $this->parameters['id']); } - public static function content(array $parameters = []): string + public function content(): string { if (!local_user()) { return Login::form($_SERVER['REQUEST_URI']); diff --git a/src/Module/Conversation/Community.php b/src/Module/Conversation/Community.php index 3a30f37995..d954ef8f39 100644 --- a/src/Module/Conversation/Community.php +++ b/src/Module/Conversation/Community.php @@ -49,9 +49,9 @@ class Community extends BaseModule protected static $max_id; protected static $item_id; - public static function content(array $parameters = []) + public function content(): string { - self::parseRequest($parameters); + $this->parseRequest(); if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) { $tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl'); @@ -94,8 +94,8 @@ class Community extends BaseModule if (local_user() && DI::config()->get('system', 'community_no_sharer')) { $path = self::$content; - if (!empty($parameters['accounttype'])) { - $path .= '/' . $parameters['accounttype']; + if (!empty($this->parameters['accounttype'])) { + $path .= '/' . $this->parameters['accounttype']; } $query_parameters = []; @@ -166,11 +166,10 @@ class Community extends BaseModule /** * Computes module parameters from the request and local configuration * - * @param array $parameters * @throws HTTPException\BadRequestException * @throws HTTPException\ForbiddenException */ - protected static function parseRequest(array $parameters) + protected function parseRequest() { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.')); @@ -182,10 +181,10 @@ class Community extends BaseModule throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.')); } - self::$accountTypeString = $_GET['accounttype'] ?? $parameters['accounttype'] ?? ''; + self::$accountTypeString = $_GET['accounttype'] ?? $this->parameters['accounttype'] ?? ''; self::$accountType = User::getAccountTypeByString(self::$accountTypeString); - self::$content = $parameters['content'] ?? ''; + self::$content = $this->parameters['content'] ?? ''; if (!self::$content) { if (!empty(DI::config()->get('system', 'singleuser'))) { // On single user systems only the global page does make sense diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index f2dc1fae1c..0f2d9cd6fc 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -57,13 +57,13 @@ class Network extends BaseModule /** @var string */ protected static $order; - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { return Login::form(); } - self::parseRequest($parameters, $_GET); + $this->parseRequest($_GET); $module = 'network'; @@ -272,11 +272,11 @@ class Network extends BaseModule return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]); } - protected static function parseRequest(array $parameters, array $get) + protected function parseRequest(array $get) { - self::$groupId = $parameters['group_id'] ?? 0; + self::$groupId = $this->parameters['group_id'] ?? 0; - self::$forumContactId = $parameters['contact_id'] ?? 0; + self::$forumContactId = $this->parameters['contact_id'] ?? 0; self::$selectedTab = Session::get('network-tab', DI::pConfig()->get(local_user(), 'network.view', 'selected_tab', '')); @@ -317,13 +317,13 @@ class Network extends BaseModule Session::set('network-tab', self::$selectedTab); DI::pConfig()->set(local_user(), 'network.view', 'selected_tab', self::$selectedTab); - self::$accountTypeString = $get['accounttype'] ?? $parameters['accounttype'] ?? ''; + self::$accountTypeString = $get['accounttype'] ?? $this->parameters['accounttype'] ?? ''; self::$accountType = User::getAccountTypeByString(self::$accountTypeString); self::$network = $get['nets'] ?? ''; - self::$dateFrom = $parameters['from'] ?? ''; - self::$dateTo = $parameters['to'] ?? ''; + self::$dateFrom = $this->parameters['from'] ?? ''; + self::$dateTo = $this->parameters['to'] ?? ''; if (DI::mode()->isMobile()) { self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network', diff --git a/src/Module/Credits.php b/src/Module/Credits.php index 1a586a808d..fdd4f69749 100644 --- a/src/Module/Credits.php +++ b/src/Module/Credits.php @@ -32,7 +32,7 @@ use Friendica\DI; */ class Credits extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { /* fill the page with credits */ $credits_string = file_get_contents('CREDITS.txt'); diff --git a/src/Module/DFRN/Notify.php b/src/Module/DFRN/Notify.php index 6aeb23417e..eda5da9361 100644 --- a/src/Module/DFRN/Notify.php +++ b/src/Module/DFRN/Notify.php @@ -38,7 +38,7 @@ use Friendica\Network\HTTPException; */ class Notify extends BaseModule { - public static function post(array $parameters = []) + public function post() { $postdata = Network::postdata(); @@ -47,8 +47,8 @@ class Notify extends BaseModule } $data = json_decode($postdata); - if (is_object($data) && !empty($parameters['nickname'])) { - $user = User::getByNickname($parameters['nickname']); + if (is_object($data) && !empty($this->parameters['nickname'])) { + $user = User::getByNickname($this->parameters['nickname']); if (empty($user)) { throw new \Friendica\Network\HTTPException\InternalServerErrorException(); } diff --git a/src/Module/DFRN/Poll.php b/src/Module/DFRN/Poll.php index d9c7884ec0..0cf43f2a7e 100644 --- a/src/Module/DFRN/Poll.php +++ b/src/Module/DFRN/Poll.php @@ -29,11 +29,11 @@ use Friendica\Protocol\OStatus; */ class Poll extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { header("Content-type: application/atom+xml"); $last_update = $_GET['last_update'] ?? ''; - echo OStatus::feed($parameters['nickname'], $last_update, 10); + echo OStatus::feed($this->parameters['nickname'], $last_update, 10); exit(); } } diff --git a/src/Module/Debug/ActivityPubConversion.php b/src/Module/Debug/ActivityPubConversion.php index 854f557d0c..7f5fa6274d 100644 --- a/src/Module/Debug/ActivityPubConversion.php +++ b/src/Module/Debug/ActivityPubConversion.php @@ -34,7 +34,7 @@ use Friendica\Util\XML; class ActivityPubConversion extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { function visible_whitespace($s) { diff --git a/src/Module/Debug/Babel.php b/src/Module/Debug/Babel.php index ff8bc87411..c50bd08d74 100644 --- a/src/Module/Debug/Babel.php +++ b/src/Module/Debug/Babel.php @@ -35,7 +35,7 @@ use Friendica\Util\XML; */ class Babel extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { function visible_whitespace($s) { diff --git a/src/Module/Debug/Feed.php b/src/Module/Debug/Feed.php index 5ef6816682..2d2a7dc549 100644 --- a/src/Module/Debug/Feed.php +++ b/src/Module/Debug/Feed.php @@ -32,7 +32,7 @@ use Friendica\Protocol; */ class Feed extends BaseModule { - public static function init(array $parameters = []) + public function init() { if (!local_user()) { notice(DI::l10n()->t('You must be logged in to use this module')); @@ -40,7 +40,7 @@ class Feed extends BaseModule } } - public static function content(array $parameters = []) + public function content(): string { $result = []; if (!empty($_REQUEST['url'])) { diff --git a/src/Module/Debug/ItemBody.php b/src/Module/Debug/ItemBody.php index 2299b3cb21..3759931145 100644 --- a/src/Module/Debug/ItemBody.php +++ b/src/Module/Debug/ItemBody.php @@ -31,17 +31,17 @@ use Friendica\Network\HTTPException; */ class ItemBody extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.')); } - if (empty($parameters['item'])) { + if (empty($this->parameters['item'])) { throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.')); } - $itemId = intval($parameters['item']); + $itemId = intval($this->parameters['item']); $item = Post::selectFirst(['body'], ['uid' => [0, local_user()], 'uri-id' => $itemId]); diff --git a/src/Module/Debug/Localtime.php b/src/Module/Debug/Localtime.php index ff1466408e..6fb91380ae 100644 --- a/src/Module/Debug/Localtime.php +++ b/src/Module/Debug/Localtime.php @@ -31,7 +31,7 @@ class Localtime extends BaseModule { static $mod_localtime = ''; - public static function post(array $parameters = []) + public function post() { $time = ($_REQUEST['time'] ?? '') ?: 'now'; @@ -42,7 +42,7 @@ class Localtime extends BaseModule } } - public static function content(array $parameters = []) + public function content(): string { $time = ($_REQUEST['time'] ?? '') ?: 'now'; diff --git a/src/Module/Debug/Probe.php b/src/Module/Debug/Probe.php index 304096b2ec..fcb7dda218 100644 --- a/src/Module/Debug/Probe.php +++ b/src/Module/Debug/Probe.php @@ -32,7 +32,7 @@ use Friendica\Network\Probe as NetworkProbe; */ class Probe extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a probing.')); diff --git a/src/Module/Debug/WebFinger.php b/src/Module/Debug/WebFinger.php index e8a619f0b9..4527d2fb22 100644 --- a/src/Module/Debug/WebFinger.php +++ b/src/Module/Debug/WebFinger.php @@ -31,7 +31,7 @@ use Friendica\Network\Probe; */ class WebFinger extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a probing.')); diff --git a/src/Module/Delegation.php b/src/Module/Delegation.php index 12f8c5074c..2b36fc2a30 100644 --- a/src/Module/Delegation.php +++ b/src/Module/Delegation.php @@ -37,7 +37,7 @@ use Friendica\Util\Proxy; */ class Delegation extends BaseModule { - public static function post(array $parameters = []) + public function post() { if (!local_user()) { return; @@ -112,7 +112,7 @@ class Delegation extends BaseModule // NOTREACHED } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { throw new ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Diaspora/Fetch.php b/src/Module/Diaspora/Fetch.php index 55eeea9b55..e3d6f4616e 100644 --- a/src/Module/Diaspora/Fetch.php +++ b/src/Module/Diaspora/Fetch.php @@ -38,13 +38,13 @@ use Friendica\Util\Strings; */ class Fetch extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { - if (empty($parameters['guid'])) { + if (empty($this->parameters['guid'])) { throw new HTTPException\NotFoundException(); } - $guid = $parameters['guid']; + $guid = $this->parameters['guid']; // Fetch the item $condition = ['origin' => true, 'private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $guid, diff --git a/src/Module/Diaspora/Receive.php b/src/Module/Diaspora/Receive.php index dc6fb716b7..14ad5c3912 100644 --- a/src/Module/Diaspora/Receive.php +++ b/src/Module/Diaspora/Receive.php @@ -38,12 +38,12 @@ class Receive extends BaseModule /** @var LoggerInterface */ private static $logger; - public static function init(array $parameters = []) + public function init() { self::$logger = DI::logger(); } - public static function post(array $parameters = []) + public function post() { $enabled = DI::config()->get('system', 'diaspora_enabled', false); if (!$enabled) { @@ -51,10 +51,10 @@ class Receive extends BaseModule throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.')); } - if ($parameters['type'] === 'public') { + if ($this->parameters['type'] === 'public') { self::receivePublic(); - } else if ($parameters['type'] === 'users') { - self::receiveUser($parameters['guid']); + } else if ($this->parameters['type'] === 'users') { + self::receiveUser($this->parameters['guid']); } } diff --git a/src/Module/Directory.php b/src/Module/Directory.php index 0172612d51..a81780a280 100644 --- a/src/Module/Directory.php +++ b/src/Module/Directory.php @@ -38,7 +38,7 @@ use Friendica\Network\HTTPException; */ class Directory extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $app = DI::app(); $config = DI::config(); diff --git a/src/Module/Events/Json.php b/src/Module/Events/Json.php index 50e468a9c7..566cf648a2 100644 --- a/src/Module/Events/Json.php +++ b/src/Module/Events/Json.php @@ -13,7 +13,7 @@ use Friendica\Util\Temporal; class Json extends \Friendica\BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { if (!local_user()) { throw new HTTPException\UnauthorizedException(); diff --git a/src/Module/Feed.php b/src/Module/Feed.php index 788f9da7c2..6470ab5c37 100644 --- a/src/Module/Feed.php +++ b/src/Module/Feed.php @@ -41,7 +41,7 @@ use Friendica\Protocol\Feed as ProtocolFeed; */ class Feed extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $a = DI::app(); @@ -68,7 +68,7 @@ class Feed extends BaseModule } header("Content-type: application/atom+xml; charset=utf-8"); - echo ProtocolFeed::atom($parameters['nickname'], $last_update, 10, $type, $nocache, true); + echo ProtocolFeed::atom($this->parameters['nickname'], $last_update, 10, $type, $nocache, true); exit(); } } diff --git a/src/Module/Filer/RemoveTag.php b/src/Module/Filer/RemoveTag.php index 8c65f43814..e6749de020 100644 --- a/src/Module/Filer/RemoveTag.php +++ b/src/Module/Filer/RemoveTag.php @@ -33,7 +33,7 @@ use Friendica\Util\XML; */ class RemoveTag extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { throw new HTTPException\ForbiddenException(); @@ -41,7 +41,7 @@ class RemoveTag extends BaseModule $logger = DI::logger(); - $item_id = $parameters['id'] ?? 0; + $item_id = $this->parameters['id'] ?? 0; $term = XML::unescape(trim($_GET['term'] ?? '')); $cat = XML::unescape(trim($_GET['cat'] ?? '')); @@ -62,7 +62,7 @@ class RemoveTag extends BaseModule if ($item_id && strlen($term)) { $item = Post::selectFirst(['uri-id'], ['id' => $item_id]); if (!DBA::isResult($item)) { - return; + return ''; } if (!Post\Category::deleteFileByURIId($item['uri-id'], local_user(), $type, $term)) { notice(DI::l10n()->t('Item was not removed')); @@ -74,5 +74,7 @@ class RemoveTag extends BaseModule if ($type == Post\Category::FILE) { DI::baseUrl()->redirect('filed?file=' . rawurlencode($term)); } + + return ''; } } diff --git a/src/Module/Filer/SaveTag.php b/src/Module/Filer/SaveTag.php index 50f6c2e9b1..b1742c8a6a 100644 --- a/src/Module/Filer/SaveTag.php +++ b/src/Module/Filer/SaveTag.php @@ -34,7 +34,7 @@ use Friendica\Util\XML; */ class SaveTag extends BaseModule { - public static function init(array $parameters = []) + public function init() { if (!local_user()) { notice(DI::l10n()->t('You must be logged in to use this module')); @@ -42,13 +42,13 @@ class SaveTag extends BaseModule } } - public static function rawContent(array $parameters = []) + public function rawContent() { $logger = DI::logger(); $term = XML::unescape(trim($_GET['term'] ?? '')); - $item_id = $parameters['id'] ?? 0; + $item_id = $this->parameters['id'] ?? 0; $logger->info('filer', ['tag' => $term, 'item' => $item_id]); diff --git a/src/Module/FollowConfirm.php b/src/Module/FollowConfirm.php index 75153512b6..41f811698b 100644 --- a/src/Module/FollowConfirm.php +++ b/src/Module/FollowConfirm.php @@ -10,7 +10,7 @@ use Friendica\Model\Contact; */ class FollowConfirm extends BaseModule { - public static function post(array $parameters = []) + public function post() { $uid = local_user(); if (!$uid) { diff --git a/src/Module/FriendSuggest.php b/src/Module/FriendSuggest.php index 78e75bc314..b0456377f1 100644 --- a/src/Module/FriendSuggest.php +++ b/src/Module/FriendSuggest.php @@ -38,16 +38,16 @@ use Friendica\Worker\Delivery; */ class FriendSuggest extends BaseModule { - public static function init(array $parameters = []) + public function init() { if (!local_user()) { throw new ForbiddenException(DI::l10n()->t('Permission denied.')); } } - public static function post(array $parameters = []) + public function post() { - $cid = intval($parameters['contact']); + $cid = intval($this->parameters['contact']); // We do query the "uid" as well to ensure that it is our contact if (!DI::dba()->exists('contact', ['id' => $cid, 'uid' => local_user()])) { @@ -83,9 +83,9 @@ class FriendSuggest extends BaseModule info(DI::l10n()->t('Friend suggestion sent.')); } - public static function content(array $parameters = []) + public function content(): string { - $cid = intval($parameters['contact']); + $cid = intval($this->parameters['contact']); $contact = DI::dba()->selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]); if (empty($contact)) { diff --git a/src/Module/Friendica.php b/src/Module/Friendica.php index 95a319a41a..b4de151e97 100644 --- a/src/Module/Friendica.php +++ b/src/Module/Friendica.php @@ -38,7 +38,7 @@ use Friendica\Protocol\ActivityPub; */ class Friendica extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $config = DI::config(); @@ -110,7 +110,7 @@ class Friendica extends BaseModule ]); } - public static function rawContent(array $parameters = []) + public function rawContent() { if (ActivityPub::isRequest()) { try { diff --git a/src/Module/Group.php b/src/Module/Group.php index ee6c7b8c27..1750d3e04f 100644 --- a/src/Module/Group.php +++ b/src/Module/Group.php @@ -32,7 +32,7 @@ require_once 'boot.php'; class Group extends BaseModule { - public static function post(array $parameters = []) + public function post() { $a = DI::app(); @@ -138,7 +138,7 @@ class Group extends BaseModule } } - public static function content(array $parameters = []) + public function content(): string { $change = false; diff --git a/src/Module/HCard.php b/src/Module/HCard.php index 079f240ae4..110371ee95 100644 --- a/src/Module/HCard.php +++ b/src/Module/HCard.php @@ -34,14 +34,14 @@ use Friendica\Network\HTTPException; */ class HCard extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { - if ((local_user()) && ($parameters['action'] ?? '') === 'view') { + if ((local_user()) && ($this->parameters['action'] ?? '') === 'view') { // A logged in user views a profile of a user $nickname = DI::app()->getLoggedInUserNickname(); - } elseif (empty($parameters['action'])) { + } elseif (empty($this->parameters['action'])) { // Show the profile hCard - $nickname = $parameters['profile']; + $nickname = $this->parameters['profile']; } else { throw new HTTPException\NotFoundException(DI::l10n()->t('No profile')); } diff --git a/src/Module/HTTPException/MethodNotAllowed.php b/src/Module/HTTPException/MethodNotAllowed.php index f100bba492..07aab537a8 100644 --- a/src/Module/HTTPException/MethodNotAllowed.php +++ b/src/Module/HTTPException/MethodNotAllowed.php @@ -27,7 +27,7 @@ use Friendica\Network\HTTPException; class MethodNotAllowed extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { throw new HTTPException\MethodNotAllowedException(DI::l10n()->t('Method Not Allowed.')); } diff --git a/src/Module/HTTPException/PageNotFound.php b/src/Module/HTTPException/PageNotFound.php index 746773ef12..6af5e91ae6 100644 --- a/src/Module/HTTPException/PageNotFound.php +++ b/src/Module/HTTPException/PageNotFound.php @@ -27,7 +27,7 @@ use Friendica\Network\HTTPException; class PageNotFound extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { throw new HTTPException\NotFoundException(DI::l10n()->t('Page not found.')); } diff --git a/src/Module/Hashtag.php b/src/Module/Hashtag.php index cdf0de6c16..8910d9cce4 100644 --- a/src/Module/Hashtag.php +++ b/src/Module/Hashtag.php @@ -31,7 +31,7 @@ use Friendica\Util\Strings; */ class Hashtag extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $result = []; @@ -47,5 +47,7 @@ class Hashtag extends BaseModule DBA::close($taglist); System::jsonExit($result); + + return ''; } } diff --git a/src/Module/Help.php b/src/Module/Help.php index 7e84af1d69..d0b61c2211 100644 --- a/src/Module/Help.php +++ b/src/Module/Help.php @@ -32,7 +32,7 @@ use Friendica\Network\HTTPException; */ class Help extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { Nav::setSelected('help'); diff --git a/src/Module/Home.php b/src/Module/Home.php index 9d16e11aa7..f4e6b97339 100644 --- a/src/Module/Home.php +++ b/src/Module/Home.php @@ -32,7 +32,7 @@ use Friendica\Module\Security\Login; */ class Home extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $app = DI::app(); $config = DI::config(); diff --git a/src/Module/Install.php b/src/Module/Install.php index 8b6f97f984..8f872c683e 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -65,7 +65,7 @@ class Install extends BaseModule */ private static $installer; - public static function init(array $parameters = []) + public function init() { $a = DI::app(); @@ -94,7 +94,7 @@ class Install extends BaseModule self::$currentWizardStep = ($_POST['pass'] ?? '') ?: self::SYSTEM_CHECK; } - public static function post(array $parameters = []) + public function post() { $a = DI::app(); $configCache = $a->getConfigCache(); @@ -177,7 +177,7 @@ class Install extends BaseModule } } - public static function content(array $parameters = []) + public function content(): string { $a = DI::app(); $configCache = $a->getConfigCache(); diff --git a/src/Module/Invite.php b/src/Module/Invite.php index 65438c1514..10346a5162 100644 --- a/src/Module/Invite.php +++ b/src/Module/Invite.php @@ -35,7 +35,7 @@ use Friendica\Util\Strings; */ class Invite extends BaseModule { - public static function post(array $parameters = []) + public function post() { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -124,7 +124,7 @@ class Invite extends BaseModule info(DI::l10n()->tt('%d message sent.', '%d messages sent.', $total)); } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Item/Activity.php b/src/Module/Item/Activity.php index 1d44bf9957..3936aa2bcb 100644 --- a/src/Module/Item/Activity.php +++ b/src/Module/Item/Activity.php @@ -38,18 +38,18 @@ use Friendica\Network\HTTPException; */ class Activity extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { if (!Session::isAuthenticated()) { throw new HTTPException\ForbiddenException(); } - if (empty($parameters['id']) || empty($parameters['verb'])) { + if (empty($this->parameters['id']) || empty($this->parameters['verb'])) { throw new HTTPException\BadRequestException(); } - $verb = $parameters['verb']; - $itemId = $parameters['id']; + $verb = $this->parameters['verb']; + $itemId = $this->parameters['id']; if (in_array($verb, ['announce', 'unannounce'])) { $item = Post::selectFirst(['network'], ['id' => $itemId]); diff --git a/src/Module/Item/Compose.php b/src/Module/Item/Compose.php index f81b0c8969..6521ddc91a 100644 --- a/src/Module/Item/Compose.php +++ b/src/Module/Item/Compose.php @@ -40,7 +40,7 @@ use Friendica\Util\Temporal; class Compose extends BaseModule { - public static function post(array $parameters = []) + public function post() { if (!empty($_REQUEST['body'])) { $_REQUEST['return'] = 'network'; @@ -51,7 +51,7 @@ class Compose extends BaseModule } } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { return Login::form('compose', false); @@ -64,7 +64,7 @@ class Compose extends BaseModule } /// @TODO Retrieve parameter from router - $posttype = $parameters['type'] ?? Item::PT_ARTICLE; + $posttype = $this->parameters['type'] ?? Item::PT_ARTICLE; if (!in_array($posttype, [Item::PT_ARTICLE, Item::PT_PERSONAL_NOTE])) { switch ($posttype) { case 'note': diff --git a/src/Module/Item/Follow.php b/src/Module/Item/Follow.php index d67af70e45..f893531708 100644 --- a/src/Module/Item/Follow.php +++ b/src/Module/Item/Follow.php @@ -34,7 +34,7 @@ use Friendica\Network\HTTPException; */ class Follow extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $l10n = DI::l10n(); @@ -42,11 +42,11 @@ class Follow extends BaseModule throw new HttpException\ForbiddenException($l10n->t('Access denied.')); } - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { throw new HTTPException\BadRequestException(); } - $itemId = intval($parameters['id']); + $itemId = intval($this->parameters['id']); if (!Item::performActivity($itemId, 'follow', local_user())) { throw new HTTPException\BadRequestException($l10n->t('Unable to follow this item.')); diff --git a/src/Module/Item/Ignore.php b/src/Module/Item/Ignore.php index d38c19bb9a..33481fd2e3 100644 --- a/src/Module/Item/Ignore.php +++ b/src/Module/Item/Ignore.php @@ -33,7 +33,7 @@ use Friendica\Network\HTTPException; */ class Ignore extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $l10n = DI::l10n(); @@ -41,11 +41,11 @@ class Ignore extends BaseModule throw new HttpException\ForbiddenException($l10n->t('Access denied.')); } - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { throw new HTTPException\BadRequestException(); } - $itemId = intval($parameters['id']); + $itemId = intval($this->parameters['id']); $dba = DI::dba(); diff --git a/src/Module/Item/Pin.php b/src/Module/Item/Pin.php index b8022cf57c..12ff946553 100644 --- a/src/Module/Item/Pin.php +++ b/src/Module/Item/Pin.php @@ -34,7 +34,7 @@ use Friendica\Network\HTTPException; */ class Pin extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $l10n = DI::l10n(); @@ -42,11 +42,11 @@ class Pin extends BaseModule throw new HttpException\ForbiddenException($l10n->t('Access denied.')); } - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { throw new HTTPException\BadRequestException(); } - $itemId = intval($parameters['id']); + $itemId = intval($this->parameters['id']); $item = Post::selectFirst(['uri-id', 'uid'], ['id' => $itemId]); if (!DBA::isResult($item)) { diff --git a/src/Module/Item/Star.php b/src/Module/Item/Star.php index c39b6a11a0..b3e4ed2a13 100644 --- a/src/Module/Item/Star.php +++ b/src/Module/Item/Star.php @@ -35,7 +35,7 @@ use Friendica\Network\HTTPException; */ class Star extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $l10n = DI::l10n(); @@ -43,11 +43,11 @@ class Star extends BaseModule throw new HttpException\ForbiddenException($l10n->t('Access denied.')); } - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { throw new HTTPException\BadRequestException(); } - $itemId = intval($parameters['id']); + $itemId = intval($this->parameters['id']); $item = Post::selectFirstForUser(local_user(), ['uid', 'uri-id', 'starred'], ['uid' => [0, local_user()], 'id' => $itemId]); diff --git a/src/Module/Magic.php b/src/Module/Magic.php index c51c05844c..af9e5084a1 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -39,7 +39,7 @@ use Friendica\Util\Strings; */ class Magic extends BaseModule { - public static function init(array $parameters = []) + public function init() { $a = DI::app(); $ret = ['success' => false, 'url' => '', 'message' => '']; diff --git a/src/Module/Maintenance.php b/src/Module/Maintenance.php index be70e7a5c7..2025a5fa4d 100644 --- a/src/Module/Maintenance.php +++ b/src/Module/Maintenance.php @@ -34,7 +34,7 @@ use Friendica\Util\Strings; */ class Maintenance extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $reason = DI::config()->get('system', 'maintenance_reason'); diff --git a/src/Module/Manifest.php b/src/Module/Manifest.php index 0f9112d11f..ff462fd3e2 100644 --- a/src/Module/Manifest.php +++ b/src/Module/Manifest.php @@ -27,7 +27,7 @@ use Friendica\DI; class Manifest extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $config = DI::config(); diff --git a/src/Module/NoScrape.php b/src/Module/NoScrape.php index 2530038969..06bce3e248 100644 --- a/src/Module/NoScrape.php +++ b/src/Module/NoScrape.php @@ -35,14 +35,14 @@ use Friendica\Model\User; */ class NoScrape extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $a = DI::app(); - if (isset($parameters['nick'])) { + if (isset($this->parameters['nick'])) { // Get infos about a specific nick (public) - $which = $parameters['nick']; - } elseif (local_user() && isset($parameters['profile']) && DI::args()->get(2) == 'view') { + $which = $this->parameters['nick']; + } elseif (local_user() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') { // view infos about a known profile (needs a login) $which = $a->getLoggedInUserNickname(); } else { diff --git a/src/Module/NodeInfo110.php b/src/Module/NodeInfo110.php index 5248c662bf..d8f8a5049a 100644 --- a/src/Module/NodeInfo110.php +++ b/src/Module/NodeInfo110.php @@ -33,7 +33,7 @@ use Friendica\Model\Nodeinfo; */ class NodeInfo110 extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $config = DI::config(); diff --git a/src/Module/NodeInfo120.php b/src/Module/NodeInfo120.php index 0eb6e793f9..aac8c6d4fc 100644 --- a/src/Module/NodeInfo120.php +++ b/src/Module/NodeInfo120.php @@ -33,7 +33,7 @@ use Friendica\Model\Nodeinfo; */ class NodeInfo120 extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $config = DI::config(); diff --git a/src/Module/NodeInfo210.php b/src/Module/NodeInfo210.php index 5ea9c0e683..cb55411f23 100644 --- a/src/Module/NodeInfo210.php +++ b/src/Module/NodeInfo210.php @@ -33,7 +33,7 @@ use Friendica\Model\Nodeinfo; */ class NodeInfo210 extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $config = DI::config(); diff --git a/src/Module/Notifications/Introductions.php b/src/Module/Notifications/Introductions.php index 9bc9f40b0a..7379510d81 100644 --- a/src/Module/Notifications/Introductions.php +++ b/src/Module/Notifications/Introductions.php @@ -55,7 +55,7 @@ class Introductions extends BaseNotifications ]; } - public static function content(array $parameters = []) + public function content(): string { Nav::setSelected('introductions'); diff --git a/src/Module/Notifications/Notification.php b/src/Module/Notifications/Notification.php index 64ab459f12..486054f98f 100644 --- a/src/Module/Notifications/Notification.php +++ b/src/Module/Notifications/Notification.php @@ -42,13 +42,13 @@ class Notification extends BaseModule * @throws \ImagickException * @throws \Exception */ - public static function post(array $parameters = []) + public function post() { if (!local_user()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.')); } - $request_id = $parameters['id'] ?? false; + $request_id = $this->parameters['id'] ?? false; if ($request_id) { $intro = DI::intro()->selectOneById($request_id, local_user()); @@ -73,7 +73,7 @@ class Notification extends BaseModule * * @throws HTTPException\UnauthorizedException */ - public static function rawContent(array $parameters = []) + public function rawContent() { if (!local_user()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.')); @@ -101,14 +101,14 @@ class Notification extends BaseModule * @throws HTTPException\InternalServerErrorException * @throws \Exception */ - public static function content(array $parameters = []): string + public function content(): string { if (!local_user()) { notice(DI::l10n()->t('You must be logged in to show this page.')); return Login::form(); } - $request_id = $parameters['id'] ?? false; + $request_id = $this->parameters['id'] ?? false; if ($request_id) { $Notify = DI::notify()->selectOneById($request_id); diff --git a/src/Module/Notifications/Notifications.php b/src/Module/Notifications/Notifications.php index a0e40719c0..eef4af9bc4 100644 --- a/src/Module/Notifications/Notifications.php +++ b/src/Module/Notifications/Notifications.php @@ -82,7 +82,7 @@ class Notifications extends BaseNotifications ]; } - public static function content(array $parameters = []) + public function content(): string { Nav::setSelected('notifications'); diff --git a/src/Module/OAuth/Acknowledge.php b/src/Module/OAuth/Acknowledge.php index 6f7ac945b9..f0915df41a 100644 --- a/src/Module/OAuth/Acknowledge.php +++ b/src/Module/OAuth/Acknowledge.php @@ -30,13 +30,13 @@ use Friendica\Module\BaseApi; */ class Acknowledge extends BaseApi { - public static function post(array $parameters = []) + public function post() { DI::session()->set('oauth_acknowledge', true); DI::app()->redirect(DI::session()->get('return_path')); } - public static function content(array $parameters = []) + public function content(): string { DI::session()->set('return_path', $_REQUEST['return_path'] ?? ''); diff --git a/src/Module/OAuth/Authorize.php b/src/Module/OAuth/Authorize.php index cf5187d947..d39cbe353d 100644 --- a/src/Module/OAuth/Authorize.php +++ b/src/Module/OAuth/Authorize.php @@ -35,10 +35,9 @@ class Authorize extends BaseApi private static $oauth_code = ''; /** - * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function rawContent(array $parameters = []) + public function rawContent() { $request = self::getRequest([ 'force_login' => '', // Forces the user to re-login, which is necessary for authorizing with multiple accounts from the same instance. @@ -98,7 +97,7 @@ class Authorize extends BaseApi self::$oauth_code = $token['code']; } - public static function content(array $parameters = []) + public function content(): string { if (empty(self::$oauth_code)) { return ''; diff --git a/src/Module/OAuth/Revoke.php b/src/Module/OAuth/Revoke.php index 519e79db01..bf906ab454 100644 --- a/src/Module/OAuth/Revoke.php +++ b/src/Module/OAuth/Revoke.php @@ -32,7 +32,7 @@ use Friendica\Module\BaseApi; */ class Revoke extends BaseApi { - public static function post(array $parameters = []) + public function post() { $request = self::getRequest([ 'client_id' => '', // Client ID, obtained during app registration diff --git a/src/Module/OAuth/Token.php b/src/Module/OAuth/Token.php index f104e96721..6aef63f302 100644 --- a/src/Module/OAuth/Token.php +++ b/src/Module/OAuth/Token.php @@ -34,7 +34,7 @@ use Friendica\Security\OAuth; */ class Token extends BaseApi { - public static function post(array $parameters = []) + public function post() { $request = self::getRequest([ 'client_id' => '', // Client ID, obtained during app registration diff --git a/src/Module/Oembed.php b/src/Module/Oembed.php index 0d6fb8ee52..1b38c0e973 100644 --- a/src/Module/Oembed.php +++ b/src/Module/Oembed.php @@ -37,7 +37,7 @@ use Friendica\Util\Strings; */ class Oembed extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { // Unused form: /oembed/b2h?url=... if (DI::args()->getArgv()[1] == 'b2h') { diff --git a/src/Module/OpenSearch.php b/src/Module/OpenSearch.php index df37706874..e5212c2519 100644 --- a/src/Module/OpenSearch.php +++ b/src/Module/OpenSearch.php @@ -36,7 +36,7 @@ class OpenSearch extends BaseModule /** * @throws \Exception */ - public static function rawContent(array $parameters = []) + public function rawContent() { header('Content-type: application/opensearchdescription+xml'); diff --git a/src/Module/Owa.php b/src/Module/Owa.php index 5b87e6a4f1..85530df6f9 100644 --- a/src/Module/Owa.php +++ b/src/Module/Owa.php @@ -44,7 +44,7 @@ use Friendica\Util\Strings; */ class Owa extends BaseModule { - public static function init(array $parameters = []) + public function init() { $ret = [ 'success' => false ]; diff --git a/src/Module/ParseUrl.php b/src/Module/ParseUrl.php index 0b1548ed5e..092d6ec747 100644 --- a/src/Module/ParseUrl.php +++ b/src/Module/ParseUrl.php @@ -31,7 +31,7 @@ use Friendica\Util; class ParseUrl extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { if (!Session::isAuthenticated()) { throw new \Friendica\Network\HTTPException\ForbiddenException(); diff --git a/src/Module/PermissionTooltip.php b/src/Module/PermissionTooltip.php index 7599c2f060..1f6b58e4aa 100644 --- a/src/Module/PermissionTooltip.php +++ b/src/Module/PermissionTooltip.php @@ -15,10 +15,10 @@ use Friendica\Network\HTTPException; */ class PermissionTooltip extends \Friendica\BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { - $type = $parameters['type']; - $referenceId = $parameters['id']; + $type = $this->parameters['type']; + $referenceId = $this->parameters['id']; $expectedTypes = ['item', 'photo', 'event']; if (!in_array($type, $expectedTypes)) { diff --git a/src/Module/Photo.php b/src/Module/Photo.php index 399313e3f5..824edeb6af 100644 --- a/src/Module/Photo.php +++ b/src/Module/Photo.php @@ -51,7 +51,7 @@ class Photo extends BaseModule * Fetch a photo or an avatar, in optional size, check for permissions and * return the image */ - public static function rawContent(array $parameters = []) + public function rawContent() { $totalstamp = microtime(true); @@ -77,14 +77,14 @@ class Photo extends BaseModule $scale = null; $stamp = microtime(true); // User avatar - if (!empty($parameters['type'])) { - if (!empty($parameters['customsize'])) { - $customsize = intval($parameters['customsize']); - $square_resize = !in_array($parameters['type'], ['media', 'preview']); + if (!empty($this->parameters['type'])) { + if (!empty($this->parameters['customsize'])) { + $customsize = intval($this->parameters['customsize']); + $square_resize = !in_array($this->parameters['type'], ['media', 'preview']); } - if (!empty($parameters['guid'])) { - $guid = $parameters['guid']; + if (!empty($this->parameters['guid'])) { + $guid = $this->parameters['guid']; $account = DBA::selectFirst('account-user-view', ['id'], ['guid' => $guid], ['order' => ['uid' => true]]); if (empty($account)) { throw new HTTPException\NotFoundException(); @@ -94,12 +94,12 @@ class Photo extends BaseModule } // Contact Id Fallback, to remove after version 2021.12 - if (isset($parameters['contact_id'])) { - $id = intval($parameters['contact_id']); + if (isset($this->parameters['contact_id'])) { + $id = intval($this->parameters['contact_id']); } - if (!empty($parameters['nickname_ext'])) { - $nickname = pathinfo($parameters['nickname_ext'], PATHINFO_FILENAME); + if (!empty($this->parameters['nickname_ext'])) { + $nickname = pathinfo($this->parameters['nickname_ext'], PATHINFO_FILENAME); $user = User::getByNickname($nickname, ['uid']); if (empty($user)) { throw new HTTPException\NotFoundException(); @@ -109,23 +109,23 @@ class Photo extends BaseModule } // User Id Fallback, to remove after version 2021.12 - if (!empty($parameters['uid_ext'])) { - $id = intval(pathinfo($parameters['uid_ext'], PATHINFO_FILENAME)); + if (!empty($this->parameters['uid_ext'])) { + $id = intval(pathinfo($this->parameters['uid_ext'], PATHINFO_FILENAME)); } // Please refactor this for the love of everything that's good - if (isset($parameters['id'])) { - $id = $parameters['id']; + if (isset($this->parameters['id'])) { + $id = $this->parameters['id']; } if (empty($id)) { - Logger::notice('No picture id was detected', ['parameters' => $parameters, 'query' => DI::args()->getQueryString()]); + Logger::notice('No picture id was detected', ['parameters' => $this->parameters, 'query' => DI::args()->getQueryString()]); throw new HTTPException\NotFoundException(DI::l10n()->t('The Photo is not available.')); } - $photo = self::getPhotoByid($id, $parameters['type'], $customsize ?: Proxy::PIXEL_SMALL); + $photo = self::getPhotoByid($id, $this->parameters['type'], $customsize ?: Proxy::PIXEL_SMALL); } else { - $photoid = pathinfo($parameters['name'], PATHINFO_FILENAME); + $photoid = pathinfo($this->parameters['name'], PATHINFO_FILENAME); $scale = 0; if (substr($photoid, -2, 1) == "-") { $scale = intval(substr($photoid, -1, 1)); diff --git a/src/Module/Profile/Common.php b/src/Module/Profile/Common.php index 7138ac73fd..4a335ddf7f 100644 --- a/src/Module/Profile/Common.php +++ b/src/Module/Profile/Common.php @@ -35,7 +35,7 @@ use Friendica\Network\HTTPException; class Common extends BaseProfile { - public static function content(array $parameters = []) + public function content(): string { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); @@ -45,7 +45,7 @@ class Common extends BaseProfile Nav::setSelected('home'); - $nickname = $parameters['nickname']; + $nickname = $this->parameters['nickname']; $profile = Profile::load($a, $nickname); if (empty($profile)) { diff --git a/src/Module/Profile/Contacts.php b/src/Module/Profile/Contacts.php index 94f301557b..e20fd3f2d5 100644 --- a/src/Module/Profile/Contacts.php +++ b/src/Module/Profile/Contacts.php @@ -34,7 +34,7 @@ use Friendica\Network\HTTPException; class Contacts extends Module\BaseProfile { - public static function content(array $parameters = []) + public function content(): string { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); @@ -42,8 +42,8 @@ class Contacts extends Module\BaseProfile $a = DI::app(); - $nickname = $parameters['nickname']; - $type = $parameters['type'] ?? 'all'; + $nickname = $this->parameters['nickname']; + $type = $this->parameters['type'] ?? 'all'; $profile = Model\Profile::load($a, $nickname); if (empty($profile)) { diff --git a/src/Module/Profile/Index.php b/src/Module/Profile/Index.php index 5334ac932f..75d467f547 100644 --- a/src/Module/Profile/Index.php +++ b/src/Module/Profile/Index.php @@ -34,13 +34,13 @@ use Friendica\BaseModule; */ class Index extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { - Profile::rawContent($parameters); + (new Profile($this->parameters))->rawContent(); } - public static function content(array $parameters = []) + public function content(): string { - return Status::content($parameters); + return (new Status($this->parameters))->content(); } } diff --git a/src/Module/Profile/Media.php b/src/Module/Profile/Media.php index e10597199e..74af5f95e2 100644 --- a/src/Module/Profile/Media.php +++ b/src/Module/Profile/Media.php @@ -29,11 +29,11 @@ use Friendica\Network\HTTPException; class Media extends BaseProfile { - public static function content(array $parameters = []) + public function content(): string { $a = DI::app(); - $profile = ProfileModel::load($a, $parameters['nickname']); + $profile = ProfileModel::load($a, $this->parameters['nickname']); if (empty($profile)) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); } diff --git a/src/Module/Profile/Profile.php b/src/Module/Profile/Profile.php index 25b6eccc9a..a497fc4dd6 100644 --- a/src/Module/Profile/Profile.php +++ b/src/Module/Profile/Profile.php @@ -46,10 +46,10 @@ use Friendica\Util\Temporal; class Profile extends BaseProfile { - public static function rawContent(array $parameters = []) + public function rawContent() { if (ActivityPub::isRequest()) { - $user = DBA::selectFirst('user', ['uid'], ['nickname' => $parameters['nickname']]); + $user = DBA::selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname']]); if (DBA::isResult($user)) { try { $data = ActivityPub\Transmitter::getProfile($user['uid']); @@ -61,9 +61,9 @@ class Profile extends BaseProfile } } - if (DBA::exists('userd', ['username' => $parameters['nickname']])) { + if (DBA::exists('userd', ['username' => $this->parameters['nickname']])) { // Known deleted user - $data = ActivityPub\Transmitter::getDeletedUser($parameters['nickname']); + $data = ActivityPub\Transmitter::getDeletedUser($this->parameters['nickname']); System::jsonError(410, $data); } else { @@ -73,11 +73,11 @@ class Profile extends BaseProfile } } - public static function content(array $parameters = []) + public function content(): string { $a = DI::app(); - $profile = ProfileModel::load($a, $parameters['nickname']); + $profile = ProfileModel::load($a, $this->parameters['nickname']); if (!$profile) { throw new HTTPException\NotFoundException(DI::l10n()->t('Profile not found.')); } @@ -98,7 +98,7 @@ class Profile extends BaseProfile DI::page()['htmlhead'] .= '' . "\n"; } - DI::page()['htmlhead'] .= self::buildHtmlHead($profile, $parameters['nickname'], $remote_contact_id); + DI::page()['htmlhead'] .= self::buildHtmlHead($profile, $this->parameters['nickname'], $remote_contact_id); Nav::setSelected('home'); @@ -134,7 +134,7 @@ class Profile extends BaseProfile $view_as_contact_alert = DI::l10n()->t( 'You\'re currently viewing your profile as %s Cancel', htmlentities($view_as_contacts[$key]['name'], ENT_COMPAT, 'UTF-8'), - 'profile/' . $parameters['nickname'] . '/profile' + 'profile/' . $this->parameters['nickname'] . '/profile' ); } } diff --git a/src/Module/Profile/Schedule.php b/src/Module/Profile/Schedule.php index e72b1c7a65..1e9cd5fa5d 100644 --- a/src/Module/Profile/Schedule.php +++ b/src/Module/Profile/Schedule.php @@ -33,7 +33,7 @@ use Friendica\Util\DateTimeFormat; class Schedule extends BaseProfile { - public static function post(array $parameters = []) + public function post() { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -50,7 +50,7 @@ class Schedule extends BaseProfile Post\Delayed::deleteById($_REQUEST['delete']); } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -80,7 +80,7 @@ class Schedule extends BaseProfile '$form_security_token' => BaseModule::getFormSecurityToken("profile_schedule"), '$baseurl' => DI::baseUrl()->get(true), '$title' => DI::l10n()->t('Scheduled Posts'), - '$nickname' => $parameters['nickname'] ?? '', + '$nickname' => $this->parameters['nickname'] ?? '', '$scheduled_at' => DI::l10n()->t('Scheduled'), '$content' => DI::l10n()->t('Content'), '$delete' => DI::l10n()->t('Remove post'), diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index e93fc5699e..ad9a4acdee 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -46,13 +46,13 @@ use Friendica\Util\XML; class Status extends BaseProfile { - public static function content(array $parameters = []) + public function content(): string { $args = DI::args(); $a = DI::app(); - $profile = ProfileModel::load($a, $parameters['nickname']); + $profile = ProfileModel::load($a, $this->parameters['nickname']); if (empty($profile)) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); @@ -62,10 +62,10 @@ class Status extends BaseProfile DI::page()['htmlhead'] .= '' . "\n"; } - DI::page()['htmlhead'] .= '' . "\n"; - DI::page()['htmlhead'] .= '' . "\n"; - DI::page()['htmlhead'] .= '' . "\n"; - DI::page()['htmlhead'] .= '' . "\n"; + DI::page()['htmlhead'] .= '' . "\n"; + DI::page()['htmlhead'] .= '' . "\n"; + DI::page()['htmlhead'] .= '' . "\n"; + DI::page()['htmlhead'] .= '' . "\n"; $category = $datequery = $datequery2 = ''; diff --git a/src/Module/Proxy.php b/src/Module/Proxy.php index 86b8a95cbb..abe9a8c2e9 100644 --- a/src/Module/Proxy.php +++ b/src/Module/Proxy.php @@ -44,9 +44,9 @@ class Proxy extends BaseModule /** * Fetch remote image content */ - public static function rawContent(array $parameters = []) + public function rawContent() { - $request = self::getRequestInfo($parameters); + $request = $this->getRequestInfo(); if (!DI::config()->get('system', 'proxify_content')) { Logger::notice('Proxy access is forbidden', ['request' => $request, 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '', 'accept' => $_SERVER['HTTP_ACCEPT'] ?? '']); @@ -119,13 +119,13 @@ class Proxy extends BaseModule * ] * @throws \Exception */ - private static function getRequestInfo(array $parameters) + private function getRequestInfo() { $size = ProxyUtils::PIXEL_LARGE; $sizetype = ''; - if (!empty($parameters['url']) && empty($_REQUEST['url'])) { - $url = $parameters['url']; + if (!empty($this->parameters['url']) && empty($_REQUEST['url'])) { + $url = $this->parameters['url']; // thumb, small, medium and large. if (substr($url, -6) == ':micro') { diff --git a/src/Module/PublicRSAKey.php b/src/Module/PublicRSAKey.php index a13130d1c9..d159255eee 100644 --- a/src/Module/PublicRSAKey.php +++ b/src/Module/PublicRSAKey.php @@ -33,13 +33,13 @@ use Friendica\Util\Strings; */ class PublicRSAKey extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { - if (empty($parameters['nick'])) { + if (empty($this->parameters['nick'])) { throw new BadRequestException(); } - $nick = $parameters['nick']; + $nick = $this->parameters['nick']; $user = User::getByNickname($nick, ['spubkey']); if (empty($user) || empty($user['spubkey'])) { diff --git a/src/Module/RandomProfile.php b/src/Module/RandomProfile.php index df1a987d2e..38cd684294 100644 --- a/src/Module/RandomProfile.php +++ b/src/Module/RandomProfile.php @@ -30,7 +30,7 @@ use Friendica\Model\Contact; */ class RandomProfile extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $a = DI::app(); @@ -42,5 +42,7 @@ class RandomProfile extends BaseModule } DI::baseUrl()->redirect('profile'); + + return ''; } } diff --git a/src/Module/ReallySimpleDiscovery.php b/src/Module/ReallySimpleDiscovery.php index 8d6a6ff3c2..fe071fc550 100644 --- a/src/Module/ReallySimpleDiscovery.php +++ b/src/Module/ReallySimpleDiscovery.php @@ -31,7 +31,7 @@ use Friendica\Util\XML; */ class ReallySimpleDiscovery extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { header('Content-Type: text/xml'); diff --git a/src/Module/Register.php b/src/Module/Register.php index 909e61a998..fca59a2c85 100644 --- a/src/Module/Register.php +++ b/src/Module/Register.php @@ -53,7 +53,7 @@ class Register extends BaseModule * * @return string */ - public static function content(array $parameters = []) + public function content(): string { // logged in users can register others (people/pages/groups) // even with closed registrations, unless specifically prohibited by site policy. @@ -129,7 +129,7 @@ class Register extends BaseModule $tpl = $arr['template']; - $tos = new Tos(); + $tos = new Tos($this->parameters); $o = Renderer::replaceMacros($tpl, [ '$invitations' => DI::config()->get('system', 'invitation_only'), @@ -182,7 +182,7 @@ class Register extends BaseModule * Extend this method if the module is supposed to process POST requests. * Doesn't display any content */ - public static function post(array $parameters = []) + public function post() { BaseModule::checkFormSecurityTokenRedirectOnError('/register', 'register'); diff --git a/src/Module/RemoteFollow.php b/src/Module/RemoteFollow.php index f1e653f1ce..6fedc13931 100644 --- a/src/Module/RemoteFollow.php +++ b/src/Module/RemoteFollow.php @@ -42,9 +42,9 @@ class RemoteFollow extends BaseModule { static $owner; - public static function init(array $parameters = []) + public function init() { - self::$owner = User::getOwnerDataByNick($parameters['profile']); + self::$owner = User::getOwnerDataByNick($this->parameters['profile']); if (!self::$owner) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); } @@ -52,7 +52,7 @@ class RemoteFollow extends BaseModule DI::page()['aside'] = Widget\VCard::getHTML(self::$owner); } - public static function post(array $parameters = []) + public function post() { if (!empty($_POST['cancel']) || empty($_POST['dfrn_url'])) { DI::baseUrl()->redirect(); @@ -96,7 +96,7 @@ class RemoteFollow extends BaseModule System::externalRedirect($follow_link); } - public static function content(array $parameters = []) + public function content(): string { if (empty(self::$owner)) { return ''; @@ -115,7 +115,7 @@ class RemoteFollow extends BaseModule '$submit' => DI::l10n()->t('Submit Request'), '$cancel' => DI::l10n()->t('Cancel'), - '$request' => 'remote_follow/' . $parameters['profile'], + '$request' => 'remote_follow/' . $this->parameters['profile'], '$name' => self::$owner['name'], '$myaddr' => Profile::getMyURL(), ]); diff --git a/src/Module/RobotsTxt.php b/src/Module/RobotsTxt.php index 63abcf36e8..ec7ee086ec 100644 --- a/src/Module/RobotsTxt.php +++ b/src/Module/RobotsTxt.php @@ -28,7 +28,7 @@ use Friendica\BaseModule; */ class RobotsTxt extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $allDisalloweds = [ '/settings/', diff --git a/src/Module/Search/Acl.php b/src/Module/Search/Acl.php index 636e09539f..0866b5f9ae 100644 --- a/src/Module/Search/Acl.php +++ b/src/Module/Search/Acl.php @@ -48,7 +48,7 @@ class Acl extends BaseModule const TYPE_PRIVATE_MESSAGE = 'm'; const TYPE_ANY_CONTACT = 'a'; - public static function rawContent(array $parameters = []) + public function rawContent() { if (!local_user()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.')); diff --git a/src/Module/Search/Directory.php b/src/Module/Search/Directory.php index 692122155f..bbd90f137d 100644 --- a/src/Module/Search/Directory.php +++ b/src/Module/Search/Directory.php @@ -31,7 +31,7 @@ use Friendica\Module\Security\Login; */ class Directory extends BaseSearch { - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { notice(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Search/Filed.php b/src/Module/Search/Filed.php index 7bfc14f6f5..519b0ece02 100644 --- a/src/Module/Search/Filed.php +++ b/src/Module/Search/Filed.php @@ -17,7 +17,7 @@ use Friendica\Module\Security\Login; class Filed extends BaseSearch { - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { return Login::form(); diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 769d5f90d2..2118aeaaee 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -41,7 +41,7 @@ use Friendica\Network\HTTPException; class Index extends BaseSearch { - public static function content(array $parameters = []) + public function content(): string { $search = (!empty($_GET['q']) ? trim(rawurldecode($_GET['q'])) : ''); diff --git a/src/Module/Search/Saved.php b/src/Module/Search/Saved.php index d5cc15ceea..43c33d5446 100644 --- a/src/Module/Search/Saved.php +++ b/src/Module/Search/Saved.php @@ -28,7 +28,7 @@ use Friendica\DI; class Saved extends BaseModule { - public static function init(array $parameters = []) + public function init() { $action = DI::args()->get(2, 'none'); $search = trim(rawurldecode($_GET['term'] ?? '')); diff --git a/src/Module/Security/Login.php b/src/Module/Security/Login.php index 0e49234809..5c47e97496 100644 --- a/src/Module/Security/Login.php +++ b/src/Module/Security/Login.php @@ -33,7 +33,7 @@ use Friendica\Module\Register; */ class Login extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $return_path = $_REQUEST['return_path'] ?? '' ; @@ -46,7 +46,7 @@ class Login extends BaseModule return self::form(Session::get('return_path'), intval(DI::config()->get('config', 'register_policy')) !== \Friendica\Module\Register::CLOSED); } - public static function post(array $parameters = []) + public function post() { $return_path = Session::get('return_path'); Session::clear(); diff --git a/src/Module/Security/Logout.php b/src/Module/Security/Logout.php index 1724ae297e..604c9fc175 100644 --- a/src/Module/Security/Logout.php +++ b/src/Module/Security/Logout.php @@ -36,7 +36,7 @@ class Logout extends BaseModule /** * Process logout requests */ - public static function init(array $parameters = []) + public function init() { $visitor_home = null; if (remote_user()) { diff --git a/src/Module/Security/OpenID.php b/src/Module/Security/OpenID.php index 8e8613c4e9..360c9c672f 100644 --- a/src/Module/Security/OpenID.php +++ b/src/Module/Security/OpenID.php @@ -31,7 +31,7 @@ use LightOpenID; */ class OpenID extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { if (DI::config()->get('system', 'no_openid')) { DI::baseUrl()->redirect(); @@ -97,5 +97,7 @@ class OpenID extends BaseModule DI::baseUrl()->redirect('login'); } } + + return ''; } } diff --git a/src/Module/Security/TwoFactor/Recovery.php b/src/Module/Security/TwoFactor/Recovery.php index d93146cb6c..193fcb8447 100644 --- a/src/Module/Security/TwoFactor/Recovery.php +++ b/src/Module/Security/TwoFactor/Recovery.php @@ -35,14 +35,14 @@ use Friendica\Security\TwoFactor\Model\RecoveryCode; */ class Recovery extends BaseModule { - public static function init(array $parameters = []) + public function init() { if (!local_user()) { return; } } - public static function post(array $parameters = []) + public function post() { if (!local_user()) { return; @@ -67,7 +67,7 @@ class Recovery extends BaseModule } } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { DI::baseUrl()->redirect(); diff --git a/src/Module/Security/TwoFactor/Verify.php b/src/Module/Security/TwoFactor/Verify.php index 22c757b82d..3669943ba4 100644 --- a/src/Module/Security/TwoFactor/Verify.php +++ b/src/Module/Security/TwoFactor/Verify.php @@ -38,7 +38,7 @@ class Verify extends BaseModule { private static $errors = []; - public static function post(array $parameters = []) + public function post() { if (!local_user()) { return; @@ -78,7 +78,7 @@ class Verify extends BaseModule } } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { DI::baseUrl()->redirect(); diff --git a/src/Module/Settings/Delegation.php b/src/Module/Settings/Delegation.php index 067304ee8a..a2e4588396 100644 --- a/src/Module/Settings/Delegation.php +++ b/src/Module/Settings/Delegation.php @@ -36,7 +36,7 @@ use Friendica\Util\Strings; */ class Delegation extends BaseSettings { - public static function post(array $parameters = []) + public function post() { if (!DI::app()->isLoggedIn()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -62,9 +62,9 @@ class Delegation extends BaseSettings DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => local_user()]); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Settings/Display.php b/src/Module/Settings/Display.php index 5429a11e23..aab8f864b1 100644 --- a/src/Module/Settings/Display.php +++ b/src/Module/Settings/Display.php @@ -36,7 +36,7 @@ use Friendica\Network\HTTPException; */ class Display extends BaseSettings { - public static function post(array $parameters = []) + public function post() { if (!DI::app()->isLoggedIn()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -112,9 +112,9 @@ class Display extends BaseSettings DI::baseUrl()->redirect('settings/display'); } - public static function content(array $parameters = []) + public function content(): string { - parent::content($parameters); + parent::content(); if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Settings/Profile/Index.php b/src/Module/Settings/Profile/Index.php index 28e8430eaa..161c440b60 100644 --- a/src/Module/Settings/Profile/Index.php +++ b/src/Module/Settings/Profile/Index.php @@ -41,7 +41,7 @@ use Friendica\Util\Temporal; class Index extends BaseSettings { - public static function post(array $parameters = []) + public function post() { if (!local_user()) { return; @@ -135,7 +135,7 @@ class Index extends BaseSettings DI::baseUrl()->redirect('settings/profile'); } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { notice(DI::l10n()->t('You must be logged in to use this module')); diff --git a/src/Module/Settings/Profile/Photo/Crop.php b/src/Module/Settings/Profile/Photo/Crop.php index 104b6f653e..3b5f109d79 100644 --- a/src/Module/Settings/Profile/Photo/Crop.php +++ b/src/Module/Settings/Profile/Photo/Crop.php @@ -33,13 +33,13 @@ use Friendica\Network\HTTPException; class Crop extends BaseSettings { - public static function post(array $parameters = []) + public function post() { if (!Session::isAuthenticated()) { return; } - $photo_prefix = $parameters['guid']; + $photo_prefix = $this->parameters['guid']; $resource_id = $photo_prefix; $scale = 0; if (substr($photo_prefix, -2, 1) == '-') { @@ -160,7 +160,7 @@ class Crop extends BaseSettings DI::baseUrl()->redirect($path); } - public static function content(array $parameters = []) + public function content(): string { if (!Session::isAuthenticated()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); @@ -168,7 +168,7 @@ class Crop extends BaseSettings parent::content(); - $resource_id = $parameters['guid']; + $resource_id = $this->parameters['guid']; $photos = Photo::selectToArray([], ['resource-id' => $resource_id, 'uid' => local_user()], ['order' => ['scale' => false]]); if (!DBA::isResult($photos)) { diff --git a/src/Module/Settings/Profile/Photo/Index.php b/src/Module/Settings/Profile/Photo/Index.php index cda71a7c69..2e65a01c61 100644 --- a/src/Module/Settings/Profile/Photo/Index.php +++ b/src/Module/Settings/Profile/Photo/Index.php @@ -34,7 +34,7 @@ use Friendica\Util\Strings; class Index extends BaseSettings { - public static function post(array $parameters = []) + public function post() { if (!Session::isAuthenticated()) { return; @@ -106,7 +106,7 @@ class Index extends BaseSettings DI::baseUrl()->redirect('settings/profile/photo/crop/' . $resource_id); } - public static function content(array $parameters = []) + public function content(): string { if (!Session::isAuthenticated()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Settings/TwoFactor/AppSpecific.php b/src/Module/Settings/TwoFactor/AppSpecific.php index 29d6b19c56..74a9ba6578 100644 --- a/src/Module/Settings/TwoFactor/AppSpecific.php +++ b/src/Module/Settings/TwoFactor/AppSpecific.php @@ -36,7 +36,7 @@ class AppSpecific extends BaseSettings { private static $appSpecificPassword = null; - public static function init(array $parameters = []) + public function init() { if (!local_user()) { return; @@ -54,7 +54,7 @@ class AppSpecific extends BaseSettings } } - public static function post(array $parameters = []) + public function post() { if (!local_user()) { return; @@ -97,13 +97,13 @@ class AppSpecific extends BaseSettings } } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { return Login::form('settings/2fa/app_specific'); } - parent::content($parameters); + parent::content(); $appSpecificPasswords = AppSpecificPassword::getListForUser(local_user()); diff --git a/src/Module/Settings/TwoFactor/Index.php b/src/Module/Settings/TwoFactor/Index.php index 3bb3a2aa1f..0dcef14ad9 100644 --- a/src/Module/Settings/TwoFactor/Index.php +++ b/src/Module/Settings/TwoFactor/Index.php @@ -33,7 +33,7 @@ use PragmaRX\Google2FA\Google2FA; class Index extends BaseSettings { - public static function post(array $parameters = []) + public function post() { if (!local_user()) { return; @@ -94,13 +94,13 @@ class Index extends BaseSettings } } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { return Login::form('settings/2fa'); } - parent::content($parameters); + parent::content(); $has_secret = (bool) DI::pConfig()->get(local_user(), '2fa', 'secret'); $verified = DI::pConfig()->get(local_user(), '2fa', 'verified'); diff --git a/src/Module/Settings/TwoFactor/Recovery.php b/src/Module/Settings/TwoFactor/Recovery.php index eac3da919a..d46f6a8f52 100644 --- a/src/Module/Settings/TwoFactor/Recovery.php +++ b/src/Module/Settings/TwoFactor/Recovery.php @@ -34,7 +34,7 @@ use Friendica\Module\Security\Login; */ class Recovery extends BaseSettings { - public static function init(array $parameters = []) + public function init() { if (!local_user()) { return; @@ -52,7 +52,7 @@ class Recovery extends BaseSettings } } - public static function post(array $parameters = []) + public function post() { if (!local_user()) { return; @@ -69,13 +69,13 @@ class Recovery extends BaseSettings } } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { return Login::form('settings/2fa/recovery'); } - parent::content($parameters); + parent::content(); if (!RecoveryCode::countValidForUser(local_user())) { RecoveryCode::generateForUser(local_user()); diff --git a/src/Module/Settings/TwoFactor/Trusted.php b/src/Module/Settings/TwoFactor/Trusted.php index 7532509417..d1e0c177a9 100644 --- a/src/Module/Settings/TwoFactor/Trusted.php +++ b/src/Module/Settings/TwoFactor/Trusted.php @@ -14,7 +14,7 @@ use UAParser\Parser; */ class Trusted extends BaseSettings { - public static function init(array $parameters = []) + public function init() { if (!local_user()) { return; @@ -32,7 +32,7 @@ class Trusted extends BaseSettings } } - public static function post(array $parameters = []) + public function post() { if (!local_user()) { return; @@ -64,9 +64,9 @@ class Trusted extends BaseSettings } - public static function content(array $parameters = []): string + public function content(): string { - parent::content($parameters); + parent::content(); $trustedBrowserRepository = new TwoFactor\Repository\TrustedBrowser(DI::dba(), DI::logger()); $trustedBrowsers = $trustedBrowserRepository->selectAllByUid(local_user()); diff --git a/src/Module/Settings/TwoFactor/Verify.php b/src/Module/Settings/TwoFactor/Verify.php index a4106c260c..18aa6ca9f0 100644 --- a/src/Module/Settings/TwoFactor/Verify.php +++ b/src/Module/Settings/TwoFactor/Verify.php @@ -39,7 +39,7 @@ use PragmaRX\Google2FA\Google2FA; */ class Verify extends BaseSettings { - public static function init(array $parameters = []) + public function init() { if (!local_user()) { return; @@ -58,7 +58,7 @@ class Verify extends BaseSettings } } - public static function post(array $parameters = []) + public function post() { if (!local_user()) { return; @@ -84,13 +84,13 @@ class Verify extends BaseSettings } } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { return Login::form('settings/2fa/verify'); } - parent::content($parameters); + parent::content(); $company = 'Friendica'; $holder = Session::get('my_address'); diff --git a/src/Module/Settings/UserExport.php b/src/Module/Settings/UserExport.php index aad76c4fbc..b5d79c4af5 100644 --- a/src/Module/Settings/UserExport.php +++ b/src/Module/Settings/UserExport.php @@ -47,18 +47,17 @@ class UserExport extends BaseSettings * If there is an action required through the URL / path, react * accordingly and export the requested data. * - * @param array $parameters Router-supplied parameters * @return string * @throws HTTPException\ForbiddenException * @throws HTTPException\InternalServerErrorException */ - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); } - parent::content($parameters); + parent::content(); /** * options shown on "Export personal data" page @@ -84,10 +83,9 @@ class UserExport extends BaseSettings * to the browser which then offers a save / open dialog * to the user. * - * @param array $parameters Router-supplied parameters * @throws HTTPException\ForbiddenException */ - public static function rawContent(array $parameters = []) + public function rawContent() { if (!DI::app()->isLoggedIn()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); diff --git a/src/Module/Smilies.php b/src/Module/Smilies.php index 8ee641b5a6..ded7980050 100644 --- a/src/Module/Smilies.php +++ b/src/Module/Smilies.php @@ -33,7 +33,7 @@ use Friendica\DI; */ class Smilies extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { if (!empty(DI::args()->getArgv()[1]) && (DI::args()->getArgv()[1] === "json")) { $smilies = Content\Smilies::getList(); @@ -45,7 +45,7 @@ class Smilies extends BaseModule } } - public static function content(array $parameters = []) + public function content(): string { $smilies = Content\Smilies::getList(); $count = count($smilies['texts'] ?? []); diff --git a/src/Module/Special/HTTPException.php b/src/Module/Special/HTTPException.php index 3b771c3ac7..44f48ff2eb 100644 --- a/src/Module/Special/HTTPException.php +++ b/src/Module/Special/HTTPException.php @@ -65,7 +65,7 @@ class HTTPException * @param \Friendica\Network\HTTPException $e * @throws \Exception */ - public static function rawContent(\Friendica\Network\HTTPException $e) + public function rawContent(\Friendica\Network\HTTPException $e) { $content = ''; @@ -84,7 +84,7 @@ class HTTPException * @return string * @throws \Exception */ - public static function content(\Friendica\Network\HTTPException $e) + public function content(\Friendica\Network\HTTPException $e): string { header($_SERVER["SERVER_PROTOCOL"] . ' ' . $e->getCode() . ' ' . $e->getDescription()); diff --git a/src/Module/Statistics.php b/src/Module/Statistics.php index e9d9eca020..a78031c369 100644 --- a/src/Module/Statistics.php +++ b/src/Module/Statistics.php @@ -28,14 +28,14 @@ use Friendica\Network\HTTPException\NotFoundException; class Statistics extends BaseModule { - public static function init(array $parameters = []) + public function init() { if (!DI::config()->get("system", "nodeinfo")) { throw new NotFoundException(); } } - public static function rawContent(array $parameters = []) + public function rawContent() { $config = DI::config(); $logger = DI::logger(); diff --git a/src/Module/Theme.php b/src/Module/Theme.php index 1282fc783f..6c164b5ba5 100644 --- a/src/Module/Theme.php +++ b/src/Module/Theme.php @@ -30,11 +30,11 @@ use Friendica\Util\Strings; */ class Theme extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { header('Content-Type: text/css'); - $theme = Strings::sanitizeFilePathItem($parameters['theme']); + $theme = Strings::sanitizeFilePathItem($this->parameters['theme']); if (file_exists("view/theme/$theme/theme.php")) { require_once "view/theme/$theme/theme.php"; diff --git a/src/Module/ThemeDetails.php b/src/Module/ThemeDetails.php index 48c4174128..5b931e1172 100644 --- a/src/Module/ThemeDetails.php +++ b/src/Module/ThemeDetails.php @@ -29,7 +29,7 @@ use Friendica\Core\Theme; */ class ThemeDetails extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { if (!empty($_REQUEST['theme'])) { $theme = $_REQUEST['theme']; diff --git a/src/Module/ToggleMobile.php b/src/Module/ToggleMobile.php index 11e8259d59..a0fb2f88f6 100644 --- a/src/Module/ToggleMobile.php +++ b/src/Module/ToggleMobile.php @@ -29,7 +29,7 @@ use Friendica\DI; */ class ToggleMobile extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $a = DI::app(); @@ -46,5 +46,7 @@ class ToggleMobile extends BaseModule } $a->redirect($address); + + return ''; } } diff --git a/src/Module/Tos.php b/src/Module/Tos.php index 34834d41c1..8357ead18a 100644 --- a/src/Module/Tos.php +++ b/src/Module/Tos.php @@ -41,8 +41,10 @@ class Tos extends BaseModule * be properties of the class, however cannot be set directly as the property * cannot depend on a function result when declaring the variable. **/ - public function __construct() + public function __construct(array $parameters = []) { + parent::__construct($parameters); + $this->privacy_operate = DI::l10n()->t('At the time of registration, and for providing communications between the user account and their contacts, the user has to provide a display name (pen name), an username (nickname) and a working email address. The names will be accessible on the profile page of the account by any visitor of the page, even if other profile details are not displayed. The email address will only be used to send the user notifications about interactions, but wont be visibly displayed. The listing of an account in the node\'s user directory or the global user directory is optional and can be controlled in the user settings, it is not necessary for communication.'); $this->privacy_distribute = DI::l10n()->t('This data is required for communication and is passed on to the nodes of the communication partners and is stored there. Users can enter additional private data that may be transmitted to the communication partners accounts.'); $this->privacy_delete = DI::l10n()->t('At any point in time a logged in user can export their account data from the account settings. If the user wants to delete their account they can do so at %1$s/removeme. The deletion of the account will be permanent. Deletion of the data will also be requested from the nodes of the communication partners.', DI::baseUrl()); @@ -58,7 +60,7 @@ class Tos extends BaseModule * dealings with their own node so a TOS is not necessary. * **/ - public static function init(array $parameters = []) + public function init() { if (strlen(DI::config()->get('system','singleuser'))) { DI::baseUrl()->redirect('profile/' . DI::config()->get('system','singleuser')); @@ -77,7 +79,7 @@ class Tos extends BaseModule * @return string * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function content(array $parameters = []) { + public function content(): string { $tpl = Renderer::getMarkupTemplate('tos.tpl'); if (DI::config()->get('system', 'tosdisplay')) { return Renderer::replaceMacros($tpl, [ @@ -90,7 +92,7 @@ class Tos extends BaseModule '$privacy_delete' => DI::l10n()->t('At any point in time a logged in user can export their account data from the account settings. If the user wants to delete their account they can do so at %1$s/removeme. The deletion of the account will be permanent. Deletion of the data will also be requested from the nodes of the communication partners.', DI::baseUrl()) ]); } else { - return; + return ''; } } } diff --git a/src/Module/Update/Community.php b/src/Module/Update/Community.php index 78d6f0bd35..07ed5a610f 100644 --- a/src/Module/Update/Community.php +++ b/src/Module/Update/Community.php @@ -33,9 +33,9 @@ use Friendica\Module\Conversation\Community as CommunityModule; */ class Community extends CommunityModule { - public static function rawContent(array $parameters = []) + public function rawContent() { - self::parseRequest($parameters); + $this->parseRequest(); $o = ''; if (!empty($_GET['force']) || !DI::pConfig()->get(local_user(), 'system', 'no_auto_update')) { diff --git a/src/Module/Update/Network.php b/src/Module/Update/Network.php index df37c82a81..3652b11263 100644 --- a/src/Module/Update/Network.php +++ b/src/Module/Update/Network.php @@ -9,13 +9,13 @@ use Friendica\Module\Conversation\Network as NetworkModule; class Network extends NetworkModule { - public static function rawContent(array $parameters = []) + public function rawContent() { if (!isset($_GET['p']) || !isset($_GET['item'])) { exit(); } - self::parseRequest($parameters, $_GET); + $this->parseRequest($_GET); $profile_uid = intval($_GET['p']); diff --git a/src/Module/Update/Profile.php b/src/Module/Update/Profile.php index cc738f501e..b06aea8044 100644 --- a/src/Module/Update/Profile.php +++ b/src/Module/Update/Profile.php @@ -35,7 +35,7 @@ use Friendica\Util\DateTimeFormat; class Profile extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $a = DI::app(); diff --git a/src/Module/Welcome.php b/src/Module/Welcome.php index 1c8209b59f..92845cdaff 100644 --- a/src/Module/Welcome.php +++ b/src/Module/Welcome.php @@ -30,7 +30,7 @@ use Friendica\DI; */ class Welcome extends BaseModule { - public static function content(array $parameters = []) + public function content(): string { $config = DI::config(); diff --git a/src/Module/WellKnown/HostMeta.php b/src/Module/WellKnown/HostMeta.php index 219eb3609b..a65b4db1a1 100644 --- a/src/Module/WellKnown/HostMeta.php +++ b/src/Module/WellKnown/HostMeta.php @@ -33,7 +33,7 @@ use Friendica\Util\Crypto; */ class HostMeta extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $config = DI::config(); diff --git a/src/Module/WellKnown/NodeInfo.php b/src/Module/WellKnown/NodeInfo.php index a8d0768929..a419792806 100644 --- a/src/Module/WellKnown/NodeInfo.php +++ b/src/Module/WellKnown/NodeInfo.php @@ -30,7 +30,7 @@ use Friendica\DI; */ class NodeInfo extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { self::printWellKnown(); } diff --git a/src/Module/WellKnown/SecurityTxt.php b/src/Module/WellKnown/SecurityTxt.php index c0cdc4e515..73a627c2e7 100644 --- a/src/Module/WellKnown/SecurityTxt.php +++ b/src/Module/WellKnown/SecurityTxt.php @@ -29,7 +29,7 @@ use Friendica\BaseModule; */ class SecurityTxt extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $name = 'security.txt'; $fp = fopen($name, 'rt'); diff --git a/src/Module/WellKnown/XSocialRelay.php b/src/Module/WellKnown/XSocialRelay.php index 96968680dc..c401825236 100644 --- a/src/Module/WellKnown/XSocialRelay.php +++ b/src/Module/WellKnown/XSocialRelay.php @@ -32,7 +32,7 @@ use Friendica\Protocol\Relay; */ class XSocialRelay extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { $config = DI::config(); diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index 66404f4567..4a8e32e8ea 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -36,7 +36,7 @@ use Friendica\Protocol\Salmon; */ class Xrd extends BaseModule { - public static function rawContent(array $parameters = []) + public function rawContent() { // @TODO: Replace with parameter from router if (DI::args()->getArgv()[0] == 'xrd') { diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 57ef629bb2..28d26b4e7b 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -181,10 +181,10 @@ return [ ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL], ], ], - App\Module::class => [ - 'instanceOf' => App\Module::class, + App\ModuleController::class => [ + 'instanceOf' => App\ModuleController::class, 'call' => [ - ['determineModule', [], Dice::CHAIN_CALL], + ['determineName', [], Dice::CHAIN_CALL], ], ], \Friendica\Core\System::class => [ diff --git a/tests/datasets/legacy/legacy.php b/tests/datasets/legacy/legacy.php new file mode 100644 index 0000000000..4b0a76e609 --- /dev/null +++ b/tests/datasets/legacy/legacy.php @@ -0,0 +1,6 @@ +determineRunMode(true, $module, $server, $mobileDetect); @@ -218,7 +218,7 @@ class ModeTest extends MockedTest public function testIsBackendButIndex() { $server = []; - $module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], true); + $module = new ModuleController(ModuleController::DEFAULT, null, true); $mobileDetect = new MobileDetect(); $mode = (new Mode())->determineRunMode(false, $module, $server, $mobileDetect); @@ -232,7 +232,7 @@ class ModeTest extends MockedTest public function testIsNotBackend() { $server = []; - $module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false); + $module = new ModuleController(ModuleController::DEFAULT, null, false); $mobileDetect = new MobileDetect(); $mode = (new Mode())->determineRunMode(false, $module, $server, $mobileDetect); @@ -250,7 +250,7 @@ class ModeTest extends MockedTest 'HTTP_X_REQUESTED_WITH' => 'xmlhttprequest', ]; - $module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false); + $module = new ModuleController(ModuleController::DEFAULT, null, false); $mobileDetect = new MobileDetect(); $mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect); @@ -264,7 +264,7 @@ class ModeTest extends MockedTest public function testIsNotAjax() { $server = []; - $module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false); + $module = new ModuleController(ModuleController::DEFAULT, null, false); $mobileDetect = new MobileDetect(); $mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect); @@ -278,7 +278,7 @@ class ModeTest extends MockedTest public function testIsMobileIsTablet() { $server = []; - $module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false); + $module = new ModuleController(ModuleController::DEFAULT, null, false); $mobileDetect = Mockery::mock(MobileDetect::class); $mobileDetect->shouldReceive('isMobile')->andReturn(true); $mobileDetect->shouldReceive('isTablet')->andReturn(true); @@ -296,7 +296,7 @@ class ModeTest extends MockedTest public function testIsNotMobileIsNotTablet() { $server = []; - $module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false); + $module = new ModuleController(ModuleController::DEFAULT, null, false); $mobileDetect = Mockery::mock(MobileDetect::class); $mobileDetect->shouldReceive('isMobile')->andReturn(false); $mobileDetect->shouldReceive('isTablet')->andReturn(false); diff --git a/tests/src/App/ModuleTest.php b/tests/src/App/ModuleControllerTest.php similarity index 71% rename from tests/src/App/ModuleTest.php rename to tests/src/App/ModuleControllerTest.php index c5d4e11faa..13ef16a6d4 100644 --- a/tests/src/App/ModuleTest.php +++ b/tests/src/App/ModuleControllerTest.php @@ -21,6 +21,7 @@ namespace Friendica\Test\src\App; +use Dice\Dice; use Friendica\App; use Friendica\Core\Cache\Capability\ICanCache; use Friendica\Core\Config\Capability\IManageConfigValues; @@ -32,13 +33,13 @@ use Friendica\Module\WellKnown\HostMeta; use Friendica\Test\DatabaseTest; use Mockery; -class ModuleTest extends DatabaseTest +class ModuleControllerTest extends DatabaseTest { - private function assertModule(array $assert, App\Module $module) + private function assertModule(array $assert, App\ModuleController $module) { self::assertEquals($assert['isBackend'], $module->isBackend()); self::assertEquals($assert['name'], $module->getName()); - self::assertEquals($assert['class'], $module->getClassName()); + self::assertEquals($assert['class'], $module->getModule()); } /** @@ -46,23 +47,27 @@ class ModuleTest extends DatabaseTest */ public function testDefault() { - $module = new App\Module(); + $module = new App\ModuleController(); + + $defaultClass = App\ModuleController::DEFAULT_CLASS; self::assertModule([ 'isBackend' => false, - 'name' => App\Module::DEFAULT, - 'class' => App\Module::DEFAULT_CLASS, + 'name' => App\ModuleController::DEFAULT, + 'class' => new $defaultClass(), ], $module); } public function dataModuleName() { + $defaultClass = App\ModuleController::DEFAULT_CLASS; + return [ 'default' => [ 'assert' => [ 'isBackend' => false, 'name' => 'network', - 'class' => App\Module::DEFAULT_CLASS, + 'class' => new $defaultClass(), ], 'args' => new App\Arguments('network/data/in', 'network/data/in', @@ -73,7 +78,7 @@ class ModuleTest extends DatabaseTest 'assert' => [ 'isBackend' => false, 'name' => 'with_strike_and_point', - 'class' => App\Module::DEFAULT_CLASS, + 'class' => new $defaultClass(), ], 'args' => new App\Arguments('with-strike.and-point/data/in', 'with-strike.and-point/data/in', @@ -83,35 +88,35 @@ class ModuleTest extends DatabaseTest 'withNothing' => [ 'assert' => [ 'isBackend' => false, - 'name' => App\Module::DEFAULT, - 'class' => App\Module::DEFAULT_CLASS, + 'name' => App\ModuleController::DEFAULT, + 'class' => new $defaultClass(), ], 'args' => new App\Arguments(), ], 'withIndex' => [ 'assert' => [ 'isBackend' => false, - 'name' => App\Module::DEFAULT, - 'class' => App\Module::DEFAULT_CLASS, + 'name' => App\ModuleController::DEFAULT, + 'class' => new $defaultClass(), ], 'args' => new App\Arguments(), ], 'withBackendMod' => [ 'assert' => [ 'isBackend' => true, - 'name' => App\Module::BACKEND_MODULES[0], - 'class' => App\Module::DEFAULT_CLASS, + 'name' => App\ModuleController::BACKEND_MODULES[0], + 'class' => new $defaultClass(), ], - 'args' => new App\Arguments(App\Module::BACKEND_MODULES[0] . '/data/in', - App\Module::BACKEND_MODULES[0] . '/data/in', - [App\Module::BACKEND_MODULES[0], 'data', 'in'], + 'args' => new App\Arguments(App\ModuleController::BACKEND_MODULES[0] . '/data/in', + App\ModuleController::BACKEND_MODULES[0] . '/data/in', + [App\ModuleController::BACKEND_MODULES[0], 'data', 'in'], 3), ], 'withFirefoxApp' => [ 'assert' => [ 'isBackend' => false, 'name' => 'login', - 'class' => App\Module::DEFAULT_CLASS, + 'class' => new $defaultClass(), ], 'args' => new App\Arguments('users/sign_in', 'users/sign_in', @@ -128,7 +133,7 @@ class ModuleTest extends DatabaseTest */ public function testModuleName(array $assert, App\Arguments $args) { - $module = (new App\Module())->determineModule($args); + $module = (new App\ModuleController())->determineName($args); self::assertModule($assert, $module); } @@ -137,28 +142,32 @@ class ModuleTest extends DatabaseTest { return [ 'default' => [ - 'assert' => App\Module::DEFAULT_CLASS, - 'name' => App\Module::DEFAULT, - 'command' => App\Module::DEFAULT, + 'assert' => App\ModuleController::DEFAULT_CLASS, + 'name' => App\ModuleController::DEFAULT, + 'command' => App\ModuleController::DEFAULT, 'privAdd' => false, + 'args' => [], ], 'legacy' => [ 'assert' => LegacyModule::class, 'name' => 'display', 'command' => 'display/test/it', 'privAdd' => false, + 'args' => [__DIR__ . '/../../datasets/legacy/legacy.php'], ], 'new' => [ 'assert' => HostMeta::class, 'not_required', 'command' => '.well-known/host-meta', 'privAdd' => false, + 'args' => [], ], '404' => [ 'assert' => PageNotFound::class, 'name' => 'invalid', 'command' => 'invalid', 'privAdd' => false, + 'args' => [], ] ]; } @@ -168,7 +177,7 @@ class ModuleTest extends DatabaseTest * * @dataProvider dataModuleClass */ - public function testModuleClass($assert, string $name, string $command, bool $privAdd) + public function testModuleClass($assert, string $name, string $command, bool $privAdd, array $args) { $config = Mockery::mock(IManageConfigValues::class); $config->shouldReceive('get')->with('config', 'private_addons', false)->andReturn($privAdd)->atMost()->once(); @@ -187,9 +196,13 @@ class ModuleTest extends DatabaseTest $router = (new App\Router([], __DIR__ . '/../../../static/routes.config.php', $l10n, $cache, $lock)); - $module = (new App\Module($name))->determineClass(new App\Arguments('', $command), $router, $config); + $dice = Mockery::mock(Dice::class); - self::assertEquals($assert, $module->getClassName()); + $dice->shouldReceive('create')->andReturn(new $assert(...$args)); + + $module = (new App\ModuleController($name))->determineClass(new App\Arguments('', $command), $router, $config, $dice); + + self::assertEquals($assert, $module->getModule()->getClassName()); } /** @@ -197,9 +210,9 @@ class ModuleTest extends DatabaseTest */ public function testImmutable() { - $module = new App\Module(); + $module = new App\ModuleController(); - $moduleNew = $module->determineModule(new App\Arguments()); + $moduleNew = $module->determineName(new App\Arguments()); self::assertNotSame($moduleNew, $module); } diff --git a/tests/src/Module/Api/Friendica/NotificationTest.php b/tests/src/Module/Api/Friendica/NotificationTest.php index 7a213e2a5b..7f1fd701fa 100644 --- a/tests/src/Module/Api/Friendica/NotificationTest.php +++ b/tests/src/Module/Api/Friendica/NotificationTest.php @@ -67,14 +67,16 @@ class NotificationTest extends ApiTest XML; - Notification::rawContent(['extension' => 'xml']); + $notification = new Notification(['extension' => 'xml']); + $notification->rawContent(); self::assertXmlStringEqualsXmlString($assertXml, ApiResponseDouble::getOutput()); } public function testWithJsonResult() { - Notification::rawContent(['parameter' => 'json']); + $notification = new Notification(['parameter' => 'json']); + $notification->rawContent(); $result = json_encode(ApiResponseDouble::getOutput()); diff --git a/tests/src/Module/Api/Friendica/Photo/DeleteTest.php b/tests/src/Module/Api/Friendica/Photo/DeleteTest.php index 3fd1d92f72..5581c9cc2e 100644 --- a/tests/src/Module/Api/Friendica/Photo/DeleteTest.php +++ b/tests/src/Module/Api/Friendica/Photo/DeleteTest.php @@ -30,7 +30,7 @@ class DeleteTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - Delete::rawContent(); + (new Delete())->rawContent(); } public function testWithoutAuthenticatedUser() @@ -41,7 +41,7 @@ class DeleteTest extends ApiTest public function testWrong() { $this->expectException(BadRequestException::class); - Delete::rawContent(['photo_id' => 1]); + (new Delete(['photo_id' => 1]))->rawContent(); } public function testWithCorrectPhotoId() diff --git a/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php b/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php index f99e61bd1b..6ee3c5e7b5 100644 --- a/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php +++ b/tests/src/Module/Api/Friendica/Photoalbum/DeleteTest.php @@ -30,13 +30,13 @@ class DeleteTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - Delete::rawContent(); + (new Delete())->rawContent(); } public function testWrong() { $this->expectException(BadRequestException::class); - Delete::rawContent(['album' => 'album_name']); + (new Delete(['album' => 'album_name']))->rawContent(); } public function testValid() diff --git a/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php b/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php index b07d4c5bcf..c7d65cb16b 100644 --- a/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php +++ b/tests/src/Module/Api/Friendica/Photoalbum/UpdateTest.php @@ -30,19 +30,19 @@ class UpdateTest extends ApiTest public function testEmpty() { $this->expectException(BadRequestException::class); - Update::rawContent(); + (new Update())->rawContent(); } public function testTooFewArgs() { $this->expectException(BadRequestException::class); - Update::rawContent(['album' => 'album_name']); + (new Update(['album' => 'album_name']))->rawContent(); } public function testWrongUpdate() { $this->expectException(BadRequestException::class); - Update::rawContent(['album' => 'album_name', 'album_new' => 'album_name']); + (new Update(['album' => 'album_name', 'album_new' => 'album_name']))->rawContent(); } public function testWithoutAuthenticatedUser() diff --git a/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php b/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php index 454b8ef40d..a819a7a1e6 100644 --- a/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php +++ b/tests/src/Module/Api/GnuSocial/GnuSocial/VersionTest.php @@ -10,7 +10,8 @@ class VersionTest extends ApiTest { public function test() { - Version::rawContent(['extension' => 'json']); + $version = new Version(['extension' => 'json']); + $version->rawContent(); $result = json_decode(ApiResponseDouble::getOutput()); diff --git a/tests/src/Module/Api/GnuSocial/Help/TestTest.php b/tests/src/Module/Api/GnuSocial/Help/TestTest.php index c962cac302..c624ca0326 100644 --- a/tests/src/Module/Api/GnuSocial/Help/TestTest.php +++ b/tests/src/Module/Api/GnuSocial/Help/TestTest.php @@ -10,14 +10,16 @@ class TestTest extends ApiTest { public function testJson() { - Test::rawContent(['extension' => 'json']); + $test = new Test(['extension' => 'json']); + $test->rawContent(); self::assertEquals('"ok"', ApiResponseDouble::getOutput()); } public function testXml() { - Test::rawContent(['extension' => 'xml']); + $test = new Test(['extension' => 'xml']); + $test->rawContent(); self::assertxml(ApiResponseDouble::getOutput(), 'ok'); } diff --git a/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php b/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php index 46088d330f..3a84324af5 100644 --- a/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php +++ b/tests/src/Module/Api/Twitter/Account/RateLimitStatusTest.php @@ -10,7 +10,8 @@ class RateLimitStatusTest extends ApiTest { public function testWithJson() { - RateLimitStatus::rawContent(['extension' => 'json']); + $rateLimitStatus = new RateLimitStatus(['extension' => 'json']); + $rateLimitStatus->rawContent(); $result = json_decode(ApiResponseDouble::getOutput()); @@ -21,7 +22,8 @@ class RateLimitStatusTest extends ApiTest public function testWithXml() { - RateLimitStatus::rawContent(['extension' => 'xml']); + $rateLimitStatus = new RateLimitStatus(['extension' => 'xml']); + $rateLimitStatus->rawContent(); self::assertXml(ApiResponseDouble::getOutput(), 'hash'); } diff --git a/tests/src/Module/Api/Twitter/SavedSearchesTest.php b/tests/src/Module/Api/Twitter/SavedSearchesTest.php index f4dad04fc1..fc0f80467b 100644 --- a/tests/src/Module/Api/Twitter/SavedSearchesTest.php +++ b/tests/src/Module/Api/Twitter/SavedSearchesTest.php @@ -10,7 +10,8 @@ class SavedSearchesTest extends ApiTest { public function test() { - SavedSearches::rawContent(['extension' => 'json']); + $savedSearch = new SavedSearches(['extension' => 'json']); + $savedSearch->rawContent(); $result = json_decode(ApiResponseDouble::getOutput());