OCP\AppFramework\App strict

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-03-09 08:42:03 +01:00
parent a20e9d7891
commit 129a608ebe
No known key found for this signature in database
GPG Key ID: F941078878347C0C
2 changed files with 13 additions and 10 deletions

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@ -55,7 +56,7 @@ class App {
* the transformed app id, defaults to OCA\
* @return string the starting namespace for the app
*/
public static function buildAppNamespace($appId, $topNamespace='OCA\\') {
public static function buildAppNamespace(string $appId, string $topNamespace='OCA\\'): string {
// Hit the cache!
if (isset(self::$nameSpaceCache[$appId])) {
return $topNamespace . self::$nameSpaceCache[$appId];
@ -81,7 +82,7 @@ class App {
* @param DIContainer $container an instance of a pimple container.
* @param array $urlParams list of URL parameters (optional)
*/
public static function main($controllerName, $methodName, DIContainer $container, array $urlParams = null) {
public static function main(string $controllerName, string $methodName, DIContainer $container, array $urlParams = null) {
if (!is_null($urlParams)) {
$container[IRequest::class]->setUrlParameters($urlParams);
} else if (isset($container['urlParams']) && !is_null($container['urlParams'])) {
@ -171,7 +172,7 @@ class App {
* @param array $urlParams an array with variables extracted from the routes
* @param DIContainer $container an instance of a pimple container.
*/
public static function part($controllerName, $methodName, array $urlParams,
public static function part(string $controllerName, string $methodName, array $urlParams,
DIContainer $container){
$container['urlParams'] = $urlParams;

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@ -33,6 +34,7 @@
namespace OCP\AppFramework;
use OC\AppFramework\Routing\RouteConfig;
use OCP\Route\IRouter;
/**
@ -45,6 +47,8 @@ use OC\AppFramework\Routing\RouteConfig;
*/
class App {
/** @var IAppContainer */
private $container;
/**
* Turns an app id into a namespace by convetion. The id is split at the
@ -56,7 +60,7 @@ class App {
* @return string the starting namespace for the app
* @since 8.0.0
*/
public static function buildAppNamespace($appId, $topNamespace='OCA\\') {
public static function buildAppNamespace(string $appId, string $topNamespace='OCA\\'): string {
return \OC\AppFramework\App::buildAppNamespace($appId, $topNamespace);
}
@ -65,17 +69,15 @@ class App {
* @param array $urlParams an array with variables extracted from the routes
* @since 6.0.0
*/
public function __construct($appName, $urlParams = array()) {
public function __construct(string $appName, array $urlParams = []) {
$this->container = new \OC\AppFramework\DependencyInjection\DIContainer($appName, $urlParams);
}
private $container;
/**
* @return IAppContainer
* @since 6.0.0
*/
public function getContainer() {
public function getContainer(): IAppContainer {
return $this->container;
}
@ -98,7 +100,7 @@ class App {
* @since 6.0.0
* @suppress PhanAccessMethodInternal
*/
public function registerRoutes($router, $routes) {
public function registerRoutes(IRouter $router, array $routes) {
$routeConfig = new RouteConfig($this->container, $router, $routes);
$routeConfig->register();
}
@ -134,7 +136,7 @@ class App {
* @param string $methodName the method that you want to call
* @since 6.0.0
*/
public function dispatch($controllerName, $methodName) {
public function dispatch(string $controllerName, string $methodName) {
\OC\AppFramework\App::main($controllerName, $methodName, $this->container);
}
}