11<?php
22
3+ declare (strict_types=1 );
4+
35/**
46 * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
57 * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
68 * SPDX-License-Identifier: AGPL-3.0-only
79 */
810// use OCP namespace for all classes that are considered public.
911// This means that they should be used by apps instead of the internal Nextcloud classes
10-
1112namespace OCP ;
1213
1314use Closure ;
14- use OC \AppFramework \Utility \SimpleContainer ;
1515use Psr \Container \ContainerExceptionInterface ;
1616use Psr \Container \ContainerInterface ;
1717use Psr \Container \NotFoundExceptionInterface ;
2222 * IContainer is the basic interface to be used for any internal dependency injection mechanism
2323 *
2424 * @since 6.0.0
25- * @deprecated 20.0.0 use \Psr\Container\ContainerInterface
2625 */
2726interface IContainer extends ContainerInterface {
27+ /**
28+ * Finds an entry of the container by its identifier and returns it.
29+ *
30+ * @template T
31+ * @param class-string<T>|string $id Identifier of the entry to look for.
32+ *
33+ * @throws NotFoundExceptionInterface No entry was found for **this** identifier.
34+ * @throws ContainerExceptionInterface Error while retrieving the entry.
35+ *
36+ * @return ($id is class-string<T> ? T : mixed) Entry.
37+ * @since 34.0.0
38+ */
39+ public function get (string $ id );
40+
2841 /**
2942 * @template T
3043 *
3144 * If a parameter is not registered in the container try to instantiate it
3245 * by using reflection to find out how to build the class
33- * @param string $name the class name to resolve
34- * @psalm-param string|class-string<T> $name
35- * @return \stdClass
36- * @psalm-return ($name is class-string ? T : mixed)
46+ * @param class-string<T>|string $name
47+ * @return ($name is class-string<T> ? T : mixed)
3748 * @since 8.2.0
38- * @deprecated 20.0.0 use \Psr\Container\ContainerInterface ::get
49+ * @deprecated 20.0.0 use {@see self ::get()}
3950 * @throws ContainerExceptionInterface if the class could not be found or instantiated
4051 */
41- public function resolve ($ name );
52+ public function resolve (string $ name ): mixed ;
4253
4354 /**
4455 * Look up a service for a given name in the container.
4556 *
4657 * @template T
47- *
48- * @param string $name
49- * @psalm-param string|class-string<T> $name
58+ * @param class-string<T>|string $name
5059 * @param bool $autoload Should we try to autoload the service. If we are trying to resolve built in types this makes no sense for example
51- * @return mixed
52- * @psalm-return ($name is class-string ? T : mixed)
60+ * @return ($name is class-string<T> ? T : mixed)
5361 * @throws ContainerExceptionInterface if the query could not be resolved
5462 * @throws NotFoundExceptionInterface if the name could not be found within the container
5563 * @since 6.0.0
56- * @deprecated 20.0.0 use \Psr\Container\ContainerInterface ::get
64+ * @deprecated 20.0.0 use {@see self ::get()}
5765 */
58- public function query (string $ name , bool $ autoload = true );
66+ public function query (string $ name , bool $ autoload = true ): mixed ;
5967
6068 /**
6169 * A value is stored in the container with it's corresponding name
6270 *
63- * @param string $name
64- * @param mixed $value
65- * @return void
6671 * @since 6.0.0
6772 * @deprecated 20.0.0 use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerParameter
6873 */
69- public function registerParameter ($ name , $ value );
74+ public function registerParameter (string $ name , mixed $ value ): void ;
7075
7176 /**
7277 * A service is registered in the container where a closure is passed in which will actually
@@ -75,14 +80,11 @@ public function registerParameter($name, $value);
7580 * memory and be reused on subsequent calls.
7681 * In case the parameter is false the service will be recreated on every call.
7782 *
78- * @param string $name
79- * @param \Closure(SimpleContainer): mixed $closure
80- * @param bool $shared
81- * @return void
83+ * @param \Closure(IContainer): mixed $closure
8284 * @since 6.0.0
8385 * @deprecated 20.0.0 use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerService
8486 */
85- public function registerService ($ name , Closure $ closure , $ shared = true );
87+ public function registerService (string $ name , Closure $ closure , bool $ shared = true ): void ;
8688
8789 /**
8890 * Shortcut for returning a service from a service under a different key,
@@ -93,5 +95,5 @@ public function registerService($name, Closure $closure, $shared = true);
9395 * @since 8.2.0
9496 * @deprecated 20.0.0 use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerServiceAlias
9597 */
96- public function registerAlias ($ alias , $ target );
98+ public function registerAlias (string $ alias , string $ target ): void ;
9799}
0 commit comments