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 /apps | |
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 'apps')
-rw-r--r-- | apps/files/lib/helper.php | 11 | ||||
-rw-r--r-- | apps/files_encryption/lib/helper.php | 10 | ||||
-rw-r--r-- | apps/files_external/lib/config.php | 2 | ||||
-rw-r--r-- | apps/files_trashbin/lib/trashbin.php | 35 |
4 files changed, 39 insertions, 19 deletions
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php index e4bfcb4e9ee..aa5a2f8c68a 100644 --- a/apps/files/lib/helper.php +++ b/apps/files/lib/helper.php @@ -8,6 +8,8 @@ namespace OCA\Files; +use OCP\Files\FileInfo; + /** * Helper class for manipulating file information */ @@ -58,7 +60,7 @@ class Helper * @param \OCP\Files\FileInfo $b file * @return int -1 if $a must come before $b, 1 otherwise */ - public static function compareFileNames($a, $b) { + public static function compareFileNames(FileInfo $a, FileInfo $b) { $aType = $a->getType(); $bType = $b->getType(); if ($aType === 'dir' and $bType !== 'dir') { @@ -77,7 +79,7 @@ class Helper * @param \OCP\Files\FileInfo $b file * @return int -1 if $a must come before $b, 1 otherwise */ - public static function compareTimestamp($a, $b) { + public static function compareTimestamp(FileInfo $a, FileInfo $b) { $aTime = $a->getMTime(); $bTime = $b->getMTime(); return $aTime - $bTime; @@ -90,7 +92,7 @@ class Helper * @param \OCP\Files\FileInfo $b file * @return int -1 if $a must come before $b, 1 otherwise */ - public static function compareSize($a, $b) { + public static function compareSize(FileInfo $a, FileInfo $b) { $aSize = $a->getSize(); $bSize = $b->getSize(); return ($aSize < $bSize) ? -1 : 1; @@ -102,7 +104,7 @@ class Helper * @param \OCP\Files\FileInfo $i * @return array formatted file info */ - public static function formatFileInfo($i) { + public static function formatFileInfo(FileInfo $i) { $entry = array(); $entry['id'] = $i['fileid']; @@ -147,6 +149,7 @@ class Helper /** * Format file info for JSON * @param \OCP\Files\FileInfo[] $fileInfos file infos + * @return array */ public static function formatFileInfos($fileInfos) { $files = array(); diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php index 6f4eb4aaf3b..53c380ab2b3 100644 --- a/apps/files_encryption/lib/helper.php +++ b/apps/files_encryption/lib/helper.php @@ -89,7 +89,7 @@ class Helper { * @param string $password * @return bool */ - public static function setupUser($util, $password) { + public static function setupUser(Util $util, $password) { // Check files_encryption infrastructure is ready for action if (!$util->ready()) { @@ -333,7 +333,7 @@ class Helper { * @param string $path * @param \OC\Files\View $view */ - public static function mkdirr($path, $view) { + public static function mkdirr($path, \OC\Files\View $view) { $dirname = \OC\Files\Filesystem::normalizePath(dirname($path)); $dirParts = explode('/', $dirname); $dir = ""; @@ -348,8 +348,10 @@ class Helper { /** * redirect to a error page * @param Session $session + * @param int|null $errorCode + * @throws \Exception */ - public static function redirectToErrorPage($session, $errorCode = null) { + public static function redirectToErrorPage(Session $session, $errorCode = null) { if ($errorCode === null) { $init = $session->getInitialized(); @@ -439,7 +441,7 @@ class Helper { * @param \OC\Files\View $rootView root view, relative to data/ * @return array list of share key files, path relative to data/$user */ - public static function findShareKeys($filePath, $shareKeyPath, $rootView) { + public static function findShareKeys($filePath, $shareKeyPath, \OC\Files\View $rootView) { $result = array(); $user = \OCP\User::getUser(); diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 5378137e1d3..fa44e446d96 100644 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -740,7 +740,7 @@ class OC_Mount_Config { * @param string $backend * @return string */ - private static function getSingleDependencyMessage($l, $module, $backend) { + private static function getSingleDependencyMessage(OC_L10N $l, $module, $backend) { switch (strtolower($module)) { case 'curl': return $l->t('<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.', $backend); diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index 63962296416..3d90791108e 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -434,10 +434,10 @@ class Trashbin { * @param string $filename name of file once it was deleted * @param string $uniqueFilename new file name to restore the file without overwriting existing files * @param string $location location if file - * @param int $timestamp deleteion time - * + * @param int $timestamp deletion time + * @return bool */ - private static function restoreVersions($view, $file, $filename, $uniqueFilename, $location, $timestamp) { + private static function restoreVersions(\OC\Files\View $view, $file, $filename, $uniqueFilename, $location, $timestamp) { if (\OCP\App::isEnabled('files_versions')) { // disable proxy to prevent recursive calls @@ -488,10 +488,10 @@ class Trashbin { * @param string $filename name of file * @param string $uniqueFilename new file name to restore the file without overwriting existing files * @param string $location location of file - * @param int $timestamp deleteion time - * + * @param int $timestamp deletion time + * @return bool */ - private static function restoreEncryptionKeys($view, $file, $filename, $uniqueFilename, $location, $timestamp) { + private static function restoreEncryptionKeys(\OC\Files\View $view, $file, $filename, $uniqueFilename, $location, $timestamp) { // Take care of encryption keys TODO! Get '.key' in file between file name and delete date (also for permanent delete!) if (\OCP\App::isEnabled('files_encryption')) { $user = \OCP\User::getUser(); @@ -639,8 +639,12 @@ class Trashbin { /** * @param \OC\Files\View $view + * @param $file + * @param $filename + * @param $timestamp + * @return int */ - private static function deleteVersions($view, $file, $filename, $timestamp) { + private static function deleteVersions(\OC\Files\View $view, $file, $filename, $timestamp) { $size = 0; if (\OCP\App::isEnabled('files_versions')) { $user = \OCP\User::getUser(); @@ -664,8 +668,12 @@ class Trashbin { /** * @param \OC\Files\View $view + * @param $file + * @param $filename + * @param $timestamp + * @return int */ - private static function deleteEncryptionKeys($view, $file, $filename, $timestamp) { + private static function deleteEncryptionKeys(\OC\Files\View $view, $file, $filename, $timestamp) { $size = 0; if (\OCP\App::isEnabled('files_encryption')) { $user = \OCP\User::getUser(); @@ -879,8 +887,10 @@ class Trashbin { * @param string $source source path, relative to the users files directory * @param string $destination destination path relative to the users root directoy * @param \OC\Files\View $view file view for the users root directory + * @return int + * @throws Exceptions\CopyRecursiveException */ - private static function copy_recursive($source, $destination, $view) { + private static function copy_recursive($source, $destination, \OC\Files\View $view) { $size = 0; if ($view->is_dir($source)) { $view->mkdir($destination); @@ -955,7 +965,7 @@ class Trashbin { * @param \OC\Files\View $view filesystem view relative to users root directory * @return string with unique extension */ - private static function getUniqueFilename($location, $filename, $view) { + private static function getUniqueFilename($location, $filename, \OC\Files\View $view) { $ext = pathinfo($filename, PATHINFO_EXTENSION); $name = pathinfo($filename, PATHINFO_FILENAME); $l = \OC::$server->getL10N('files_trashbin'); @@ -1036,6 +1046,7 @@ class Trashbin { /** * check if trash bin is empty for a given user * @param string $user + * @return bool */ public static function isEmpty($user) { @@ -1050,6 +1061,10 @@ class Trashbin { return true; } + /** + * @param $path + * @return string + */ public static function preview_icon($path) { return \OC_Helper::linkToRoute('core_ajax_trashbin_preview', array('x' => 36, 'y' => 36, 'file' => $path)); } |