diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2018-03-09 10:13:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-09 10:13:08 +0100 |
commit | 528ffaf2505dabd49e3b9c8ed48fdbd5a23f3ee5 (patch) | |
tree | 21f6abafb134fa530bb4efc6a738f005d8a3f7a5 | |
parent | 81a3ac1226f468f144a0de08ffe062be2abc480d (diff) | |
parent | 129a608ebe80c04a09cc8ad90741ffe46d1e4b9f (diff) | |
download | nextcloud-server-528ffaf2505dabd49e3b9c8ed48fdbd5a23f3ee5.tar.gz nextcloud-server-528ffaf2505dabd49e3b9c8ed48fdbd5a23f3ee5.zip |
Merge pull request #8742 from nextcloud/strict_app
OCP\AppFramework\App strict
-rw-r--r-- | lib/private/AppFramework/App.php | 7 | ||||
-rw-r--r-- | lib/public/AppFramework/App.php | 16 |
2 files changed, 13 insertions, 10 deletions
diff --git a/lib/private/AppFramework/App.php b/lib/private/AppFramework/App.php index 6e8c3736fdb..25708245e26 100644 --- a/lib/private/AppFramework/App.php +++ b/lib/private/AppFramework/App.php @@ -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; diff --git a/lib/public/AppFramework/App.php b/lib/public/AppFramework/App.php index d5a9075fa3e..b6ed2da5076 100644 --- a/lib/public/AppFramework/App.php +++ b/lib/public/AppFramework/App.php @@ -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); } } |