Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/dav/lib/CalDAV/CalendarHome.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OCP\App\IAppManager;
use OCP\IConfig;
use OCP\IL10N;
use OCP\L10N\IFactory;
use OCP\Server;
use Psr\Log\LoggerInterface;
use Sabre\CalDAV\Backend\BackendInterface;
Expand Down Expand Up @@ -49,7 +50,7 @@ public function __construct(
private bool $returnCachedSubscriptions,
) {
parent::__construct($caldavBackend, $principalInfo);
$this->l10n = \OC::$server->getL10N('dav');
$this->l10n = Server::get(IFactory::class)->get('dav');
$this->config = Server::get(IConfig::class);
$this->pluginManager = new PluginManager(
\OC::$server,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Server;
use Psr\Log\LoggerInterface;
use Sabre\VObject\ITip\Message;
Expand All @@ -45,7 +46,7 @@ public function __construct(bool $public = true) {
$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));

// Add maintenance plugin
$this->server->addPlugin(new MaintenancePlugin(Server::get(IConfig::class), \OC::$server->getL10N('dav')));
$this->server->addPlugin(new MaintenancePlugin(Server::get(IConfig::class), Server::get(IFactory::class)->get('dav')));

// Set URL explicitly due to reverse-proxy situations
$this->server->httpRequest->setUrl($baseUri);
Expand Down
11 changes: 3 additions & 8 deletions apps/dav/lib/Connector/Sabre/MaintenancePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

class MaintenancePlugin extends ServerPlugin {

/** @var IL10N */
private $l10n;

/**
* Reference to main server object
*
Expand All @@ -30,10 +27,9 @@ class MaintenancePlugin extends ServerPlugin {
* @param IConfig $config
*/
public function __construct(
private IConfig $config,
IL10N $l10n,
private readonly IConfig $config,
private readonly IL10N $l10n,
) {
$this->l10n = \OC::$server->getL10N('dav');
}


Expand All @@ -59,9 +55,8 @@ public function initialize(\Sabre\DAV\Server $server) {
* in case the system is in maintenance mode.
*
* @throws ServiceUnavailable
* @return bool
*/
public function checkMaintenanceMode() {
public function checkMaintenanceMode(): bool {
if ($this->config->getSystemValueBool('maintenance')) {
throw new ServerMaintenanceMode($this->l10n->t('System is in maintenance mode.'));
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

class RootCollection extends SimpleCollection {
public function __construct() {
$l10n = \OC::$server->getL10N('dav');
$l10n = Server::get(IFactory::class)->get('dav');
$random = Server::get(ISecureRandom::class);
$logger = Server::get(LoggerInterface::class);
$userManager = Server::get(IUserManager::class);
Expand Down
5 changes: 3 additions & 2 deletions apps/dav/lib/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
use OCP\ITagManager;
use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Mail\IEmailValidator;
use OCP\Mail\IMailer;
use OCP\Profiler\IProfiler;
Expand Down Expand Up @@ -132,7 +133,7 @@ public function __construct(
$this->server->setLogger($logger);

// Add maintenance plugin
$this->server->addPlugin(new MaintenancePlugin(\OCP\Server::get(IConfig::class), \OC::$server->getL10N('dav')));
$this->server->addPlugin(new MaintenancePlugin(\OCP\Server::get(IConfig::class), \OCP\Server::get(IFactory::class)->get('dav')));

$this->server->addPlugin(new AppleQuirksPlugin());

Expand Down Expand Up @@ -398,7 +399,7 @@ public function __construct(
\OCP\Server::get(IURLGenerator::class),
\OCP\Server::get(ThemingDefaults::class),
\OCP\Server::get(IRequest::class),
\OC::$server->getL10N('dav'),
\OCP\Server::get(IFactory::class)->get('dav'),
function () {
return UUIDUtil::getUUID();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\DBConfigService;
use OCA\Files_External\Service\StoragesService;
use OCP\AppFramework\IAppContainer;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Cache\ICache;
use OCP\Files\Config\IUserMountCache;
Expand Down Expand Up @@ -127,14 +126,6 @@ protected function setUp(): void {
Filesystem::CLASSNAME,
Filesystem::signal_delete_mount,
get_class($this), 'deleteHookCallback');

$containerMock = $this->createMock(IAppContainer::class);
$containerMock->method('query')
->willReturnCallback(function ($name) {
if ($name === 'OCA\Files_External\Service\BackendService') {
return $this->backendService;
}
});
}

protected function tearDown(): void {
Expand Down
4 changes: 2 additions & 2 deletions apps/files_sharing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ public function registerEventsScripts(IEventDispatcher $dispatcher): void {
// notifications api to accept incoming user shares
$dispatcher->addListener(ShareCreatedEvent::class, function (ShareCreatedEvent $event): void {
/** @var Listener $listener */
$listener = $this->getContainer()->query(Listener::class);
$listener = $this->getContainer()->get(Listener::class);
$listener->shareNotification($event);
});
$dispatcher->addListener(IGroup::class . '::postAddUser', function ($event): void {
if (!$event instanceof OldGenericEvent) {
return;
}
/** @var Listener $listener */
$listener = $this->getContainer()->query(Listener::class);
$listener = $this->getContainer()->get(Listener::class);
$listener->userAddedToGroup($event);
});
}
Expand Down
4 changes: 2 additions & 2 deletions apps/settings/tests/AppInfo/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use OCA\Settings\Controller\UsersController;
use OCA\Settings\Middleware\SubadminMiddleware;
use OCP\AppFramework\Controller;
use OCP\AppFramework\IAppContainer;
use OCP\AppFramework\Middleware;
use Psr\Container\ContainerInterface;
use Test\TestCase;

/**
Expand All @@ -28,7 +28,7 @@
#[\PHPUnit\Framework\Attributes\Group(name: 'DB')]
class ApplicationTest extends TestCase {
protected Application $app;
protected IAppContainer $container;
protected ContainerInterface $container;

protected function setUp(): void {
parent::setUp();
Expand Down
4 changes: 2 additions & 2 deletions apps/systemtags/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function boot(IBootContext $context): void {
$context->injectFn(function (IEventDispatcher $dispatcher) use ($context): void {
$managerListener = function (ManagerEvent $event) use ($context): void {
/** @var Listener $listener */
$listener = $context->getServerContainer()->query(Listener::class);
$listener = $context->getServerContainer()->get(Listener::class);
$listener->event($event);
};
$dispatcher->addListener(ManagerEvent::EVENT_CREATE, $managerListener);
Expand All @@ -55,7 +55,7 @@ public function boot(IBootContext $context): void {

$mapperListener = function (MapperEvent $event) use ($context): void {
/** @var Listener $listener */
$listener = $context->getServerContainer()->query(Listener::class);
$listener = $context->getServerContainer()->get(Listener::class);
$listener->mapperEvent($event);
};
$dispatcher->addListener(MapperEvent::EVENT_ASSIGN, $mapperListener);
Expand Down
6 changes: 3 additions & 3 deletions apps/theming/tests/ServicesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
use OCP\AppFramework\App;
use OCP\AppFramework\IAppContainer;
use OCP\Capabilities\ICapability;
use OCP\IL10N;
use OCP\Settings\IIconSection;
use OCP\Settings\ISettings;
use Psr\Container\ContainerInterface;
use Test\TestCase;

/**
Expand All @@ -30,7 +30,7 @@
class ServicesTest extends TestCase {
protected App $app;

protected IAppContainer $container;
protected ContainerInterface $container;

protected function setUp(): void {
parent::setUp();
Expand Down Expand Up @@ -65,6 +65,6 @@ public function testContainerQuery(string $service, ?string $expected = null): v
if ($expected === null) {
$expected = $service;
}
$this->assertInstanceOf($expected, $this->container->query($service));
$this->assertInstanceOf($expected, $this->container->get($service));
}
}
5 changes: 2 additions & 3 deletions apps/user_ldap/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\IAppContainer;
use OCP\AppFramework\Services\IAppConfig;
use OCP\Config\IUserConfig;
use OCP\EventDispatcher\IEventDispatcher;
Expand Down Expand Up @@ -85,7 +84,7 @@ function (ContainerInterface $c) {
public function boot(IBootContext $context): void {
$context->injectFn(function (
INotificationManager $notificationManager,
IAppContainer $appContainer,
ContainerInterface $appContainer,
IEventDispatcher $dispatcher,
IUserManager $userManager,
IGroupManager $groupManager,
Expand Down Expand Up @@ -119,7 +118,7 @@ public function boot(IBootContext $context): void {
);
}

private function registerBackendDependents(IAppContainer $appContainer, IEventDispatcher $dispatcher): void {
private function registerBackendDependents(ContainerInterface $appContainer, IEventDispatcher $dispatcher): void {
$dispatcher->addListener(
'OCA\\Files_External::loadAdditionalBackends',
function () use ($appContainer): void {
Expand Down
3 changes: 2 additions & 1 deletion apps/user_status/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(OutOfOfficeStartedEvent::class, OutOfOfficeStatusListener::class);
$context->registerEventListener(OutOfOfficeEndedEvent::class, OutOfOfficeStatusListener::class);

$config = $this->getContainer()->query(IConfig::class);
/** @var IConfig $config */
$config = $this->getContainer()->get(IConfig::class);
$shareeEnumeration = $config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
$shareeEnumerationInGroupOnly = $shareeEnumeration && $config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes';
$shareeEnumerationPhone = $shareeEnumeration && $config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_phone', 'no') === 'yes';
Expand Down
33 changes: 0 additions & 33 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,6 @@
</DeprecatedMethod>
</file>
<file src="apps/dav/lib/CalDAV/CalendarHome.php">
<DeprecatedMethod>
<code><![CDATA[getL10N]]></code>
</DeprecatedMethod>
<InvalidNullableReturnType>
<code><![CDATA[INode]]></code>
</InvalidNullableReturnType>
Expand Down Expand Up @@ -284,11 +281,6 @@
<code><![CDATA[fread($this->source, $end - $start)]]></code>
</FalsableReturnStatement>
</file>
<file src="apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php">
<DeprecatedMethod>
<code><![CDATA[getL10N]]></code>
</DeprecatedMethod>
</file>
<file src="apps/dav/lib/CalDAV/Outbox.php">
<DeprecatedMethod>
<code><![CDATA[getAppValue]]></code>
Expand Down Expand Up @@ -760,11 +752,6 @@
<code><![CDATA[getPath]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="apps/dav/lib/Connector/Sabre/MaintenancePlugin.php">
<DeprecatedMethod>
<code><![CDATA[getL10N]]></code>
</DeprecatedMethod>
</file>
<file src="apps/dav/lib/Connector/Sabre/Node.php">
<InternalMethod>
<code><![CDATA[changeLock]]></code>
Expand Down Expand Up @@ -993,11 +980,6 @@
<code><![CDATA[setAppValue]]></code>
</DeprecatedMethod>
</file>
<file src="apps/dav/lib/RootCollection.php">
<DeprecatedMethod>
<code><![CDATA[getL10N]]></code>
</DeprecatedMethod>
</file>
<file src="apps/dav/lib/Search/ACalendarSearchProvider.php">
<UndefinedMagicPropertyFetch>
<code><![CDATA[$component->{'RECURRENCE-ID'}]]></code>
Expand Down Expand Up @@ -1044,8 +1026,6 @@
<code><![CDATA[dispatch]]></code>
<code><![CDATA[getAppValue]]></code>
<code><![CDATA[getAppValue]]></code>
<code><![CDATA[getL10N]]></code>
<code><![CDATA[getL10N]]></code>
<code><![CDATA[getUserFolder]]></code>
<code><![CDATA[getUserFolder]]></code>
</DeprecatedMethod>
Expand Down Expand Up @@ -1634,10 +1614,6 @@
</ConstructorSignatureMismatch>
</file>
<file src="apps/files_sharing/lib/AppInfo/Application.php">
<DeprecatedMethod>
<code><![CDATA[query]]></code>
<code><![CDATA[query]]></code>
</DeprecatedMethod>
<RedundantCondition>
<code><![CDATA[$event instanceof OldGenericEvent]]></code>
</RedundantCondition>
Expand Down Expand Up @@ -2486,10 +2462,6 @@
<code><![CDATA[MapperEvent::EVENT_ASSIGN]]></code>
<code><![CDATA[MapperEvent::EVENT_UNASSIGN]]></code>
</DeprecatedConstant>
<DeprecatedMethod>
<code><![CDATA[query]]></code>
<code><![CDATA[query]]></code>
</DeprecatedMethod>
</file>
<file src="apps/systemtags/lib/Controller/LastUsedController.php">
<DeprecatedMethod>
Expand Down Expand Up @@ -2710,10 +2682,6 @@
</RedundantCast>
</file>
<file src="apps/user_ldap/lib/AppInfo/Application.php">
<DeprecatedInterface>
<code><![CDATA[IAppContainer]]></code>
<code><![CDATA[IAppContainer]]></code>
</DeprecatedInterface>
<DeprecatedMethod>
<code><![CDATA[Util::connectHook(
'\OCA\Files_Sharing\API\Server2Server',
Expand Down Expand Up @@ -2843,7 +2811,6 @@
<code><![CDATA[getAppValue]]></code>
<code><![CDATA[getAppValue]]></code>
<code><![CDATA[getAppValue]]></code>
<code><![CDATA[query]]></code>
</DeprecatedMethod>
<UndefinedInterfaceMethod>
<code><![CDATA[registerProvider]]></code>
Expand Down
8 changes: 4 additions & 4 deletions lib/private/AppFramework/Bootstrap/BootContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
namespace OC\AppFramework\Bootstrap;

use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\IAppContainer;
use OCP\IServerContainer;
use Psr\Container\ContainerInterface;

class BootContext implements IBootContext {
public function __construct(
private IAppContainer $appContainer,
private ContainerInterface $appContainer,
) {
}

#[\Override]
public function getAppContainer(): IAppContainer {
public function getAppContainer(): ContainerInterface {
return $this->appContainer;
}

#[\Override]
public function getServerContainer(): IServerContainer {
public function getServerContainer(): ContainerInterface {
return $this->appContainer->get(IServerContainer::class);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/private/AppFramework/Bootstrap/FunctionInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace OC\AppFramework\Bootstrap;

use Closure;
use OCP\AppFramework\QueryException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use ReflectionFunction;
use ReflectionParameter;
Expand All @@ -28,14 +28,14 @@ public function injectFn(callable $fn) {
if (($type = $param->getType()) !== null) {
try {
return $this->container->get($type->getName());
} catch (QueryException $ex) {
} catch (ContainerExceptionInterface) {
// Ignore and try name as well
}
}
// Second we try by name (mostly for primitives)
try {
return $this->container->get($param->getName());
} catch (QueryException $ex) {
} catch (ContainerExceptionInterface $ex) {
// As a last resort we pass `null` if allowed
if ($type !== null && $type->allowsNull()) {
return null;
Expand Down
Loading
Loading