diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-10-24 14:13:40 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-10-24 14:13:40 +0200 |
commit | b3a04840b54464457298807d6609d525d68d8953 (patch) | |
tree | 408d7c8103a788cbb7c714f64649be180f54ed4d /lib/private | |
parent | 77b8e1543a697dbc5fad0bdbbc6bb6c271448066 (diff) | |
download | nextcloud-server-b3a04840b54464457298807d6609d525d68d8953.tar.gz nextcloud-server-b3a04840b54464457298807d6609d525d68d8953.zip |
Add type hinting to functions
It's only reasonable to have proper type hinting here which might even help us to catch bugs.
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/db/mdb2schemamanager.php | 2 | ||||
-rw-r--r-- | lib/private/files.php | 2 | ||||
-rw-r--r-- | lib/private/files/mount/manager.php | 2 | ||||
-rw-r--r-- | lib/private/preview.php | 2 | ||||
-rw-r--r-- | lib/private/server.php | 68 | ||||
-rw-r--r-- | lib/private/util.php | 4 |
6 files changed, 27 insertions, 53 deletions
diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php index 3c367f144db..1f2dbbe70d1 100644 --- a/lib/private/db/mdb2schemamanager.php +++ b/lib/private/db/mdb2schemamanager.php @@ -147,7 +147,7 @@ class MDB2SchemaManager { * @param \Doctrine\DBAL\Schema\Schema $schema * @return bool */ - private function executeSchemaChange($schema) { + private function executeSchemaChange(\Doctrine\DBAL\Schema\Schema $schema) { $this->conn->beginTransaction(); foreach ($schema->toSql($this->conn->getDatabasePlatform()) as $sql) { $this->conn->query($sql); diff --git a/lib/private/files.php b/lib/private/files.php index a983f6f32f5..571d3215caa 100644 --- a/lib/private/files.php +++ b/lib/private/files.php @@ -195,7 +195,7 @@ class OC_Files { * @param ZipStreamer $zip * @param string $internalDir */ - public static function zipAddDir($dir, $zip, $internalDir='') { + public static function zipAddDir($dir, ZipStreamer $zip, $internalDir='') { $dirname=basename($dir); $rootDir = $internalDir.$dirname; if (!empty($rootDir)) { diff --git a/lib/private/files/mount/manager.php b/lib/private/files/mount/manager.php index e5180cfe173..0ccf42941de 100644 --- a/lib/private/files/mount/manager.php +++ b/lib/private/files/mount/manager.php @@ -19,7 +19,7 @@ class Manager { /** * @param Mount $mount */ - public function addMount($mount) { + public function addMount(Mount $mount) { $this->mounts[$mount->getMountPoint()] = $mount; } diff --git a/lib/private/preview.php b/lib/private/preview.php index f8b19f11cb0..dbbe173bf80 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -779,7 +779,7 @@ class Preview { * @param \OC\Files\FileInfo $file * @return bool */ - public static function isAvailable($file) { + public static function isAvailable(\OC\Files\FileInfo $file) { if (!\OC_Config::getValue('enable_previews', true)) { return false; } diff --git a/lib/private/server.php b/lib/private/server.php index b0d63af1554..ac0eb7b4cf9 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -72,15 +72,15 @@ class Server extends SimpleContainer implements IServerContainer { $this->registerService('PreviewManager', function ($c) { return new PreviewManager(); }); - $this->registerService('TagMapper', function($c) { + $this->registerService('TagMapper', function(Server $c) { return new TagMapper($c->getDb()); }); - $this->registerService('TagManager', function ($c) { + $this->registerService('TagManager', function (Server $c) { $tagMapper = $c->query('TagMapper'); $user = \OC_User::getUser(); return new TagManager($tagMapper, $user); }); - $this->registerService('RootFolder', function ($c) { + $this->registerService('RootFolder', function (Server $c) { // TODO: get user and user manager from container as well $user = \OC_User::getUser(); /** @var $c SimpleContainer */ @@ -90,28 +90,16 @@ class Server extends SimpleContainer implements IServerContainer { $view = new View(); return new Root($manager, $view, $user); }); - $this->registerService('UserManager', function ($c) { - /** - * @var SimpleContainer $c - * @var \OC\AllConfig $config - */ - $config = $c->query('AllConfig'); + $this->registerService('UserManager', function (Server $c) { + $config = $c->getConfig(); return new \OC\User\Manager($config); }); - $this->registerService('GroupManager', function ($c) { - /** - * @var SimpleContainer $c - * @var \OC\User\Manager $userManager - */ - $userManager = $c->query('UserManager'); + $this->registerService('GroupManager', function (Server $c) { + $userManager = $c->getUserManager(); return new \OC\Group\Manager($userManager); }); - $this->registerService('UserSession', function ($c) { - /** - * @var SimpleContainer $c - * @var \OC\User\Manager $manager - */ - $manager = $c->query('UserManager'); + $this->registerService('UserSession', function (Server $c) { + $manager = $c->getUserManager(); $userSession = new \OC\User\Session($manager, new \OC\Session\Memory('')); $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); @@ -160,9 +148,8 @@ class Server extends SimpleContainer implements IServerContainer { $this->registerService('L10NFactory', function ($c) { return new \OC\L10N\Factory(); }); - $this->registerService('URLGenerator', function ($c) { - /** @var $c SimpleContainer */ - $config = $c->query('AllConfig'); + $this->registerService('URLGenerator', function (Server $c) { + $config = $c->getConfig(); return new \OC\URLGenerator($config); }); $this->registerService('AppHelper', function ($c) { @@ -181,7 +168,7 @@ class Server extends SimpleContainer implements IServerContainer { $this->registerService('AvatarManager', function ($c) { return new AvatarManager(); }); - $this->registerService('Logger', function ($c) { + $this->registerService('Logger', function (Server $c) { /** @var $c SimpleContainer */ $logClass = $c->query('AllConfig')->getSystemValue('log_type', 'owncloud'); $logger = 'OC_Log_' . ucfirst($logClass); @@ -189,17 +176,11 @@ class Server extends SimpleContainer implements IServerContainer { return new Log($logger); }); - $this->registerService('JobList', function ($c) { - /** - * @var Server $c - */ + $this->registerService('JobList', function (Server $c) { $config = $c->getConfig(); return new \OC\BackgroundJob\JobList($c->getDatabaseConnection(), $config); }); - $this->registerService('Router', function ($c) { - /** - * @var Server $c - */ + $this->registerService('Router', function (Server $c) { $cacheFactory = $c->getMemCacheFactory(); if ($cacheFactory->isAvailable()) { $router = new \OC\Route\CachingRouter($cacheFactory->create('route')); @@ -214,13 +195,10 @@ class Server extends SimpleContainer implements IServerContainer { $this->registerService('SecureRandom', function ($c) { return new SecureRandom(); }); - $this->registerService('Crypto', function ($c) { - return new Crypto(\OC::$server->getConfig(), \OC::$server->getSecureRandom()); + $this->registerService('Crypto', function (Server $c) { + return new Crypto($c->getConfig(), $c->getSecureRandom()); }); - $this->registerService('DatabaseConnection', function ($c) { - /** - * @var Server $c - */ + $this->registerService('DatabaseConnection', function (Server $c) { $factory = new \OC\DB\ConnectionFactory(); $type = $c->getConfig()->getSystemValue('dbtype', 'sqlite'); if (!$factory->isValidType($type)) { @@ -231,18 +209,14 @@ class Server extends SimpleContainer implements IServerContainer { $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); return $connection; }); - $this->registerService('Db', function ($c) { - /** - * @var Server $c - */ + $this->registerService('Db', function (Server $c) { return new Db($c->getDatabaseConnection()); }); - $this->registerService('HTTPHelper', function (SimpleContainer $c) { - $config = $c->query('AllConfig'); + $this->registerService('HTTPHelper', function (Server $c) { + $config = $c->getConfig(); return new HTTPHelper($config); }); - $this->registerService('EventLogger', function ($c) { - /** @var Server $c */ + $this->registerService('EventLogger', function (Server $c) { if (defined('DEBUG') and DEBUG) { return new EventLogger(); } else { diff --git a/lib/private/util.php b/lib/private/util.php index 858138f58fe..d600f8a5e64 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -420,7 +420,7 @@ class OC_Util { * @param \OCP\IConfig $config * @return array arrays with error messages and hints */ - public static function checkServer($config) { + public static function checkServer(\OCP\IConfig $config) { $l = \OC::$server->getL10N('lib'); $errors = array(); $CONFIG_DATADIRECTORY = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data'); @@ -1309,7 +1309,7 @@ class OC_Util { * @param \OCP\IConfig $config * @return bool whether the core or any app needs an upgrade */ - public static function needUpgrade($config) { + public static function needUpgrade(\OCP\IConfig $config) { if ($config->getSystemValue('installed', false)) { $installedVersion = $config->getSystemValue('version', '0.0.0'); $currentVersion = implode('.', OC_Util::getVersion()); |