From 388b963714895b6aee59648084fe4a66a0964efc Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Sun, 15 Dec 2019 23:28:01 +0100 Subject: [PATCH] Replace BaseObject class with DI::* calls --- bin/auth_ejabberd.php | 3 +- bin/daemon.php | 2 +- bin/worker.php | 3 +- boot.php | 1 - include/api.php | 16 +--- include/conversation.php | 19 ++-- include/items.php | 5 -- index.php | 2 +- mod/dfrn_poll.php | 7 +- mod/events.php | 5 +- mod/item.php | 10 +-- mod/lockview.php | 6 +- mod/network.php | 12 +-- mod/notifications.php | 4 +- mod/photos.php | 12 +-- mod/settings.php | 7 +- src/App/Module.php | 4 +- src/BaseModule.php | 2 +- src/BaseObject.php | 58 ------------ src/Content/Text/BBCode.php | 3 +- src/Content/Text/Markdown.php | 3 +- src/Core/ACL.php | 3 +- src/Core/Addon.php | 3 +- src/Core/Cache.php | 15 ++-- src/Core/Config.php | 13 ++- src/Core/Console.php | 2 +- src/Core/Hook.php | 3 +- src/Core/L10n.php | 18 ++-- src/Core/Lock.php | 13 ++- src/Core/Logger.php | 38 +++++--- src/Core/PConfig.php | 13 ++- src/Core/Renderer.php | 3 +- src/Core/Search.php | 3 +- src/Core/Session.php | 29 +++--- src/Core/System.php | 7 +- src/Core/Theme.php | 1 - src/Core/Worker.php | 1 - src/DI.php | 89 +++++++++++++++++++ src/Database/DBA.php | 78 ++++++++-------- src/Model/APContact.php | 3 +- src/Model/Attach.php | 3 +- src/Model/Contact.php | 4 +- src/Model/Event.php | 3 +- src/Model/Group.php | 3 +- src/Model/Item.php | 10 +-- src/Model/ItemContent.php | 3 +- src/Model/ItemURI.php | 3 +- src/Model/Nodeinfo.php | 3 +- src/Model/Notify.php | 3 +- src/Model/PermissionSet.php | 3 +- src/Model/Photo.php | 3 +- src/Model/Process.php | 3 +- src/Model/Search.php | 3 +- src/Model/TwoFactor/AppSpecificPassword.php | 3 +- src/Model/TwoFactor/RecoveryCode.php | 3 +- src/Module/Admin/Summary.php | 3 +- src/Module/Api/Mastodon/FollowRequests.php | 5 +- src/Module/Base/Api.php | 8 +- src/Module/BaseSearchModule.php | 3 +- src/Module/Delegation.php | 5 +- src/Module/Diaspora/Receive.php | 15 ++-- src/Module/Item/Compose.php | 3 +- src/Module/Item/Ignore.php | 9 +- src/Module/Notifications/Notify.php | 9 +- src/Module/Profile.php | 5 +- src/Module/Register.php | 2 +- src/Module/Search/Index.php | 4 +- src/Module/Search/Saved.php | 6 +- src/Module/Security/Login.php | 9 +- src/Module/Security/TwoFactor/Recovery.php | 5 +- src/Module/Security/TwoFactor/Verify.php | 4 +- src/Module/Settings/Delegation.php | 3 +- src/Module/Settings/UserExport.php | 2 +- src/Network/FKOAuth1.php | 7 +- src/Object/Post.php | 12 +-- src/Object/Thread.php | 3 +- src/Protocol/ActivityPub/Transmitter.php | 1 - src/Protocol/DFRN.php | 7 +- src/Util/Images.php | 1 - src/Util/Proxy.php | 1 - src/Util/Security.php | 3 +- src/Worker/APDelivery.php | 3 +- src/Worker/Cron.php | 1 - src/Worker/CronJobs.php | 1 - src/Worker/DBUpdate.php | 3 +- src/Worker/Delivery.php | 3 +- src/Worker/Expire.php | 1 - src/Worker/Notifier.php | 4 +- src/Worker/OnePoll.php | 2 - src/Worker/ProfileUpdate.php | 1 - tests/Util/AppMockTrait.php | 4 +- tests/include/ApiTest.php | 6 +- .../AutomaticInstallationConsoleTest.php | 4 +- tests/src/Core/InstallerTest.php | 5 +- tests/src/Core/Lock/SemaphoreLockTest.php | 4 +- tests/src/Database/DBATest.php | 4 +- tests/src/Database/DBStructureTest.php | 4 +- tests/src/Network/CurlResultTest.php | 4 +- 98 files changed, 321 insertions(+), 440 deletions(-) delete mode 100644 src/BaseObject.php diff --git a/bin/auth_ejabberd.php b/bin/auth_ejabberd.php index 5ccdd0174b..13dc6eeba0 100755 --- a/bin/auth_ejabberd.php +++ b/bin/auth_ejabberd.php @@ -34,7 +34,6 @@ use Dice\Dice; use Friendica\App\Mode; -use Friendica\BaseObject; use Friendica\Util\ExAuth; use Psr\Log\LoggerInterface; @@ -57,7 +56,7 @@ require dirname(__DIR__) . '/vendor/autoload.php'; $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php'); $dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['auth_ejabberd']]); -BaseObject::setDependencyInjection($dice); +\Friendica\DI::init($dice); $appMode = $dice->create(Mode::class); diff --git a/bin/daemon.php b/bin/daemon.php index b3166145b8..039a40cf06 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -36,7 +36,7 @@ require dirname(__DIR__) . '/vendor/autoload.php'; $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php'); $dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['daemon']]); -\Friendica\BaseObject::setDependencyInjection($dice); +\Friendica\DI::init($dice); $a = \Friendica\DI::app(); if ($a->getMode()->isInstall()) { diff --git a/bin/worker.php b/bin/worker.php index 1de90d8cae..e156170490 100755 --- a/bin/worker.php +++ b/bin/worker.php @@ -7,7 +7,6 @@ use Dice\Dice; use Friendica\App; -use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Core\Update; use Friendica\Core\Worker; @@ -35,7 +34,7 @@ require dirname(__DIR__) . '/vendor/autoload.php'; $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php'); $dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['worker']]); -BaseObject::setDependencyInjection($dice); +\Friendica\DI::init($dice); $a = Friendica\DI::app(); // Check the database structure and possibly fixes it diff --git a/boot.php b/boot.php index 2dcc15f7d3..ecf83854ff 100644 --- a/boot.php +++ b/boot.php @@ -18,7 +18,6 @@ */ use Friendica\App; -use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Core\PConfig; use Friendica\Core\Protocol; diff --git a/include/api.php b/include/api.php index 916051f06c..363a0b9700 100644 --- a/include/api.php +++ b/include/api.php @@ -7,12 +7,10 @@ */ use Friendica\App; -use Friendica\BaseObject; use Friendica\Content\ContactSelector; use Friendica\Content\Feature; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; -use Friendica\App\Authentication; use Friendica\Core\Config; use Friendica\Core\Hook; use Friendica\Core\L10n; @@ -23,11 +21,11 @@ use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\Mail; -use Friendica\Model\Notify; use Friendica\Model\Photo; use Friendica\Model\Profile; use Friendica\Model\User; @@ -254,9 +252,7 @@ function api_login(App $a) throw new UnauthorizedException("This API requires login"); } - /** @var Authentication $authentication */ - $authentication = BaseObject::getClass(Authentication::class); - $authentication->setForUser($a, $record); + DI::auth()->setForUser($a, $record); $_SESSION["allow_api"] = true; @@ -5909,10 +5905,7 @@ function api_friendica_notification($type) if ($a->argc!==3) { throw new BadRequestException("Invalid argument count"); } - /** @var Notify $nm */ - $nm = BaseObject::getClass(Notify::class); - - $notes = $nm->getAll([], ['seen' => 'ASC', 'date' => 'DESC'], 50); + $notes = DI::notify()->getAll([], ['seen' => 'ASC', 'date' => 'DESC'], 50); if ($type == "xml") { $xmlnotes = []; @@ -5954,8 +5947,7 @@ function api_friendica_notification_seen($type) $id = (!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0); - /** @var Notify $nm */ - $nm = BaseObject::getClass(Notify::class); + $nm = DI::notify(); $note = $nm->getByID($id); if (is_null($note)) { throw new BadRequestException("Invalid argument"); diff --git a/include/conversation.php b/include/conversation.php index b27cfe0c81..9e22c958b5 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -4,10 +4,8 @@ */ use Friendica\App; -use Friendica\BaseObject; use Friendica\Content\ContactSelector; use Friendica\Content\Feature; -use Friendica\Content\Item as ContentItem; use Friendica\Content\Pager; use Friendica\Content\Text\BBCode; use Friendica\Core\Config; @@ -20,6 +18,7 @@ use Friendica\Core\Renderer; use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; use Friendica\Model\Profile; @@ -141,8 +140,7 @@ function localize_item(&$item) During the further steps of the database restructuring I would like to address this issue. */ - /** @var Activity $activity */ - $activity = BaseObject::getClass(Activity::class); + $activity = DI::activity(); $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; if ($activity->match($item['verb'], Activity::LIKE) @@ -399,8 +397,7 @@ function count_descendants($item) { function visible_activity($item) { - /** @var Activity $activity */ - $activity = BaseObject::getClass(Activity::class); + $activity = DI::activity(); if (empty($item['verb']) || $activity->isHidden($item['verb'])) { return false; @@ -668,10 +665,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ $body = Item::prepareBody($item, true, $preview); - /** @var ContentItem $contItem */ - $contItem = BaseObject::getClass(ContentItem::class); - - list($categories, $folders) = $contItem->determineCategoriesTerms($item); + list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item); if (!empty($item['content-warning']) && PConfig::get(local_user(), 'system', 'disable_cw', false)) { $title = ucfirst($item['content-warning']); @@ -1031,10 +1025,7 @@ function builtin_activity_puller($item, &$conv_responses) { return; } - /** @var Activity $activity */ - $activity = BaseObject::getClass(Activity::class); - - if (!empty($item['verb']) && $activity->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) { + if (!empty($item['verb']) && DI::activity()->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) { $author = ['uid' => 0, 'id' => $item['author-id'], 'network' => $item['author-network'], 'url' => $item['author-link']]; $url = Contact::magicLinkByContact($author); diff --git a/include/items.php b/include/items.php index a449571ff7..5ae8558d81 100644 --- a/include/items.php +++ b/include/items.php @@ -3,13 +3,10 @@ * @file include/items.php */ -use Friendica\BaseObject; -use Friendica\Content\Feature; use Friendica\Core\Config; use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Logger; -use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\System; @@ -19,11 +16,9 @@ use Friendica\Model\Item; use Friendica\Protocol\DFRN; use Friendica\Protocol\Feed; use Friendica\Protocol\OStatus; -use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\ParseUrl; use Friendica\Util\Strings; -use Friendica\Util\Temporal; require_once __DIR__ . '/../mod/share.php'; diff --git a/index.php b/index.php index a7eee2a331..b558e86c8e 100644 --- a/index.php +++ b/index.php @@ -15,7 +15,7 @@ require __DIR__ . '/vendor/autoload.php'; $dice = (new Dice())->addRules(include __DIR__ . '/static/dependencies.config.php'); $dice = $dice->addRule(Friendica\App\Mode::class, ['call' => [['determineRunMode', [false, $_SERVER], Dice::CHAIN_CALL]]]); -\Friendica\BaseObject::setDependencyInjection($dice); +\Friendica\DI::init($dice); $a = \Friendica\DI::app(); diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 0641b9177b..7ebca9effa 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -5,14 +5,13 @@ */ use Friendica\App; -use Friendica\BaseObject; -use Friendica\App\Authentication; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Core\Session; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Module\Security\Login; use Friendica\Protocol\DFRN; use Friendica\Protocol\OStatus; @@ -22,9 +21,7 @@ use Friendica\Util\XML; function dfrn_poll_init(App $a) { - /** @var Authentication $authentication */ - $authentication = BaseObject::getClass(Authentication::class); - $authentication->withSession($a); + DI::auth()->withSession($a); $dfrn_id = $_GET['dfrn_id'] ?? ''; $type = ($_GET['type'] ?? '') ?: 'data'; diff --git a/mod/events.php b/mod/events.php index 6547a9b9ce..1a8eccde11 100644 --- a/mod/events.php +++ b/mod/events.php @@ -5,7 +5,6 @@ */ use Friendica\App; -use Friendica\BaseObject; use Friendica\Content\Nav; use Friendica\Content\Widget\CalendarExport; use Friendica\Core\ACL; @@ -19,6 +18,7 @@ use Friendica\Database\DBA; use Friendica\Model\Event; use Friendica\Model\Item; use Friendica\Model\Profile; +use Friendica\Module\Login; use Friendica\Module\Security\Login; use Friendica\Util\ACLFormatter; use Friendica\Util\DateTimeFormat; @@ -150,8 +150,7 @@ function events_post(App $a) if ($share) { - /** @var ACLFormatter $aclFormatter */ - $aclFormatter = BaseObject::getClass(ACLFormatter::class); + $aclFormatter = \Friendica\DI::aclFormatter(); $str_group_allow = $aclFormatter->toString($_POST['group_allow'] ?? ''); $str_contact_allow = $aclFormatter->toString($_POST['contact_allow'] ?? ''); diff --git a/mod/item.php b/mod/item.php index 93da70e40e..e20fb99521 100644 --- a/mod/item.php +++ b/mod/item.php @@ -16,7 +16,6 @@ */ use Friendica\App; -use Friendica\BaseObject; use Friendica\Content\Pager; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; @@ -29,6 +28,7 @@ use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Attach; use Friendica\Model\Contact; use Friendica\Model\Conversation; @@ -39,7 +39,6 @@ use Friendica\Model\Term; use Friendica\Protocol\Activity; use Friendica\Protocol\Diaspora; use Friendica\Protocol\Email; -use Friendica\Util\ACLFormatter; use Friendica\Util\DateTimeFormat; use Friendica\Util\Emailer; use Friendica\Util\Security; @@ -273,8 +272,7 @@ function item_post(App $a) { } else { // use the posted permissions - /** @var ACLFormatter $aclFormatter */ - $aclFormatter = BaseObject::getClass(ACLFormatter::class); + $aclFormatter = DI::aclFormatter(); $str_group_allow = $aclFormatter->toString($_REQUEST['group_allow'] ?? ''); $str_contact_allow = $aclFormatter->toString($_REQUEST['contact_allow'] ?? ''); @@ -506,9 +504,7 @@ function item_post(App $a) { $objecttype = Activity\ObjectType::BOOKMARK; } - /** @var BBCode\Video $bbCodeVideo */ - $bbCodeVideo = BaseObject::getClass(BBCode\Video::class); - $body = $bbCodeVideo->transform($body); + $body = DI::bbCodeVideo()->transform($body); // Fold multi-line [code] sequences $body = preg_replace('/\[\/code\]\s*\[code\]/ism', "\n", $body); diff --git a/mod/lockview.php b/mod/lockview.php index 9f9dcfea42..fc9fed3066 100644 --- a/mod/lockview.php +++ b/mod/lockview.php @@ -3,13 +3,12 @@ * @file mod/lockview.php */ use Friendica\App; -use Friendica\BaseObject; use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Group; use Friendica\Model\Item; -use Friendica\Util\ACLFormatter; function lockview_content(App $a) { @@ -61,8 +60,7 @@ function lockview_content(App $a) exit(); } - /** @var ACLFormatter $aclFormatter */ - $aclFormatter = BaseObject::getClass(ACLFormatter::class); + $aclFormatter = DI::aclFormatter(); $allowed_users = $aclFormatter->expand($item['allow_cid']); $allowed_groups = $aclFormatter->expand($item['allow_gid']); diff --git a/mod/network.php b/mod/network.php index 5d8656cd35..0376203401 100644 --- a/mod/network.php +++ b/mod/network.php @@ -5,7 +5,6 @@ */ use Friendica\App; -use Friendica\BaseObject; use Friendica\Content\Feature; use Friendica\Content\ForumManager; use Friendica\Content\Nav; @@ -22,6 +21,7 @@ use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Session; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Item; @@ -52,12 +52,9 @@ function network_init(App $a) $group_id = 0; } - /** @var DateTimeFormat $dtFormat */ - $dtFormat = BaseObject::getClass(DateTimeFormat::class); - if ($a->argc > 1) { for ($x = 1; $x < $a->argc; $x ++) { - if ($dtFormat->isYearMonth($a->argv[$x])) { + if (DI::dtFormat()->isYearMonth($a->argv[$x])) { $is_a_date_query = true; break; } @@ -465,12 +462,9 @@ function networkThreadedView(App $a, $update, $parent) $default_permissions = []; - /** @var DateTimeFormat $dtFormat */ - $dtFormat = BaseObject::getClass(DateTimeFormat::class); - if ($a->argc > 1) { for ($x = 1; $x < $a->argc; $x ++) { - if ($dtFormat->isYearMonth($a->argv[$x])) { + if (DI::dtFormat()->isYearMonth($a->argv[$x])) { if ($datequery) { $datequery2 = Strings::escapeHtml($a->argv[$x]); } else { diff --git a/mod/notifications.php b/mod/notifications.php index 502a2397de..51b4d80873 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -13,6 +13,7 @@ use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Module\Security\Login; use Friendica\Model\Introduction; use Friendica\Model\Notify; @@ -61,8 +62,7 @@ function notifications_content(App $a) $json = (($a->argc > 1 && $a->argv[$a->argc - 1] === 'json') ? true : false); - /** @var Notify $nm */ - $nm = \Friendica\BaseObject::getClass(Notify::class); + $nm = DI::notify(); $o = ''; // Get the nav tabs for the notification pages diff --git a/mod/photos.php b/mod/photos.php index 1d7ce7b3de..a3d81c041d 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -4,7 +4,6 @@ */ use Friendica\App; -use Friendica\BaseObject; use Friendica\Content\Feature; use Friendica\Content\Nav; use Friendica\Content\Pager; @@ -18,6 +17,7 @@ use Friendica\Core\Renderer; use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; use Friendica\Model\Photo; @@ -26,7 +26,6 @@ use Friendica\Model\User; use Friendica\Network\Probe; use Friendica\Object\Image; use Friendica\Protocol\Activity; -use Friendica\Util\ACLFormatter; use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; use Friendica\Util\Images; @@ -298,8 +297,7 @@ function photos_post(App $a) $albname = !empty($_POST['albname']) ? Strings::escapeTags(trim($_POST['albname'])) : ''; $origaname = !empty($_POST['origaname']) ? Strings::escapeTags(trim($_POST['origaname'])) : ''; - /** @var ACLFormatter $aclFormatter */ - $aclFormatter = BaseObject::getClass(ACLFormatter::class); + $aclFormatter = DI::aclFormatter(); $str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->toString($_POST['group_allow']) : ''; $str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->toString($_POST['contact_allow']) : ''; @@ -640,8 +638,7 @@ function photos_post(App $a) $group_deny = $_REQUEST['group_deny'] ?? []; $contact_deny = $_REQUEST['contact_deny'] ?? []; - /** @var ACLFormatter $aclFormatter */ - $aclFormatter = BaseObject::getClass(ACLFormatter::class); + $aclFormatter = DI::aclFormatter(); $str_group_allow = $aclFormatter->toString(is_array($group_allow) ? $group_allow : explode(',', $group_allow)); $str_contact_allow = $aclFormatter->toString(is_array($contact_allow) ? $contact_allow : explode(',', $contact_allow)); @@ -1442,8 +1439,7 @@ function photos_content(App $a) $template = $tpl; $sparkle = ''; - /** @var Activity $activity */ - $activity = BaseObject::getClass(Activity::class); + $activity = DI::activity(); if (($activity->match($item['verb'], Activity::LIKE) || $activity->match($item['verb'], Activity::DISLIKE)) && diff --git a/mod/settings.php b/mod/settings.php index ad83b68210..b126defcba 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -5,7 +5,6 @@ use Friendica\App; use Friendica\BaseModule; -use Friendica\BaseObject; use Friendica\Content\Feature; use Friendica\Content\Nav; use Friendica\Core\ACL; @@ -20,14 +19,13 @@ use Friendica\Core\System; use Friendica\Core\Theme; use Friendica\Core\Worker; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\GContact; use Friendica\Model\Group; use Friendica\Model\User; use Friendica\Module\Security\Login; use Friendica\Protocol\Email; -use Friendica\Util\ACLFormatter; -use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Util\Temporal; use Friendica\Worker\Delivery; @@ -564,8 +562,7 @@ function settings_post(App $a) date_default_timezone_set($timezone); } - /** @var ACLFormatter $aclFormatter */ - $aclFormatter = BaseObject::getClass(ACLFormatter::class); + $aclFormatter = DI::aclFormatter(); $str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->toString($_POST['group_allow']) : ''; $str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->toString($_POST['contact_allow']) : ''; diff --git a/src/App/Module.php b/src/App/Module.php index a8648d0aa0..39111c9501 100644 --- a/src/App/Module.php +++ b/src/App/Module.php @@ -3,7 +3,7 @@ namespace Friendica\App; use Friendica\App; -use Friendica\BaseObject; +use Friendica\BaseModule; use Friendica\Core; use Friendica\LegacyModule; use Friendica\Module\Home; @@ -59,7 +59,7 @@ class Module private $module; /** - * @var BaseObject The module class + * @var BaseModule The module class */ private $module_class; diff --git a/src/BaseModule.php b/src/BaseModule.php index be53289e52..3d6a3f691f 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -14,7 +14,7 @@ use Friendica\Core\Logger; * * @author Hypolite Petovan */ -abstract class BaseModule extends BaseObject +abstract class BaseModule { /** * @brief Initialization method common to both content() and post() diff --git a/src/BaseObject.php b/src/BaseObject.php deleted file mode 100644 index 742b2c8598..0000000000 --- a/src/BaseObject.php +++ /dev/null @@ -1,58 +0,0 @@ -create($name); - } else { - throw new InternalServerErrorException('Class \'' . $name . '\' isn\'t valid.'); - } - } -} diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 037ea901af..2619dc92cc 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -8,7 +8,6 @@ namespace Friendica\Content\Text; use DOMDocument; use DOMXPath; use Exception; -use Friendica\BaseObject; use Friendica\Content\OEmbed; use Friendica\Content\Smilies; use Friendica\Core\Cache; @@ -34,7 +33,7 @@ use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; use Friendica\Util\XML; -class BBCode extends BaseObject +class BBCode { /** * @brief Fetches attachment data that were generated the old way diff --git a/src/Content/Text/Markdown.php b/src/Content/Text/Markdown.php index cca64b0ab2..004f01beed 100644 --- a/src/Content/Text/Markdown.php +++ b/src/Content/Text/Markdown.php @@ -6,7 +6,6 @@ namespace Friendica\Content\Text; -use Friendica\BaseObject; use Friendica\Core\System; use Friendica\DI; use Friendica\Model\Contact; @@ -16,7 +15,7 @@ use Friendica\Model\Contact; * * @author Hypolite Petovan */ -class Markdown extends BaseObject +class Markdown { /** * Converts a Markdown string into HTML. The hardwrap parameter maximizes diff --git a/src/Core/ACL.php b/src/Core/ACL.php index 6134828658..d48ef3fa51 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -7,7 +7,6 @@ namespace Friendica\Core; use Friendica\App\Page; -use Friendica\BaseObject; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -18,7 +17,7 @@ use Friendica\Model\Group; * * @author Hypolite Petovan */ -class ACL extends BaseObject +class ACL { /** * Returns a select input tag with all the contact of the local user diff --git a/src/Core/Addon.php b/src/Core/Addon.php index b1c1ad2e60..59e1ec7b96 100644 --- a/src/Core/Addon.php +++ b/src/Core/Addon.php @@ -5,7 +5,6 @@ namespace Friendica\Core; -use Friendica\BaseObject; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Util\Strings; @@ -13,7 +12,7 @@ use Friendica\Util\Strings; /** * Some functions to handle addons */ -class Addon extends BaseObject +class Addon { /** * The addon sub-directory diff --git a/src/Core/Cache.php b/src/Core/Cache.php index 7a952ff8a1..d0a04b9ec1 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -4,14 +4,13 @@ */ namespace Friendica\Core; -use Friendica\BaseObject; use Friendica\Core\Cache\Cache as CacheClass; -use Friendica\Core\Cache\ICache; +use Friendica\DI; /** * @brief Class for storing data for a short time */ -class Cache extends BaseObject +class Cache { /** @deprecated Use CacheClass::MONTH */ const MONTH = CacheClass::MONTH; @@ -42,7 +41,7 @@ class Cache extends BaseObject */ public static function getAllKeys($prefix = null) { - return self::getClass(ICache::class)->getAllKeys($prefix); + return DI::cache()->getAllKeys($prefix); } /** @@ -55,7 +54,7 @@ class Cache extends BaseObject */ public static function get($key) { - return self::getClass(ICache::class)->get($key); + return DI::cache()->get($key); } /** @@ -72,7 +71,7 @@ class Cache extends BaseObject */ public static function set($key, $value, $duration = CacheClass::MONTH) { - return self::getClass(ICache::class)->set($key, $value, $duration); + return DI::cache()->set($key, $value, $duration); } /** @@ -85,7 +84,7 @@ class Cache extends BaseObject */ public static function delete($key) { - return self::getClass(ICache::class)->delete($key); + return DI::cache()->delete($key); } /** @@ -98,6 +97,6 @@ class Cache extends BaseObject */ public static function clear($outdated = true) { - return self::getClass(ICache::class)->clear($outdated); + return DI::cache()->clear($outdated); } } diff --git a/src/Core/Config.php b/src/Core/Config.php index cec7a460e7..6864cb78d6 100644 --- a/src/Core/Config.php +++ b/src/Core/Config.php @@ -8,8 +8,7 @@ */ namespace Friendica\Core; -use Friendica\BaseObject; -use Friendica\Core\Config\Configuration; +use Friendica\DI; /** * @brief Arbitrary system configuration storage @@ -18,7 +17,7 @@ use Friendica\Core\Config\Configuration; * If we ever would decide to return exactly the variable type as entered, * we will have fun with the additional features. :-) */ -class Config extends BaseObject +class Config { /** * @brief Loads all configuration values of family into a cached storage. @@ -29,7 +28,7 @@ class Config extends BaseObject */ public static function load($cat = "config") { - self::getClass(Configuration::class)->load($cat); + DI::config()->load($cat); } /** @@ -45,7 +44,7 @@ class Config extends BaseObject */ public static function get($cat, $key, $default_value = null, $refresh = false) { - return self::getClass(Configuration::class)->get($cat, $key, $default_value, $refresh); + return DI::config()->get($cat, $key, $default_value, $refresh); } /** @@ -63,7 +62,7 @@ class Config extends BaseObject */ public static function set($cat, $key, $value) { - return self::getClass(Configuration::class)->set($cat, $key, $value); + return DI::config()->set($cat, $key, $value); } /** @@ -76,6 +75,6 @@ class Config extends BaseObject */ public static function delete($cat, $key) { - return self::getClass(Configuration::class)->delete($cat, $key); + return DI::config()->delete($cat, $key); } } diff --git a/src/Core/Console.php b/src/Core/Console.php index 2ca568c2da..16fc90c4eb 100644 --- a/src/Core/Console.php +++ b/src/Core/Console.php @@ -146,7 +146,7 @@ HELP; $className = $this->subConsoles[$command]; - Friendica\BaseObject::setDependencyInjection($this->dice); + Friendica\DI::init($this->dice); /** @var Console $subconsole */ $subconsole = $this->dice->create($className, [$subargs]); diff --git a/src/Core/Hook.php b/src/Core/Hook.php index 959ed9fa16..b8ad0fb8bd 100644 --- a/src/Core/Hook.php +++ b/src/Core/Hook.php @@ -5,7 +5,6 @@ namespace Friendica\Core; use Friendica\App; -use Friendica\BaseObject; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Util\Strings; @@ -13,7 +12,7 @@ use Friendica\Util\Strings; /** * Some functions to handle hooks */ -class Hook extends BaseObject +class Hook { /** * Array of registered hooks diff --git a/src/Core/L10n.php b/src/Core/L10n.php index b27228cf80..d1a6204ef3 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -4,14 +4,14 @@ */ namespace Friendica\Core; -use Friendica\BaseObject; use Friendica\Core\L10n\L10n as L10nClass; +use Friendica\DI; /** * Provide Language, Translation, and Localization functions to the application * Localization can be referred to by the numeronym L10N (as in: "L", followed by ten more letters, and then "N"). */ -class L10n extends BaseObject +class L10n { /** * Returns the current language code @@ -20,7 +20,7 @@ class L10n extends BaseObject */ public static function getCurrentLang() { - return self::getClass(L10nClass::class)->getCurrentLang(); + return DI::l10n()->getCurrentLang(); } /** @@ -32,7 +32,7 @@ class L10n extends BaseObject */ public static function withLang(string $lang) { - return self::getClass(L10nClass::class)->withLang($lang); + DI::l10n()->withLang($lang); } /** @@ -54,7 +54,7 @@ class L10n extends BaseObject */ public static function t($s, ...$vars) { - return self::getClass(L10nClass::class)->t($s, ...$vars); + return DI::l10n()->t($s, ...$vars); } /** @@ -79,7 +79,7 @@ class L10n extends BaseObject */ public static function tt(string $singular, string $plural, int $count) { - return self::getClass(L10nClass::class)->tt($singular, $plural, $count); + return DI::l10n()->tt($singular, $plural, $count); } /** @@ -107,7 +107,7 @@ class L10n extends BaseObject */ public static function getDay($s) { - return self::getClass(L10nClass::class)->getDay($s); + return DI::l10n()->getDay($s); } /** @@ -119,7 +119,7 @@ class L10n extends BaseObject */ public static function getDayShort($s) { - return self::getClass(L10nClass::class)->getDayShort($s); + return DI::l10n()->getDayShort($s); } /** @@ -131,6 +131,6 @@ class L10n extends BaseObject */ public static function getPokeVerbs() { - return self::getClass(L10nClass::class)->getPokeVerbs(); + return DI::l10n()->getPokeVerbs(); } } diff --git a/src/Core/Lock.php b/src/Core/Lock.php index ef62bc8f76..e25feac2ec 100644 --- a/src/Core/Lock.php +++ b/src/Core/Lock.php @@ -7,14 +7,13 @@ namespace Friendica\Core; -use Friendica\BaseObject; use Friendica\Core\Cache\Cache; -use Friendica\Core\Lock\ILock; +use Friendica\DI; /** * This class contain Functions for preventing parallel execution of functions */ -class Lock extends BaseObject +class Lock { /** * @brief Acquires a lock for a given name @@ -28,7 +27,7 @@ class Lock extends BaseObject */ public static function acquire($key, $timeout = 120, $ttl = Cache::FIVE_MINUTES) { - return self::getClass(ILock::class)->acquireLock($key, $timeout, $ttl); + return DI::lock()->acquireLock($key, $timeout, $ttl); } /** @@ -37,12 +36,12 @@ class Lock extends BaseObject * @param string $key Name of the lock * @param bool $override Overrides the lock to get releases * - * @return void + * @return bool * @throws \Exception */ public static function release($key, $override = false) { - return self::getClass(ILock::class)->releaseLock($key, $override); + return DI::lock()->releaseLock($key, $override); } /** @@ -52,6 +51,6 @@ class Lock extends BaseObject */ public static function releaseAll() { - self::getClass(ILock::class)->releaseAll(); + DI::lock()->releaseAll(); } } diff --git a/src/Core/Logger.php b/src/Core/Logger.php index e8d95fa857..0ce2a6e675 100644 --- a/src/Core/Logger.php +++ b/src/Core/Logger.php @@ -4,7 +4,7 @@ */ namespace Friendica\Core; -use Friendica\BaseObject; +use Friendica\DI; use Friendica\Util\Logger\WorkerLogger; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; @@ -12,7 +12,7 @@ use Psr\Log\LogLevel; /** * @brief Logger functions */ -class Logger extends BaseObject +class Logger { /** * @see Logger::error() @@ -66,6 +66,18 @@ class Logger extends BaseObject self::DATA => 'Data', ]; + /** + * @return LoggerInterface + */ + private static function getWorker() + { + if (self::$type === self::TYPE_LOGGER) { + return DI::logger(); + } else { + return DI::workerLogger(); + } + } + /** * Enable additional logging for worker usage * @@ -76,7 +88,7 @@ class Logger extends BaseObject public static function enableWorker(string $functionName) { self::$type = self::TYPE_WORKER; - self::getClass(self::$type)->setFunctionName($functionName); + self::getWorker()->setFunctionName($functionName); } /** @@ -100,7 +112,7 @@ class Logger extends BaseObject */ public static function emergency($message, $context = []) { - self::getClass(self::$type)->emergency($message, $context); + self::getWorker()->emergency($message, $context); } /** @@ -118,7 +130,7 @@ class Logger extends BaseObject */ public static function alert($message, $context = []) { - self::getClass(self::$type)->alert($message, $context); + self::getWorker()->alert($message, $context); } /** @@ -135,7 +147,7 @@ class Logger extends BaseObject */ public static function critical($message, $context = []) { - self::getClass(self::$type)->critical($message, $context); + self::getWorker()->critical($message, $context); } /** @@ -151,7 +163,7 @@ class Logger extends BaseObject */ public static function error($message, $context = []) { - self::getClass(self::$type)->error($message, $context); + self::getWorker()->error($message, $context); } /** @@ -169,7 +181,7 @@ class Logger extends BaseObject */ public static function warning($message, $context = []) { - self::getClass(self::$type)->warning($message, $context); + self::getWorker()->warning($message, $context); } /** @@ -184,7 +196,7 @@ class Logger extends BaseObject */ public static function notice($message, $context = []) { - self::getClass(self::$type)->notice($message, $context); + self::getWorker()->notice($message, $context); } /** @@ -201,7 +213,7 @@ class Logger extends BaseObject */ public static function info($message, $context = []) { - self::getClass(self::$type)->info($message, $context); + self::getWorker()->info($message, $context); } /** @@ -216,7 +228,7 @@ class Logger extends BaseObject */ public static function debug($message, $context = []) { - self::getClass(self::$type)->debug($message, $context); + self::getWorker()->debug($message, $context); } /** @@ -230,7 +242,7 @@ class Logger extends BaseObject */ public static function log($msg, $level = LogLevel::INFO) { - self::getClass(self::$type)->log($level, $msg); + self::getWorker()->log($level, $msg); } /** @@ -245,6 +257,6 @@ class Logger extends BaseObject */ public static function devLog($msg, $level = LogLevel::DEBUG) { - self::getClass('$devLogger')->log($level, $msg); + DI::devLogger()->log($level, $msg); } } diff --git a/src/Core/PConfig.php b/src/Core/PConfig.php index e96935c4e6..06b0140097 100644 --- a/src/Core/PConfig.php +++ b/src/Core/PConfig.php @@ -8,8 +8,7 @@ */ namespace Friendica\Core; -use Friendica\BaseObject; -use Friendica\Core\Config\PConfiguration; +use Friendica\DI; /** * @brief Management of user configuration storage @@ -18,7 +17,7 @@ use Friendica\Core\Config\PConfiguration; * The PConfig::get() functions return boolean false for keys that are unset, * and this could lead to subtle bugs. */ -class PConfig extends BaseObject +class PConfig { /** * @brief Loads all configuration values of a user's config family into a cached storage. @@ -30,7 +29,7 @@ class PConfig extends BaseObject */ public static function load(int $uid, string $cat) { - self::getClass(PConfiguration::class)->load($uid, $cat); + DI::pConfig()->load($uid, $cat); } /** @@ -47,7 +46,7 @@ class PConfig extends BaseObject */ public static function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false) { - return self::getClass(PConfiguration::class)->get($uid, $cat, $key, $default_value, $refresh); + return DI::pConfig()->get($uid, $cat, $key, $default_value, $refresh); } /** @@ -62,7 +61,7 @@ class PConfig extends BaseObject */ public static function set(int $uid, string $cat, string $key, $value) { - return self::getClass(PConfiguration::class)->set($uid, $cat, $key, $value); + return DI::pConfig()->set($uid, $cat, $key, $value); } /** @@ -76,6 +75,6 @@ class PConfig extends BaseObject */ public static function delete(int $uid, string $cat, string $key) { - return self::getClass(PConfiguration::class)->delete($uid, $cat, $key); + return DI::pConfig()->delete($uid, $cat, $key); } } diff --git a/src/Core/Renderer.php b/src/Core/Renderer.php index ce90d78dee..c687a67283 100644 --- a/src/Core/Renderer.php +++ b/src/Core/Renderer.php @@ -6,7 +6,6 @@ namespace Friendica\Core; use Exception; -use Friendica\BaseObject; use Friendica\DI; use Friendica\Render\FriendicaSmarty; use Friendica\Render\ITemplateEngine; @@ -14,7 +13,7 @@ use Friendica\Render\ITemplateEngine; /** * @brief This class handles Renderer related functions. */ -class Renderer extends BaseObject +class Renderer { /** * @brief An array of registered template engines ('name'=>'class name') diff --git a/src/Core/Search.php b/src/Core/Search.php index ff1a8a317c..c1c80091f0 100644 --- a/src/Core/Search.php +++ b/src/Core/Search.php @@ -2,7 +2,6 @@ namespace Friendica\Core; -use Friendica\BaseObject; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -21,7 +20,7 @@ use Friendica\Util\Strings; * - Search in the local directory * - Search in the global directory */ -class Search extends BaseObject +class Search { const DEFAULT_DIRECTORY = 'https://dir.friendica.social'; diff --git a/src/Core/Session.php b/src/Core/Session.php index 0557ce81b7..d0c8581d31 100644 --- a/src/Core/Session.php +++ b/src/Core/Session.php @@ -5,9 +5,8 @@ */ namespace Friendica\Core; -use Friendica\BaseObject; -use Friendica\Core\Session\ISession; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Util\Strings; @@ -16,39 +15,39 @@ use Friendica\Util\Strings; * * @author Hypolite Petovan */ -class Session extends BaseObject +class Session { public static $exists = false; public static $expire = 180000; public static function exists($name) { - return self::getClass(ISession::class)->exists($name); + return DI::session()->exists($name); } public static function get($name, $defaults = null) { - return self::getClass(ISession::class)->get($name, $defaults); + return DI::session()->get($name, $defaults); } public static function set($name, $value) { - self::getClass(ISession::class)->set($name, $value); + DI::session()->set($name, $value); } public static function setMultiple(array $values) { - self::getClass(ISession::class)->setMultiple($values); + DI::session()->setMultiple($values); } public static function remove($name) { - self::getClass(ISession::class)->remove($name); + DI::session()->remove($name); } public static function clear() { - self::getClass(ISession::class)->clear(); + DI::session()->clear(); } /** @@ -59,8 +58,7 @@ class Session extends BaseObject */ public static function getRemoteContactID($uid) { - /** @var ISession $session */ - $session = self::getClass(ISession::class); + $session = DI::session(); if (empty($session->get('remote')[$uid])) { return false; @@ -77,8 +75,7 @@ class Session extends BaseObject */ public static function getUserIDForVisitorContactID($cid) { - /** @var ISession $session */ - $session = self::getClass(ISession::class); + $session = DI::session(); if (empty($session->get('remote'))) { return false; @@ -94,8 +91,7 @@ class Session extends BaseObject */ public static function setVisitorsContacts() { - /** @var ISession $session */ - $session = self::getClass(ISession::class); + $session = DI::session(); $session->set('remote', []); @@ -117,8 +113,7 @@ class Session extends BaseObject */ public static function isAuthenticated() { - /** @var ISession $session */ - $session = self::getClass(ISession::class); + $session = DI::session(); return $session->get('authenticated', false); } diff --git a/src/Core/System.php b/src/Core/System.php index cf6fd9b4a9..367e055c93 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -4,8 +4,6 @@ */ namespace Friendica\Core; -use Friendica\App\BaseURL; -use Friendica\BaseObject; use Friendica\DI; use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Util\XML; @@ -20,18 +18,17 @@ use Friendica\Util\XML; /** * @brief System methods */ -class System extends BaseObject +class System { /** * @brief Retrieves the Friendica instance base URL * * @param bool $ssl Whether to append http or https under BaseURL::SSL_POLICY_SELFSIGN * @return string Friendica server base URL - * @throws InternalServerErrorException */ public static function baseUrl($ssl = false) { - return self::getClass(BaseURL::class)->get($ssl); + return DI::baseUrl()->get($ssl); } /** diff --git a/src/Core/Theme.php b/src/Core/Theme.php index 7df985df35..dea3e20e64 100644 --- a/src/Core/Theme.php +++ b/src/Core/Theme.php @@ -6,7 +6,6 @@ namespace Friendica\Core; -use Friendica\BaseObject; use Friendica\DI; use Friendica\Model\Profile; use Friendica\Util\Strings; diff --git a/src/Core/Worker.php b/src/Core/Worker.php index b9362dace5..b451b11ca5 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -4,7 +4,6 @@ */ namespace Friendica\Core; -use Friendica\BaseObject; use Friendica\Core; use Friendica\Database\DBA; use Friendica\DI; diff --git a/src/DI.php b/src/DI.php index ef05b5cb07..efd29f9c0c 100644 --- a/src/DI.php +++ b/src/DI.php @@ -3,6 +3,22 @@ namespace Friendica; use Dice\Dice; +use Friendica\Core\Cache\ICache; +use Friendica\Core\Config\Configuration; +use Friendica\Core\Config\PConfiguration; +use Friendica\Core\L10n\L10n; +use Friendica\Core\Lock\ILock; +use Friendica\Core\Session\ISession; +use Friendica\Database\Database; +use Friendica\Model\Notify; +use Friendica\Protocol\Activity; +use Friendica\Util\ACLFormatter; +use Friendica\Content\Item as ContentItem; +use Friendica\Content\Text\BBCode\Video as BBCodeVideo; +use Friendica\Util\DateTimeFormat; +use Friendica\Util\FileSystem; +use Friendica\Util\Logger\WorkerLogger; +use Psr\Log\LoggerInterface; /** * This class is capable of getting all dynamic created classes @@ -10,6 +26,31 @@ use Dice\Dice; * There has to be a "method" phpDoc for each new class, containing result class for a proper matching * * @method static App app() + * @method static ACLFormatter aclFormatter() + * @method static Notify notify() + * @method static Activity activity() + * @method static ContentItem contentItem() + * @method static BBCodeVideo bbCodeVideo() + * @method static DateTimeFormat dtFormat() + * @method static ICache cache() + * @method static Configuration config() + * @method static PConfiguration pConfig() + * @method static ILock lock() + * @method static L10n l10n() + * @method static LoggerInterface logger() + * @method static LoggerInterface devLogger() + * @method static LoggerInterface workerLogger() + * @method static ISession session() + * @method static App\Authentication auth() + * @method static App\Arguments args() + * @method static App\BaseURL baseUrl() + * @method static App\Mode mode() + * @method static App\Module module() + * @method static App\Page page() + * @method static App\Router router() + * @method static Database dba() + * @method static FileSystem fs() + * */ class DI { @@ -26,6 +67,54 @@ class DI switch ($name) { case 'app': return self::$dice->create(App::class, $arguments); + case 'aclFormatter': + return self::$dice->create(ACLFormatter::class, $arguments); + case 'auth': + return self::$dice->create(App\Authentication::class, $arguments); + case 'args': + return self::$dice->create(App\Arguments::class, $arguments); + case 'baseUrl': + return self::$dice->create(App\BaseURL::class, $arguments); + case 'mode': + return self::$dice->create(App\Mode::class, $arguments); + case 'module': + return self::$dice->create(App\Module::class, $arguments); + case 'page': + return self::$dice->create(App\Page::class, $arguments); + case 'router': + return self::$dice->create(App\Router::class, $arguments); + case 'notify': + return self::$dice->create(Notify::class, $arguments); + case 'activity': + return self::$dice->create(Activity::class, $arguments); + case 'contentItem': + return self::$dice->create(ContentItem::class, $arguments); + case 'bbCodeVideo': + return self::$dice->create(BBCodeVideo::class, $arguments); + case 'dtFormat': + return self::$dice->create(DateTimeFormat::class, $arguments); + case 'cache': + return self::$dice->create(ICache::class, $arguments); + case 'config': + return self::$dice->create(Configuration::class, $arguments); + case 'pConfig': + return self::$dice->create(PConfiguration::class, $arguments); + case 'lock': + return self::$dice->create(ILock::class, $arguments); + case 'l10n': + return self::$dice->create(L10n::class, $arguments); + case 'logger': + return self::$dice->create(LoggerInterface::class, $arguments); + case 'devLogger': + return self::$dice->create('$devLogger', $arguments); + case 'workerLogger': + return self::$dice->create(WorkerLogger::class, $arguments); + case 'session': + return self::$dice->create(ISession::class, $arguments); + case 'dba': + return self::$dice->create(Database::class, $arguments); + case 'fs': + return self::$dice->create(FileSystem::class, $arguments); default: return null; } diff --git a/src/Database/DBA.php b/src/Database/DBA.php index 593ca0e507..1cf10ba4ad 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -2,7 +2,7 @@ namespace Friendica\Database; -use Friendica\BaseObject; +use Friendica\DI; use mysqli; use mysqli_result; use mysqli_stmt; @@ -14,7 +14,7 @@ use PDOStatement; * * This class is for the low level database stuff that does driver specific things. */ -class DBA extends BaseObject +class DBA { /** * Lowest possible date value @@ -27,7 +27,7 @@ class DBA extends BaseObject public static function connect() { - return self::getClass(Database::class)->connect(); + return DI::dba()->connect(); } /** @@ -35,7 +35,7 @@ class DBA extends BaseObject */ public static function disconnect() { - self::getClass(Database::class)->disconnect(); + DI::dba()->disconnect(); } /** @@ -43,7 +43,7 @@ class DBA extends BaseObject */ public static function reconnect() { - return self::getClass(Database::class)->reconnect(); + return DI::dba()->reconnect(); } /** @@ -52,7 +52,7 @@ class DBA extends BaseObject */ public static function getConnection() { - return self::getClass(Database::class)->getConnection(); + return DI::dba()->getConnection(); } /** @@ -65,7 +65,7 @@ class DBA extends BaseObject */ public static function serverInfo() { - return self::getClass(Database::class)->serverInfo(); + return DI::dba()->serverInfo(); } /** @@ -76,17 +76,17 @@ class DBA extends BaseObject */ public static function databaseName() { - return self::getClass(Database::class)->databaseName(); + return DI::dba()->databaseName(); } public static function escape($str) { - return self::getClass(Database::class)->escape($str); + return DI::dba()->escape($str); } public static function connected() { - return self::getClass(Database::class)->connected(); + return DI::dba()->connected(); } /** @@ -102,7 +102,7 @@ class DBA extends BaseObject */ public static function anyValueFallback($sql) { - return self::getClass(Database::class)->anyValueFallback($sql); + return DI::dba()->anyValueFallback($sql); } /** @@ -158,7 +158,7 @@ class DBA extends BaseObject { $params = self::getParam(func_get_args()); - return self::getClass(Database::class)->p($sql, $params); + return DI::dba()->p($sql, $params); } /** @@ -174,7 +174,7 @@ class DBA extends BaseObject $params = self::getParam(func_get_args()); - return self::getClass(Database::class)->e($sql, $params); + return DI::dba()->e($sql, $params); } /** @@ -188,7 +188,7 @@ class DBA extends BaseObject */ public static function exists($table, $condition) { - return self::getClass(Database::class)->exists($table, $condition); + return DI::dba()->exists($table, $condition); } /** @@ -205,7 +205,7 @@ class DBA extends BaseObject { $params = self::getParam(func_get_args()); - return self::getClass(Database::class)->fetchFirst($sql, $params); + return DI::dba()->fetchFirst($sql, $params); } /** @@ -215,7 +215,7 @@ class DBA extends BaseObject */ public static function affectedRows() { - return self::getClass(Database::class)->affectedRows(); + return DI::dba()->affectedRows(); } /** @@ -226,7 +226,7 @@ class DBA extends BaseObject */ public static function columnCount($stmt) { - return self::getClass(Database::class)->columnCount($stmt); + return DI::dba()->columnCount($stmt); } /** * @brief Returns the number of rows of a statement @@ -236,7 +236,7 @@ class DBA extends BaseObject */ public static function numRows($stmt) { - return self::getClass(Database::class)->numRows($stmt); + return DI::dba()->numRows($stmt); } /** @@ -247,7 +247,7 @@ class DBA extends BaseObject */ public static function fetch($stmt) { - return self::getClass(Database::class)->fetch($stmt); + return DI::dba()->fetch($stmt); } /** @@ -262,7 +262,7 @@ class DBA extends BaseObject */ public static function insert($table, $param, $on_duplicate_update = false) { - return self::getClass(Database::class)->insert($table, $param, $on_duplicate_update); + return DI::dba()->insert($table, $param, $on_duplicate_update); } /** @@ -272,7 +272,7 @@ class DBA extends BaseObject */ public static function lastInsertId() { - return self::getClass(Database::class)->lastInsertId(); + return DI::dba()->lastInsertId(); } /** @@ -287,7 +287,7 @@ class DBA extends BaseObject */ public static function lock($table) { - return self::getClass(Database::class)->lock($table); + return DI::dba()->lock($table); } /** @@ -298,7 +298,7 @@ class DBA extends BaseObject */ public static function unlock() { - return self::getClass(Database::class)->unlock(); + return DI::dba()->unlock(); } /** @@ -308,7 +308,7 @@ class DBA extends BaseObject */ public static function transaction() { - return self::getClass(Database::class)->transaction(); + return DI::dba()->transaction(); } /** @@ -318,7 +318,7 @@ class DBA extends BaseObject */ public static function commit() { - return self::getClass(Database::class)->commit(); + return DI::dba()->commit(); } /** @@ -328,7 +328,7 @@ class DBA extends BaseObject */ public static function rollback() { - return self::getClass(Database::class)->rollback(); + return DI::dba()->rollback(); } /** @@ -345,7 +345,7 @@ class DBA extends BaseObject */ public static function delete($table, array $conditions, array $options = []) { - return self::getClass(Database::class)->delete($table, $conditions, $options); + return DI::dba()->delete($table, $conditions, $options); } /** @@ -379,7 +379,7 @@ class DBA extends BaseObject */ public static function update($table, $fields, $condition, $old_fields = []) { - return self::getClass(Database::class)->update($table, $fields, $condition, $old_fields); + return DI::dba()->update($table, $fields, $condition, $old_fields); } /** @@ -396,7 +396,7 @@ class DBA extends BaseObject */ public static function selectFirst($table, array $fields = [], array $condition = [], $params = []) { - return self::getClass(Database::class)->selectFirst($table, $fields, $condition, $params); + return DI::dba()->selectFirst($table, $fields, $condition, $params); } /** @@ -413,7 +413,7 @@ class DBA extends BaseObject */ public static function selectToArray($table, array $fields = [], array $condition = [], array $params = []) { - return self::getClass(Database::class)->selectToArray($table, $fields, $condition, $params); + return DI::dba()->selectToArray($table, $fields, $condition, $params); } /** @@ -441,7 +441,7 @@ class DBA extends BaseObject */ public static function select($table, array $fields = [], array $condition = [], array $params = []) { - return self::getClass(Database::class)->select($table, $fields, $condition, $params); + return DI::dba()->select($table, $fields, $condition, $params); } /** @@ -465,7 +465,7 @@ class DBA extends BaseObject */ public static function count($table, array $condition = [], array $params = []) { - return self::getClass(Database::class)->count($table, $condition, $params); + return DI::dba()->count($table, $condition, $params); } /** @@ -639,7 +639,7 @@ class DBA extends BaseObject */ public static function toArray($stmt, $do_close = true) { - return self::getClass(Database::class)->toArray($stmt, $do_close); + return DI::dba()->toArray($stmt, $do_close); } /** @@ -649,7 +649,7 @@ class DBA extends BaseObject */ public static function errorNo() { - return self::getClass(Database::class)->errorNo(); + return DI::dba()->errorNo(); } /** @@ -659,7 +659,7 @@ class DBA extends BaseObject */ public static function errorMessage() { - return self::getClass(Database::class)->errorMessage(); + return DI::dba()->errorMessage(); } /** @@ -670,7 +670,7 @@ class DBA extends BaseObject */ public static function close($stmt) { - return self::getClass(Database::class)->close($stmt); + return DI::dba()->close($stmt); } /** @@ -683,7 +683,7 @@ class DBA extends BaseObject */ public static function processlist() { - return self::getClass(Database::class)->processlist(); + return DI::dba()->processlist(); } /** @@ -695,7 +695,7 @@ class DBA extends BaseObject */ public static function isResult($array) { - return self::getClass(Database::class)->isResult($array); + return DI::dba()->isResult($array); } /** @@ -707,6 +707,6 @@ class DBA extends BaseObject */ public static function escapeArray(&$arr, $add_quotation = false) { - return self::getClass(Database::class)->escapeArray($arr, $add_quotation); + DI::dba()->escapeArray($arr, $add_quotation); } } diff --git a/src/Model/APContact.php b/src/Model/APContact.php index c535034487..067be58746 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -6,7 +6,6 @@ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Content\Text\HTML; use Friendica\Core\Logger; use Friendica\Core\Config; @@ -17,7 +16,7 @@ use Friendica\Util\JsonLD; use Friendica\Util\DateTimeFormat; use Friendica\Util\Strings; -class APContact extends BaseObject +class APContact { /** * Resolves the profile url from the address by using webfinger diff --git a/src/Model/Attach.php b/src/Model/Attach.php index fce55f5106..c1d5c033bd 100644 --- a/src/Model/Attach.php +++ b/src/Model/Attach.php @@ -6,7 +6,6 @@ */ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Core\StorageManager; use Friendica\Core\System; use Friendica\Database\DBA; @@ -21,7 +20,7 @@ use Friendica\Util\Security; /** * Class to handle attach dabatase table */ -class Attach extends BaseObject +class Attach { /** diff --git a/src/Model/Contact.php b/src/Model/Contact.php index c4f05b2dc9..577f3da1df 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -5,7 +5,6 @@ namespace Friendica\Model; use Friendica\App\BaseURL; -use Friendica\BaseObject; use Friendica\Content\Pager; use Friendica\Core\Config; use Friendica\Core\Hook; @@ -18,7 +17,6 @@ use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Network\Probe; -use Friendica\Object\Image; use Friendica\Protocol\Activity; use Friendica\Protocol\ActivityPub; use Friendica\Protocol\DFRN; @@ -33,7 +31,7 @@ use Friendica\Util\Strings; /** * @brief functions for interacting with a contact */ -class Contact extends BaseObject +class Contact { /** * @deprecated since version 2019.03 diff --git a/src/Model/Event.php b/src/Model/Event.php index 7b6f31baa4..0374c6bb7c 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -5,7 +5,6 @@ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\L10n; @@ -23,7 +22,7 @@ use Friendica\Util\XML; /** * @brief functions for interacting with the event database table */ -class Event extends BaseObject +class Event { public static function getHTML(array $event, $simple = false) diff --git a/src/Model/Group.php b/src/Model/Group.php index 3be2a80e56..c984f0032e 100644 --- a/src/Model/Group.php +++ b/src/Model/Group.php @@ -6,7 +6,6 @@ namespace Friendica\Model; use Friendica\BaseModule; -use Friendica\BaseObject; use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\Protocol; @@ -16,7 +15,7 @@ use Friendica\Database\DBA; /** * @brief functions for interacting with the group database table */ -class Group extends BaseObject +class Group { const FOLLOWERS = '~'; const MUTUALS = '&'; diff --git a/src/Model/Item.php b/src/Model/Item.php index 9a86097ae8..f955337179 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -6,7 +6,6 @@ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Config; @@ -26,7 +25,6 @@ use Friendica\Protocol\Activity; use Friendica\Protocol\ActivityPub; use Friendica\Protocol\Diaspora; use Friendica\Protocol\OStatus; -use Friendica\Util\ACLFormatter; use Friendica\Util\DateTimeFormat; use Friendica\Util\Map; use Friendica\Util\Network; @@ -36,7 +34,7 @@ use Friendica\Util\XML; use Friendica\Worker\Delivery; use Text_LanguageDetect; -class Item extends BaseObject +class Item { // Posting types, inspired by https://www.w3.org/TR/activitystreams-vocabulary/#object-types const PT_ARTICLE = 0; @@ -1442,8 +1440,7 @@ class Item extends BaseObject $item['parent-uri'] = $item['thr-parent']; } - /** @var Activity $activity */ - $activity = self::getClass(Activity::class); + $activity = DI::activity(); if (isset($item['gravity'])) { $item['gravity'] = intval($item['gravity']); @@ -2980,8 +2977,7 @@ class Item extends BaseObject */ public static function enumeratePermissions(array $obj, bool $check_dead = false) { - /** @var ACLFormatter $aclFormater */ - $aclFormater = self::getClass(ACLFormatter::class); + $aclFormater = DI::aclFormatter(); $allow_people = $aclFormater->expand($obj['allow_cid']); $allow_groups = Group::expand($obj['uid'], $aclFormater->expand($obj['allow_gid']), $check_dead); diff --git a/src/Model/ItemContent.php b/src/Model/ItemContent.php index 68b42af928..136323385c 100644 --- a/src/Model/ItemContent.php +++ b/src/Model/ItemContent.php @@ -6,12 +6,11 @@ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Content\Text; use Friendica\Core\PConfig; use Friendica\Core\Protocol; -class ItemContent extends BaseObject +class ItemContent { /** * @brief Convert a message into plaintext for connectors to other networks diff --git a/src/Model/ItemURI.php b/src/Model/ItemURI.php index 8e39ebd1cb..7e27858a3b 100644 --- a/src/Model/ItemURI.php +++ b/src/Model/ItemURI.php @@ -6,10 +6,9 @@ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Database\DBA; -class ItemURI extends BaseObject +class ItemURI { /** * @brief Insert an item-uri record and return its id diff --git a/src/Model/Nodeinfo.php b/src/Model/Nodeinfo.php index f6deb31bd5..29fa00aa19 100644 --- a/src/Model/Nodeinfo.php +++ b/src/Model/Nodeinfo.php @@ -2,7 +2,6 @@ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Core\Addon; use Friendica\Database\DBA; use Friendica\DI; @@ -10,7 +9,7 @@ use Friendica\DI; /** * Model interaction for the nodeinfo */ -class Nodeinfo extends BaseObject +class Nodeinfo { /** * Updates the info about the current node diff --git a/src/Model/Notify.php b/src/Model/Notify.php index 842f9509cd..160d261b16 100644 --- a/src/Model/Notify.php +++ b/src/Model/Notify.php @@ -4,7 +4,6 @@ namespace Friendica\Model; use Exception; use Friendica\App; -use Friendica\BaseObject; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Config\PConfiguration; @@ -26,7 +25,7 @@ use Friendica\Network\HTTPException; * @brief Methods for read and write notifications from/to database * or for formatting notifications */ -final class Notify extends BaseObject +final class Notify { /** @var int The default limit of notifies per page */ const DEFAULT_PAGE_LIMIT = 80; diff --git a/src/Model/PermissionSet.php b/src/Model/PermissionSet.php index c9a0697ebc..081ef21d85 100644 --- a/src/Model/PermissionSet.php +++ b/src/Model/PermissionSet.php @@ -4,13 +4,12 @@ */ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Database\DBA; /** * @brief functions for interacting with the permission set of an object (item, photo, event, ...) */ -class PermissionSet extends BaseObject +class PermissionSet { /** * Fetch the id of a given permission set. Generate a new one when needed diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 445e8a5e5c..af17cc395e 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -6,7 +6,6 @@ */ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -29,7 +28,7 @@ require_once "include/dba.php"; /** * Class to handle photo dabatase table */ -class Photo extends BaseObject +class Photo { /** * @brief Select rows from the photo table and returns them as array diff --git a/src/Model/Process.php b/src/Model/Process.php index f70b12ba7c..7c9f886dfa 100644 --- a/src/Model/Process.php +++ b/src/Model/Process.php @@ -4,14 +4,13 @@ */ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; /** * @brief functions for interacting with a process */ -class Process extends BaseObject +class Process { /** * Insert a new process row. If the pid parameter is omitted, we use the current pid diff --git a/src/Model/Search.php b/src/Model/Search.php index 5829ff91d0..2c8349364c 100644 --- a/src/Model/Search.php +++ b/src/Model/Search.php @@ -2,13 +2,12 @@ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Database\DBA; /** * Model for DB specific logic for the search entity */ -class Search extends BaseObject +class Search { /** * Returns the list of user defined tags (e.g. #Friendica) diff --git a/src/Model/TwoFactor/AppSpecificPassword.php b/src/Model/TwoFactor/AppSpecificPassword.php index 41b1e3bac4..f1ea9af916 100644 --- a/src/Model/TwoFactor/AppSpecificPassword.php +++ b/src/Model/TwoFactor/AppSpecificPassword.php @@ -2,7 +2,6 @@ namespace Friendica\Model\TwoFactor; -use Friendica\BaseObject; use Friendica\Database\DBA; use Friendica\Model\User; use Friendica\Util\DateTimeFormat; @@ -14,7 +13,7 @@ use PragmaRX\Random\Random; * * @package Friendica\Model */ -class AppSpecificPassword extends BaseObject +class AppSpecificPassword { public static function countForUser($uid) { diff --git a/src/Model/TwoFactor/RecoveryCode.php b/src/Model/TwoFactor/RecoveryCode.php index 676b538378..1690e04f9b 100644 --- a/src/Model/TwoFactor/RecoveryCode.php +++ b/src/Model/TwoFactor/RecoveryCode.php @@ -2,7 +2,6 @@ namespace Friendica\Model\TwoFactor; -use Friendica\BaseObject; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; use PragmaRX\Random\Random; @@ -13,7 +12,7 @@ use PragmaRX\Recovery\Recovery; * * @package Friendica\Model */ -class RecoveryCode extends BaseObject +class RecoveryCode { /** * Returns the number of code the provided users can still use to replace a TOTP code diff --git a/src/Module/Admin/Summary.php b/src/Module/Admin/Summary.php index 4011fec1c7..25097d533e 100644 --- a/src/Module/Admin/Summary.php +++ b/src/Module/Admin/Summary.php @@ -81,8 +81,7 @@ class Summary extends BaseAdminModule if (Config::get('system', 'debugging')) { $file = Config::get('system', 'logfile'); - /** @var FileSystem $fileSystem */ - $fileSystem = self::getClass(FileSystem::class); + $fileSystem = DI::fs(); try { $stream = $fileSystem->createStream($file); diff --git a/src/Module/Api/Mastodon/FollowRequests.php b/src/Module/Api/Mastodon/FollowRequests.php index 739400eb77..a8d6cb52ea 100644 --- a/src/Module/Api/Mastodon/FollowRequests.php +++ b/src/Module/Api/Mastodon/FollowRequests.php @@ -3,10 +3,10 @@ namespace Friendica\Module\Api\Mastodon; use Friendica\Api\Mastodon; -use Friendica\App\BaseURL; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\APContact; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Introduction; use Friendica\Module\Base\Api; @@ -104,8 +104,7 @@ class FollowRequests extends Api $base_query['limit'] = $limit; } - /** @var BaseURL $BaseURL */ - $BaseURL = self::getClass(BaseURL::class); + $BaseURL = DI::baseUrl(); $links = []; if ($count > $limit) { diff --git a/src/Module/Base/Api.php b/src/Module/Base/Api.php index 3a4e100897..b4cb39e15f 100644 --- a/src/Module/Base/Api.php +++ b/src/Module/Base/Api.php @@ -23,15 +23,15 @@ class Api extends BaseModule public static function init(array $parameters = []) { - $Arguments = self::getClass(Arguments::class); + $arguments = DI::args(); - if (substr($Arguments->getQueryString(), -4) === '.xml') { + if (substr($arguments->getQueryString(), -4) === '.xml') { self::$format = 'xml'; } - if (substr($Arguments->getQueryString(), -4) === '.rss') { + if (substr($arguments->getQueryString(), -4) === '.rss') { self::$format = 'rss'; } - if (substr($Arguments->getQueryString(), -4) === '.atom') { + if (substr($arguments->getQueryString(), -4) === '.atom') { self::$format = 'atom'; } } diff --git a/src/Module/BaseSearchModule.php b/src/Module/BaseSearchModule.php index 7c6760a8d1..0fa3eb5d63 100644 --- a/src/Module/BaseSearchModule.php +++ b/src/Module/BaseSearchModule.php @@ -65,8 +65,7 @@ class BaseSearchModule extends BaseModule $header = L10n::t('Forum Search - %s', $search); } - /** @var Arguments $args */ - $args = self::getClass(Arguments::class); + $args = DI::args(); $pager = new Pager($args->getQueryString()); if ($localSearch && empty($results)) { diff --git a/src/Module/Delegation.php b/src/Module/Delegation.php index a255ad3841..32d02a00e9 100644 --- a/src/Module/Delegation.php +++ b/src/Module/Delegation.php @@ -3,7 +3,6 @@ namespace Friendica\Module; use Friendica\BaseModule; -use Friendica\App\Authentication; use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Renderer; @@ -81,9 +80,7 @@ class Delegation extends BaseModule Session::clear(); - /** @var Authentication $authentication */ - $authentication = self::getClass(Authentication::class); - $authentication->setForUser(DI::app(), $user, true, true); + DI::auth()->setForUser(DI::app(), $user, true, true); if ($limited_id) { Session::set('submanage', $original_id); diff --git a/src/Module/Diaspora/Receive.php b/src/Module/Diaspora/Receive.php index 72b060a848..4b6bb2a52e 100644 --- a/src/Module/Diaspora/Receive.php +++ b/src/Module/Diaspora/Receive.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\BaseModule; use Friendica\Core\Config\Configuration; use Friendica\Core\L10n\L10n; +use Friendica\DI; use Friendica\Model\User; use Friendica\Network\HTTPException; use Friendica\Protocol\Diaspora; @@ -23,24 +24,18 @@ class Receive extends BaseModule public static function init(array $parameters = []) { - /** @var LoggerInterface $logger */ - self::$logger = self::getClass(LoggerInterface::class); + self::$logger = DI::logger(); } public static function post(array $parameters = []) { - /** @var Configuration $config */ - $config = self::getClass(Configuration::class); - - $enabled = $config->get('system', 'diaspora_enabled', false); + $enabled = DI::config()->get('system', 'diaspora_enabled', false); if (!$enabled) { self::$logger->info('Diaspora disabled.'); - $l10n = self::getClass(L10n::class); - throw new HTTPException\ForbiddenException($l10n->t('Access denied.')); + throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.')); } - /** @var App\Arguments $args */ - $args = self::getClass(App\Arguments::class); + $args = DI::args(); $type = $args->get(1); diff --git a/src/Module/Item/Compose.php b/src/Module/Item/Compose.php index 78c4710a36..7a26c93cf0 100644 --- a/src/Module/Item/Compose.php +++ b/src/Module/Item/Compose.php @@ -63,8 +63,7 @@ class Compose extends BaseModule $user = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'hidewall', 'default-location']); - /** @var ACLFormatter $aclFormatter */ - $aclFormatter = self::getClass(ACLFormatter::class); + $aclFormatter = DI::aclFormatter(); $contact_allow_list = $aclFormatter->expand($user['allow_cid']); $group_allow_list = $aclFormatter->expand($user['allow_gid']); diff --git a/src/Module/Item/Ignore.php b/src/Module/Item/Ignore.php index 75b2a7bd35..f59ba229c1 100644 --- a/src/Module/Item/Ignore.php +++ b/src/Module/Item/Ignore.php @@ -19,17 +19,14 @@ class Ignore extends BaseModule { public static function rawContent(array $parameters = []) { - /** @var L10n $l10n */ - $l10n = self::getClass(L10n::class); + $l10n = DI::l10n(); if (!Session::isAuthenticated()) { throw new HttpException\ForbiddenException($l10n->t('Access denied.')); } - /** @var App\Arguments $args */ - $args = self::getClass(App\Arguments::class); - /** @var Database $dba */ - $dba = self::getClass(Database::class); + $args = DI::args(); + $dba = DI::dba(); $message_id = intval($args->get(2)); diff --git a/src/Module/Notifications/Notify.php b/src/Module/Notifications/Notify.php index d95d9c0d8e..5200c59114 100644 --- a/src/Module/Notifications/Notify.php +++ b/src/Module/Notifications/Notify.php @@ -3,11 +3,9 @@ namespace Friendica\Module\Notifications; use Friendica\BaseModule; -use Friendica\BaseObject; use Friendica\Core\L10n; use Friendica\Core\System; use Friendica\DI; -use Friendica\Model\Notify as ModelNotify; use Friendica\Network\HTTPException; /** @@ -28,9 +26,7 @@ class Notify extends BaseModule // @TODO: Replace with parameter from router if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') { - /** @var ModelNotify $notificationsManager */ - $notificationsManager = self::getClass(ModelNotify::class); - $success = $notificationsManager->setAllSeen(); + $success = DI::notify()->setAllSeen(); header('Content-type: application/json; charset=utf-8'); echo json_encode([ @@ -52,8 +48,7 @@ class Notify extends BaseModule // @TODO: Replace with parameter from router if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) { - /** @var ModelNotify $notificationsManager */ - $notificationsManager = BaseObject::getClass(ModelNotify::class); + $notificationsManager = DI::notify(); // @TODO: Replace with parameter from router $note = $notificationsManager->getByID($a->argv[2]); if (!empty($note)) { diff --git a/src/Module/Profile.php b/src/Module/Profile.php index eb8becfff5..0515d22e18 100644 --- a/src/Module/Profile.php +++ b/src/Module/Profile.php @@ -133,12 +133,9 @@ class Profile extends BaseModule $category = $datequery = $datequery2 = ''; - /** @var DateTimeFormat $dtFormat */ - $dtFormat = self::getClass(DateTimeFormat::class); - if ($a->argc > 2) { for ($x = 2; $x < $a->argc; $x ++) { - if ($dtFormat->isYearMonth($a->argv[$x])) { + if (DI::dtFormat()->isYearMonth($a->argv[$x])) { if ($datequery) { $datequery2 = Strings::escapeHtml($a->argv[$x]); } else { diff --git a/src/Module/Register.php b/src/Module/Register.php index df7a028166..d079c5c420 100644 --- a/src/Module/Register.php +++ b/src/Module/Register.php @@ -209,7 +209,7 @@ class Register extends BaseModule $user = $result['user']; - $base_url = self::getClass(BaseURL::class)->get(); + $base_url = DI::baseUrl()->get(); if ($netpublish && intval(Config::get('config', 'register_policy')) !== self::APPROVE) { $url = $base_url . '/profile/' . $user['nickname']; diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 4e8a4c63c5..c53c6439c9 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -126,9 +126,7 @@ class Index extends BaseSearchModule // OR your own posts if you are a logged in member // No items will be shown if the member has a blocked profile wall. - /** @var Arguments $args */ - $args = self::getClass(Arguments::class); - $pager = new Pager($args->getQueryString()); + $pager = new Pager(DI::args()->getQueryString()); if ($tag) { Logger::info('Start tag search.', ['q' => $search]); diff --git a/src/Module/Search/Saved.php b/src/Module/Search/Saved.php index 80f84a927c..c2d60bc5a3 100644 --- a/src/Module/Search/Saved.php +++ b/src/Module/Search/Saved.php @@ -2,7 +2,6 @@ namespace Friendica\Module\Search; -use Friendica\App\Arguments; use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Database\DBA; @@ -13,10 +12,7 @@ class Saved extends BaseModule { public static function init(array $parameters = []) { - /** @var Arguments $args */ - $args = self::getClass(Arguments::class); - - $action = $args->get(2, 'none'); + $action = DI::args()->get(2, 'none'); $search = Strings::escapeTags(trim(rawurldecode($_GET['term'] ?? ''))); $return_url = $_GET['return_url'] ?? 'search?q=' . urlencode($search); diff --git a/src/Module/Security/Login.php b/src/Module/Security/Login.php index 5de46903db..dc129e8f66 100644 --- a/src/Module/Security/Login.php +++ b/src/Module/Security/Login.php @@ -7,7 +7,6 @@ namespace Friendica\Module\Security; use Friendica\BaseModule; -use Friendica\App\Authentication; use Friendica\Core\Config; use Friendica\Core\Hook; use Friendica\Core\L10n; @@ -49,15 +48,11 @@ class Login extends BaseModule ) { $openid_url = trim(($_POST['openid_url'] ?? '') ?: $_POST['username']); - /** @var Authentication $authentication */ - $authentication = self::getClass(Authentication::class); - $authentication->withOpenId($openid_url, !empty($_POST['remember'])); + DI::auth()->withOpenId($openid_url, !empty($_POST['remember'])); } if (!empty($_POST['auth-params']) && $_POST['auth-params'] === 'login') { - /** @var Authentication $authentication */ - $authentication = self::getClass(Authentication::class); - $authentication->withPassword( + DI::auth()->withPassword( DI::app(), trim($_POST['username']), trim($_POST['password']), diff --git a/src/Module/Security/TwoFactor/Recovery.php b/src/Module/Security/TwoFactor/Recovery.php index b0f88fcfb7..9a6beb13ad 100644 --- a/src/Module/Security/TwoFactor/Recovery.php +++ b/src/Module/Security/TwoFactor/Recovery.php @@ -42,10 +42,7 @@ class Recovery extends BaseModule Session::set('2fa', true); notice(L10n::t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user()))); - // Resume normal login workflow - /** @var Authentication $authentication */ - $authentication = self::getClass(Authentication::class); - $authentication->setForUser($a, $a->user, true, true); + DI::auth()->setForUser($a, $a->user, true, true); } else { notice(L10n::t('Invalid code, please retry.')); } diff --git a/src/Module/Security/TwoFactor/Verify.php b/src/Module/Security/TwoFactor/Verify.php index 08545b061e..ff494d7ca0 100644 --- a/src/Module/Security/TwoFactor/Verify.php +++ b/src/Module/Security/TwoFactor/Verify.php @@ -40,9 +40,7 @@ class Verify extends BaseModule Session::set('2fa', $code); // Resume normal login workflow - /** @var Authentication $authentication */ - $authentication = self::getClass(Authentication::class); - $authentication->setForUser($a, $a->user, true, true); + DI::auth()->setForUser($a, $a->user, true, true); } else { self::$errors[] = L10n::t('Invalid code, please retry.'); } diff --git a/src/Module/Settings/Delegation.php b/src/Module/Settings/Delegation.php index 78730c3d63..43d4857463 100644 --- a/src/Module/Settings/Delegation.php +++ b/src/Module/Settings/Delegation.php @@ -55,8 +55,7 @@ class Delegation extends BaseSettingsModule throw new HTTPException\ForbiddenException(L10n::t('Permission denied.')); } - /** @var Arguments $args */ - $args = self::getClass(Arguments::class); + $args = DI::args(); // @TODO Replace with router-provided arguments $action = $args->get(2); diff --git a/src/Module/Settings/UserExport.php b/src/Module/Settings/UserExport.php index 643a5998e9..6c06f1133c 100644 --- a/src/Module/Settings/UserExport.php +++ b/src/Module/Settings/UserExport.php @@ -62,7 +62,7 @@ class UserExport extends BaseSettingsModule **/ public static function rawContent(array $parameters = []) { - $args = self::getClass(Arguments::class); + $args = DI::args(); if ($args->getArgc() == 3) { // @TODO Replace with router-provided arguments $action = $args->get(2); diff --git a/src/Network/FKOAuth1.php b/src/Network/FKOAuth1.php index da68410626..26b5637a62 100644 --- a/src/Network/FKOAuth1.php +++ b/src/Network/FKOAuth1.php @@ -4,10 +4,7 @@ */ namespace Friendica\Network; -use Friendica\BaseObject; -use Friendica\App\Authentication; use Friendica\Core\Logger; -use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use OAuthServer; @@ -47,8 +44,6 @@ class FKOAuth1 extends OAuthServer die('This api requires login'); } - /** @var Authentication $authentication */ - $authentication = BaseObject::getClass(Authentication::class); - $authentication->setForUser($a, $record, true); + DI::auth()->setForUser($a, $record, true); } } diff --git a/src/Object/Post.php b/src/Object/Post.php index 7697346390..e5a66a562f 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -4,10 +4,8 @@ */ namespace Friendica\Object; -use Friendica\BaseObject; use Friendica\Content\ContactSelector; use Friendica\Content\Feature; -use Friendica\Content\Item as ContentItem; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\Hook; @@ -33,7 +31,7 @@ use Friendica\Util\Temporal; /** * An item */ -class Post extends BaseObject +class Post { private $data = []; private $template = null; @@ -344,10 +342,7 @@ class Post extends BaseObject $body = Item::prepareBody($item, true); - /** @var ContentItem $contItem */ - $contItem = self::getClass(ContentItem::class); - - list($categories, $folders) = $contItem->determineCategoriesTerms($item); + list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item); $body_e = $body; $text_e = strip_tags($body); @@ -551,8 +546,7 @@ class Post extends BaseObject return false; } - /** @var Activity $activity */ - $activity = self::getClass(Activity::class); + $activity = DI::activity(); /* * Only add what will be displayed diff --git a/src/Object/Thread.php b/src/Object/Thread.php index 35f155ee1c..f88dee2c41 100644 --- a/src/Object/Thread.php +++ b/src/Object/Thread.php @@ -4,7 +4,6 @@ */ namespace Friendica\Object; -use Friendica\BaseObject; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\DI; @@ -16,7 +15,7 @@ use Friendica\Util\Security; * * We should think about making this a SPL Iterator */ -class Thread extends BaseObject +class Thread { private $parents = []; private $mode = null; diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 9bae638511..398ee3ae8f 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -4,7 +4,6 @@ */ namespace Friendica\Protocol\ActivityPub; -use Friendica\BaseObject; use Friendica\Content\Feature; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\Plaintext; diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index f7a8f69390..c20f069567 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -11,7 +11,6 @@ namespace Friendica\Protocol; use DOMDocument; use DOMXPath; use Friendica\App\BaseURL; -use Friendica\BaseObject; use Friendica\Content\OEmbed; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; @@ -21,6 +20,7 @@ use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Conversation; use Friendica\Model\Event; @@ -31,8 +31,6 @@ use Friendica\Model\PermissionSet; use Friendica\Model\Profile; use Friendica\Model\User; use Friendica\Network\Probe; -use Friendica\Object\Image; -use Friendica\Protocol\ActivityNamespace; use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; use Friendica\Util\Images; @@ -2181,8 +2179,7 @@ class DFRN // The functions below are partly used by ostatus.php as well - where we have this variable $contact = Contact::selectFirst([], ['id' => $importer['id']]); - /** @var Activity $activity */ - $activity = BaseObject::getClass(Activity::class); + $activity = DI::activity(); // Big question: Do we need these functions? They were part of the "consume_feed" function. // This function once was responsible for DFRN and OStatus. diff --git a/src/Util/Images.php b/src/Util/Images.php index ec9179147c..7f31dd4383 100644 --- a/src/Util/Images.php +++ b/src/Util/Images.php @@ -2,7 +2,6 @@ namespace Friendica\Util; -use Friendica\BaseObject; use Friendica\Core\Cache; use Friendica\Core\Logger; use Friendica\Core\System; diff --git a/src/Util/Proxy.php b/src/Util/Proxy.php index 0c9c053d0a..dab08b18bb 100644 --- a/src/Util/Proxy.php +++ b/src/Util/Proxy.php @@ -2,7 +2,6 @@ namespace Friendica\Util; -use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Core\System; use Friendica\DI; diff --git a/src/Util/Security.php b/src/Util/Security.php index 043c59d84f..a269ca88c1 100644 --- a/src/Util/Security.php +++ b/src/Util/Security.php @@ -5,7 +5,6 @@ namespace Friendica\Util; -use Friendica\BaseObject; use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Model\Group; @@ -15,7 +14,7 @@ use Friendica\Core\Session; /** * Secures that User is allow to do requests */ -class Security extends BaseObject +class Security { public static function canWriteToUserWall($owner) { diff --git a/src/Worker/APDelivery.php b/src/Worker/APDelivery.php index 812db57013..7ac1dfacaf 100644 --- a/src/Worker/APDelivery.php +++ b/src/Worker/APDelivery.php @@ -4,14 +4,13 @@ */ namespace Friendica\Worker; -use Friendica\BaseObject; use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Model\ItemDeliveryData; use Friendica\Protocol\ActivityPub; use Friendica\Util\HTTPSignature; -class APDelivery extends BaseObject +class APDelivery { /** * @brief Delivers ActivityPub messages diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php index 1a72db53f5..f0c85f6686 100644 --- a/src/Worker/Cron.php +++ b/src/Worker/Cron.php @@ -4,7 +4,6 @@ */ namespace Friendica\Worker; -use Friendica\BaseObject; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\Hook; diff --git a/src/Worker/CronJobs.php b/src/Worker/CronJobs.php index 6c7154957f..e8553ed1c1 100644 --- a/src/Worker/CronJobs.php +++ b/src/Worker/CronJobs.php @@ -5,7 +5,6 @@ namespace Friendica\Worker; use Friendica\App; -use Friendica\BaseObject; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\Logger; diff --git a/src/Worker/DBUpdate.php b/src/Worker/DBUpdate.php index 84159eb433..5f7dfcb796 100644 --- a/src/Worker/DBUpdate.php +++ b/src/Worker/DBUpdate.php @@ -5,12 +5,11 @@ */ namespace Friendica\Worker; -use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Core\Update; use Friendica\DI; -class DBUpdate extends BaseObject +class DBUpdate { public static function execute() { diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index aebc74b185..ef5a7b9f20 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -4,7 +4,6 @@ */ namespace Friendica\Worker; -use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\Logger; @@ -21,7 +20,7 @@ use Friendica\Util\Strings; use Friendica\Util\Network; use Friendica\Core\Worker; -class Delivery extends BaseObject +class Delivery { const MAIL = 'mail'; const SUGGESTION = 'suggest'; diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php index 16a68f6487..4abb6a2267 100644 --- a/src/Worker/Expire.php +++ b/src/Worker/Expire.php @@ -6,7 +6,6 @@ namespace Friendica\Worker; -use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Core\Hook; use Friendica\Core\Logger; diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 91de60ef61..d6bf0ef484 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -4,7 +4,6 @@ */ namespace Friendica\Worker; -use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Core\Hook; use Friendica\Core\Logger; @@ -279,8 +278,7 @@ class Notifier $public_message = false; // private recipients, not public } - /** @var ACLFormatter $aclFormatter */ - $aclFormatter = BaseObject::getClass(ACLFormatter::class); + $aclFormatter = DI::aclFormatter(); $allow_people = $aclFormatter->expand($parent['allow_cid']); $allow_groups = Group::expand($uid, $aclFormatter->expand($parent['allow_gid']),true); diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index f2ba89adf7..107bd34246 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -4,8 +4,6 @@ */ namespace Friendica\Worker; -use Friendica\BaseObject; -use Friendica\Content\Text\BBCode; use Friendica\Core\Config; use Friendica\Core\Logger; use Friendica\Core\PConfig; diff --git a/src/Worker/ProfileUpdate.php b/src/Worker/ProfileUpdate.php index b5ae51bd4b..8bc45ee33a 100644 --- a/src/Worker/ProfileUpdate.php +++ b/src/Worker/ProfileUpdate.php @@ -6,7 +6,6 @@ namespace Friendica\Worker; -use Friendica\BaseObject; use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\DI; diff --git a/tests/Util/AppMockTrait.php b/tests/Util/AppMockTrait.php index f9b026979c..f9a9cb25de 100644 --- a/tests/Util/AppMockTrait.php +++ b/tests/Util/AppMockTrait.php @@ -4,8 +4,8 @@ namespace Friendica\Test\Util; use Dice\Dice; use Friendica\App; -use Friendica\BaseObject; use Friendica\Core\Config; +use Friendica\DI; use Friendica\Render\FriendicaSmartyEngine; use Friendica\Util\Profiler; use Mockery\MockInterface; @@ -109,7 +109,7 @@ trait AppMockTrait return $this->configMock->get('system', 'url'); }); - BaseObject::setDependencyInjection($this->dice); + DI::init($this->dice); if ($raw) { return; diff --git a/tests/include/ApiTest.php b/tests/include/ApiTest.php index 4c9db07089..dcd98fcce9 100644 --- a/tests/include/ApiTest.php +++ b/tests/include/ApiTest.php @@ -7,7 +7,6 @@ namespace Friendica\Test; use Dice\Dice; use Friendica\App; -use Friendica\BaseObject; use Friendica\Core\Config\Configuration; use Friendica\Core\Config\PConfiguration; use Friendica\Core\Protocol; @@ -65,7 +64,7 @@ class ApiTest extends DatabaseTest ->addRules(include __DIR__ . '/../../static/dependencies.config.php') ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]) ->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]); - BaseObject::setDependencyInjection($this->dice); + DI::init($this->dice); /** @var Database $dba */ $dba = $this->dice->create(Database::class); @@ -116,8 +115,7 @@ class ApiTest extends DatabaseTest // User ID that we know is not in the database $this->wrongUserId = 666; - /** @var ISession $session */ - $session = BaseObject::getClass(ISession::class); + $session = DI::session(); $session->start(); // Most API require login so we force the session diff --git a/tests/src/Console/AutomaticInstallationConsoleTest.php b/tests/src/Console/AutomaticInstallationConsoleTest.php index 774db31746..050a5f4420 100644 --- a/tests/src/Console/AutomaticInstallationConsoleTest.php +++ b/tests/src/Console/AutomaticInstallationConsoleTest.php @@ -4,13 +4,13 @@ namespace Friendica\Test\src\Console; use Dice\Dice; use Friendica\App; -use Friendica\BaseObject; use Friendica\Console\AutomaticInstallation; use Friendica\Core\Config\Cache\ConfigCache; use Friendica\Core\Installer; use Friendica\Core\L10n\L10n; use Friendica\Core\Logger; use Friendica\Database\Database; +use Friendica\DI; use Friendica\Test\Util\DBAMockTrait; use Friendica\Test\Util\DBStructureMockTrait; use Friendica\Test\Util\RendererMockTrait; @@ -77,7 +77,7 @@ class AutomaticInstallationConsoleTest extends ConsoleTest ->with(L10n::class) ->andReturn($l10nMock); - BaseObject::setDependencyInjection($this->dice); + DI::init($this->dice); $this->configCache = new ConfigCache(); $this->configCache->set('system', 'basepath', $this->root->url()); diff --git a/tests/src/Core/InstallerTest.php b/tests/src/Core/InstallerTest.php index 3b41e4739c..b2ef92b450 100644 --- a/tests/src/Core/InstallerTest.php +++ b/tests/src/Core/InstallerTest.php @@ -4,10 +4,9 @@ namespace Friendica\Core; use Dice\Dice; -use Friendica\BaseObject; use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\DI; use Friendica\Network\CurlResult; -use Friendica\Object\Image; use Friendica\Test\MockedTest; use Friendica\Test\Util\VFSTrait; use Friendica\Util\Network; @@ -38,7 +37,7 @@ class InstallerTest extends MockedTest ->with(\Friendica\Core\L10n\L10n::class) ->andReturn($this->l10nMock); - BaseObject::setDependencyInjection($dice); + DI::init($dice); } private function mockL10nT(string $text, $times = null) diff --git a/tests/src/Core/Lock/SemaphoreLockTest.php b/tests/src/Core/Lock/SemaphoreLockTest.php index a2291b2c24..8a4baa4fa9 100644 --- a/tests/src/Core/Lock/SemaphoreLockTest.php +++ b/tests/src/Core/Lock/SemaphoreLockTest.php @@ -4,9 +4,9 @@ namespace Friendica\Test\src\Core\Lock; use Dice\Dice; use Friendica\App; -use Friendica\BaseObject; use Friendica\Core\Config\Configuration; use Friendica\Core\Lock\SemaphoreLock; +use Friendica\DI; class SemaphoreLockTest extends LockTest { @@ -26,7 +26,7 @@ class SemaphoreLockTest extends LockTest $dice->shouldReceive('create')->with(Configuration::class)->andReturn($configMock); // @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject - BaseObject::setDependencyInjection($dice); + DI::init($dice); parent::setUp(); } diff --git a/tests/src/Database/DBATest.php b/tests/src/Database/DBATest.php index 9b2a2f122b..15d438b679 100644 --- a/tests/src/Database/DBATest.php +++ b/tests/src/Database/DBATest.php @@ -2,10 +2,10 @@ namespace Friendica\Test\src\Database; use Dice\Dice; -use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Database\Database; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Test\DatabaseTest; use Friendica\Test\Util\Database\StaticDatabase; @@ -18,7 +18,7 @@ class DBATest extends DatabaseTest $dice = (new Dice()) ->addRules(include __DIR__ . '/../../../static/dependencies.config.php') ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]); - BaseObject::setDependencyInjection($dice); + DI::init($dice); // Default config Config::set('config', 'hostname', 'localhost'); diff --git a/tests/src/Database/DBStructureTest.php b/tests/src/Database/DBStructureTest.php index 38c621d4c8..b3f9fb208f 100644 --- a/tests/src/Database/DBStructureTest.php +++ b/tests/src/Database/DBStructureTest.php @@ -3,9 +3,9 @@ namespace Friendica\Test\src\Database; use Dice\Dice; -use Friendica\BaseObject; use Friendica\Database\Database; use Friendica\Database\DBStructure; +use Friendica\DI; use Friendica\Test\DatabaseTest; use Friendica\Test\Util\Database\StaticDatabase; @@ -18,7 +18,7 @@ class DBStructureTest extends DatabaseTest $dice = (new Dice()) ->addRules(include __DIR__ . '/../../../static/dependencies.config.php') ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]); - BaseObject::setDependencyInjection($dice); + DI::init($dice); } /** diff --git a/tests/src/Network/CurlResultTest.php b/tests/src/Network/CurlResultTest.php index 03e415a99b..7f2754a0e5 100644 --- a/tests/src/Network/CurlResultTest.php +++ b/tests/src/Network/CurlResultTest.php @@ -3,7 +3,7 @@ namespace Friendica\Test\src\Network; use Dice\Dice; -use Friendica\BaseObject; +use Friendica\DI; use Friendica\Network\CurlResult; use Mockery\MockInterface; use PHPUnit\Framework\TestCase; @@ -26,7 +26,7 @@ class CurlResultTest extends TestCase ->with(LoggerInterface::class) ->andReturn($logger); - BaseObject::setDependencyInjection($dice); + DI::init($dice); } /**