diff --git a/lib/private/AppFramework/Bootstrap/ServiceFactoryRegistration.php b/lib/private/AppFramework/Bootstrap/ServiceFactoryRegistration.php index a3195bb1b32f5..1b1c986b66733 100644 --- a/lib/private/AppFramework/Bootstrap/ServiceFactoryRegistration.php +++ b/lib/private/AppFramework/Bootstrap/ServiceFactoryRegistration.php @@ -8,13 +8,15 @@ */ namespace OC\AppFramework\Bootstrap; +use OC\AppFramework\Utility\SimpleContainer; + /** * @psalm-immutable */ class ServiceFactoryRegistration extends ARegistration { /** * @var callable - * @psalm-var callable(\Psr\Container\ContainerInterface): mixed + * @psalm-var callable(SimpleContainer): mixed */ private $factory; @@ -36,7 +38,7 @@ public function getName(): string { } /** - * @psalm-return callable(\Psr\Container\ContainerInterface): mixed + * @psalm-return callable(SimpleContainer): mixed */ public function getFactory(): callable { return $this->factory; diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index f5a2b6f84b7a9..7aade20c65891 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -37,10 +37,7 @@ public function __construct() { /** * @template T * @param class-string|string $id - * @return T|mixed - * @psalm-template S as class-string|string - * @psalm-param S $id - * @psalm-return (S is class-string ? T : mixed) + * @return ($id is class-string ? T : mixed) */ public function get(string $id): mixed { return $this->query($id); @@ -172,15 +169,6 @@ public function registerParameter($name, $value) { $this[$name] = $value; } - /** - * The given closure is call the first time the given service is queried. - * The closure has to return the instance for the given service. - * Created instance will be cached in case $shared is true. - * - * @param string $name name of the service to register another backend for - * @param Closure $closure the closure to be called on service creation - * @param bool $shared - */ public function registerService($name, Closure $closure, $shared = true) { $wrapped = function () use ($closure) { return $closure($this); diff --git a/lib/private/Server.php b/lib/private/Server.php index a0c309e5f1248..f608d3ee26d28 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -958,7 +958,7 @@ public function __construct( $this->registerService(ILockingProvider::class, function (ContainerInterface $c) { $ini = $c->get(IniGetWrapper::class); $config = $c->get(IConfig::class); - $ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); + $ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, (int)($ini->getNumeric('max_execution_time') ?? 0))); if ($config->getSystemValueBool('filelocking.enabled', true) || (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { /** @var Factory $memcacheFactory */ $memcacheFactory = $c->get(ICacheFactory::class); @@ -1212,7 +1212,9 @@ public function __construct( }); $this->registerService(ISession::class, function (ContainerInterface $c) { - return $c->get(IUserSession::class)->getSession(); + /** @var Session $session */ + $session = $c->get(IUserSession::class); + return $session->getSession(); }, false); $this->registerService(IShareHelper::class, function (ContainerInterface $c) { diff --git a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php index 70b35228c87b5..5a9785297c2a5 100644 --- a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php +++ b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php @@ -9,6 +9,7 @@ namespace OCP\AppFramework\Bootstrap; +use OC\AppFramework\Utility\SimpleContainer; use OCP\AppFramework\IAppContainer; use OCP\Authentication\TwoFactorAuth\IProvider; use OCP\Calendar\ICalendarProvider; @@ -68,7 +69,7 @@ public function registerDashboardWidget(string $widgetClass): void; * * @param string $name * @param callable $factory - * @psalm-param callable(\Psr\Container\ContainerInterface): mixed $factory + * @psalm-param callable(SimpleContainer): mixed $factory * @param bool $shared If set to true the factory result will be cached otherwise every query will call the factory again * * @return void diff --git a/lib/public/IContainer.php b/lib/public/IContainer.php index f125fabafe19c..9db3069f87f1d 100644 --- a/lib/public/IContainer.php +++ b/lib/public/IContainer.php @@ -11,6 +11,7 @@ namespace OCP; use Closure; +use OC\AppFramework\Utility\SimpleContainer; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; @@ -75,7 +76,7 @@ public function registerParameter($name, $value); * In case the parameter is false the service will be recreated on every call. * * @param string $name - * @param \Closure $closure + * @param \Closure(SimpleContainer): mixed $closure * @param bool $shared * @return void * @since 6.0.0