Przeglądaj źródła

Merge pull request #23377 from nextcloud/enhancement/psalm-annotate-icontainer

Annotate IContainer so Psalm knows what resove and query return
tags/v21.0.0beta1
Morris Jobke 3 lat temu
rodzic
commit
9979b6d4e0
No account linked to committer's email address

+ 1
- 1
apps/workflowengine/lib/Manager.php Wyświetl plik

} }


/** /**
* @return IEntity[]
* @return ICheck[]
*/ */
protected function getBuildInChecks(): array { protected function getBuildInChecks(): array {
try { try {

+ 1
- 0
lib/base.php Wyświetl plik

} }


private static function registerAppRestrictionsHooks() { private static function registerAppRestrictionsHooks() {
/** @var \OC\Group\Manager $groupManager */
$groupManager = self::$server->query(\OCP\IGroupManager::class); $groupManager = self::$server->query(\OCP\IGroupManager::class);
$groupManager->listen('\OC\Group', 'postDelete', function (\OCP\IGroup $group) { $groupManager->listen('\OC\Group', 'postDelete', function (\OCP\IGroup $group) {
$appManager = self::$server->getAppManager(); $appManager = self::$server->getAppManager();

+ 7
- 2
lib/private/AppFramework/App.php Wyświetl plik



use OC\AppFramework\DependencyInjection\DIContainer; use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\Http\Dispatcher; use OC\AppFramework\Http\Dispatcher;
use OC\AppFramework\Http\Request;
use OC\HintException; use OC\HintException;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\AppFramework\Http\ICallbackResponse; use OCP\AppFramework\Http\ICallbackResponse;
*/ */
public static function main(string $controllerName, string $methodName, DIContainer $container, array $urlParams = null) { public static function main(string $controllerName, string $methodName, DIContainer $container, array $urlParams = null) {
if (!is_null($urlParams)) { if (!is_null($urlParams)) {
$container->query(IRequest::class)->setUrlParameters($urlParams);
/** @var Request $request */
$request = $container->query(IRequest::class);
$request->setUrlParameters($urlParams);
} elseif (isset($container['urlParams']) && !is_null($container['urlParams'])) { } elseif (isset($container['urlParams']) && !is_null($container['urlParams'])) {
$container->query(IRequest::class)->setUrlParameters($container['urlParams']);
/** @var Request $request */
$request = $container->query(IRequest::class);
$request->setUrlParameters($container['urlParams']);
} }
$appName = $container['AppName']; $appName = $container['AppName'];



+ 2
- 2
lib/private/Collaboration/Collaborators/Search.php Wyświetl plik

foreach ($this->pluginList[$type] as $plugin) { foreach ($this->pluginList[$type] as $plugin) {
/** @var ISearchPlugin $searchPlugin */ /** @var ISearchPlugin $searchPlugin */
$searchPlugin = $this->c->resolve($plugin); $searchPlugin = $this->c->resolve($plugin);
$hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
$hasMoreResults = $searchPlugin->search($search, $limit, $offset, $searchResult) || $hasMoreResults;
} }
} }


// Get from lookup server, not a separate share type // Get from lookup server, not a separate share type
if ($lookup) { if ($lookup) {
$searchPlugin = $this->c->resolve(LookupPlugin::class); $searchPlugin = $this->c->resolve(LookupPlugin::class);
$hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
$hasMoreResults = $searchPlugin->search($search, $limit, $offset, $searchResult) || $hasMoreResults;
} }


// sanitizing, could go into the plugins as well // sanitizing, could go into the plugins as well

+ 8
- 0
lib/public/IContainer.php Wyświetl plik

interface IContainer extends ContainerInterface { interface IContainer extends ContainerInterface {


/** /**
* @template T
*
* If a parameter is not registered in the container try to instantiate it * If a parameter is not registered in the container try to instantiate it
* by using reflection to find out how to build the class * by using reflection to find out how to build the class
* @param string $name the class name to resolve * @param string $name the class name to resolve
* @psalm-param string|class-string<T> $name
* @return \stdClass * @return \stdClass
* @psalm-return ($name is class-string ? T : mixed)
* @since 8.2.0 * @since 8.2.0
* @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get
* @throws ContainerExceptionInterface if the class could not be found or instantiated * @throws ContainerExceptionInterface if the class could not be found or instantiated
/** /**
* Look up a service for a given name in the container. * Look up a service for a given name in the container.
* *
* @template T
*
* @param string $name * @param string $name
* @psalm-param string|class-string<T> $name
* @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 * @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
* @return mixed * @return mixed
* @psalm-return ($name is class-string ? T : mixed)
* @throws ContainerExceptionInterface if the query could not be resolved * @throws ContainerExceptionInterface if the query could not be resolved
* @throws QueryException if the query could not be resolved * @throws QueryException if the query could not be resolved
* @since 6.0.0 * @since 6.0.0

Ładowanie…
Anuluj
Zapisz