From 89e0763d3d511d2da878db43c89300c51850b0f3 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 28 Feb 2014 13:37:41 +0100 Subject: [PATCH 1/4] Update PHPDoc for I10N, OC_Config, OC\Template\Base and OCP\IL10N --- lib/private/l10n.php | 31 +++++++++++++++---------------- lib/private/legacy/config.php | 6 +++--- lib/private/template/base.php | 4 ++-- lib/public/il10n.php | 12 ++++++------ 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/lib/private/l10n.php b/lib/private/l10n.php index ad979a92870..b98ccc9d58b 100644 --- a/lib/private/l10n.php +++ b/lib/private/l10n.php @@ -73,9 +73,9 @@ class OC_L10N implements \OCP\IL10N { /** * get an L10N instance - * @param $app string - * @param $lang string|null - * @return OC_L10N + * @param string $app + * @param string|null $lang + * @return \OC_L10N */ public static function get($app, $lang=null) { if (is_null($lang)) { @@ -87,9 +87,8 @@ class OC_L10N implements \OCP\IL10N { /** * @brief The constructor - * @param $app string app requesting l10n - * @param $lang string default: null Language - * @returns OC_L10N-Object + * @param string $app app requesting l10n + * @param string $lang default: null Language * * If language is not set, the constructor tries to find the right * language. @@ -237,7 +236,7 @@ class OC_L10N implements \OCP\IL10N { /** * @brief Translating - * @param $text String The text we need a translation for + * @param string $text The text we need a translation for * @param array $parameters default:array() Parameters for sprintf * @return \OC_L10N_String Translation or the same text * @@ -250,9 +249,9 @@ class OC_L10N implements \OCP\IL10N { /** * @brief Translating - * @param $text_singular String the string to translate for exactly one object - * @param $text_plural String the string to translate for n objects - * @param $count Integer Number of objects + * @param string $text_singular the string to translate for exactly one object + * @param string $text_plural the string to translate for n objects + * @param integer $count Number of objects * @param array $parameters default:array() Parameters for sprintf * @return \OC_L10N_String Translation or the same text * @@ -351,8 +350,8 @@ class OC_L10N implements \OCP\IL10N { /** * @brief Localization - * @param $type Type of localization - * @param $params parameters for this localization + * @param string $type Type of localization + * @param array $params parameters for this localization * @returns String or false * * Returns the localized data. @@ -406,7 +405,7 @@ class OC_L10N implements \OCP\IL10N { /** * @brief Choose a language - * @param $texts Associative Array with possible strings + * @param array $texts Associative Array with possible strings * @returns String * * $text is an array 'de' => 'hallo welt', 'en' => 'hello world', ... @@ -421,7 +420,7 @@ class OC_L10N implements \OCP\IL10N { /** * @brief find the best language - * @param $app Array or string, details below + * @param array|string $app Array or string, details below * @returns string language * * If $app is an array, ownCloud assumes that these are the available @@ -494,7 +493,7 @@ class OC_L10N implements \OCP\IL10N { /** * @brief find the l10n directory - * @param $app App that needs to be translated + * @param string $app App that needs to be translated * @returns directory */ protected static function findI18nDir($app) { @@ -514,7 +513,7 @@ class OC_L10N implements \OCP\IL10N { /** * @brief find all available languages for an app - * @param $app App that needs to be translated + * @param string $app App that needs to be translated * @returns array an array of available languages */ public static function findAvailableLanguages($app=null) { diff --git a/lib/private/legacy/config.php b/lib/private/legacy/config.php index ab67c8d3020..6c2103179ab 100644 --- a/lib/private/legacy/config.php +++ b/lib/private/legacy/config.php @@ -63,8 +63,8 @@ class OC_Config { /** * @brief Gets a value from config.php * @param string $key key - * @param string $default = null default value - * @return string the value or $default + * @param mixed $default = null default value + * @return mixed the value or $default * * This function gets the value from config.php. If it does not exist, * $default will be returned. @@ -76,7 +76,7 @@ class OC_Config { /** * @brief Sets a value * @param string $key key - * @param string $value value + * @param mixed $value value * * This function sets the value and writes the config.php. * diff --git a/lib/private/template/base.php b/lib/private/template/base.php index 232a29939cc..8af2fce7737 100644 --- a/lib/private/template/base.php +++ b/lib/private/template/base.php @@ -61,7 +61,7 @@ class Base { /** * @brief Assign variables * @param string $key key - * @param string $value value + * @param mixed $value value * @return bool * * This function assigns a variable. It can be accessed via $_[$key] in @@ -77,7 +77,7 @@ class Base { /** * @brief Appends a variable * @param string $key key - * @param string $value value + * @param mixed $value value * @return boolean|null * * This function assigns a variable in an array context. If the key already diff --git a/lib/public/il10n.php b/lib/public/il10n.php index 1c025e7824f..bba52b4c4bb 100644 --- a/lib/public/il10n.php +++ b/lib/public/il10n.php @@ -23,7 +23,7 @@ namespace OCP; interface IL10N { /** * Translating - * @param $text String The text we need a translation for + * @param string $text The text we need a translation for * @param array $parameters default:array() Parameters for sprintf * @return \OC_L10N_String Translation or the same text * @@ -34,9 +34,9 @@ interface IL10N { /** * Translating - * @param $text_singular String the string to translate for exactly one object - * @param $text_plural String the string to translate for n objects - * @param $count Integer Number of objects + * @param string $text_singular the string to translate for exactly one object + * @param string $text_plural the string to translate for n objects + * @param Integer $count Number of objects * @param array $parameters default:array() Parameters for sprintf * @return \OC_L10N_String Translation or the same text * @@ -51,8 +51,8 @@ interface IL10N { /** * Localization - * @param $type Type of localization - * @param $params parameters for this localization + * @param string $type Type of localization + * @param array $params parameters for this localization * @return String or false * * Returns the localized data. From 35a8dfb2fa7970098e6677f7b93b7d782d5df7f0 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 28 Feb 2014 13:53:41 +0100 Subject: [PATCH 2/4] More PHPDoc fixes, using scrutinizer patches as hints --- lib/private/appconfig.php | 4 ++-- lib/private/cache.php | 2 +- lib/private/contactsmanager.php | 4 ++-- lib/private/db.php | 5 ++--- lib/private/image.php | 2 +- lib/private/legacy/appconfig.php | 2 -- lib/private/request.php | 2 +- lib/private/share/mailnotifications.php | 3 +-- lib/public/contacts/imanager.php | 4 ++-- lib/public/iappconfig.php | 5 ++--- tests/lib/appframework/routing/RoutingTest.php | 6 +++--- tests/lib/dbschema.php | 3 +++ 12 files changed, 20 insertions(+), 22 deletions(-) diff --git a/lib/private/appconfig.php b/lib/private/appconfig.php index cdaaebb87e5..cfb84309c67 100644 --- a/lib/private/appconfig.php +++ b/lib/private/appconfig.php @@ -218,8 +218,8 @@ class AppConfig implements \OCP\IAppConfig { /** * get multiply values, either the app or key can be used as wildcard by setting it to false * - * @param boolean $app - * @param string $key + * @param string|false $app + * @param string|false $key * @return array */ public function getValues($app, $key) { diff --git a/lib/private/cache.php b/lib/private/cache.php index a311f10a00f..961270c334c 100644 --- a/lib/private/cache.php +++ b/lib/private/cache.php @@ -97,7 +97,7 @@ class Cache { /** * creates cache key based on the files given - * @param $files + * @param string[] $files * @return string */ static public function generateCacheKeyFromFiles($files) { diff --git a/lib/private/contactsmanager.php b/lib/private/contactsmanager.php index fc6745b4505..1cb3da7098f 100644 --- a/lib/private/contactsmanager.php +++ b/lib/private/contactsmanager.php @@ -47,7 +47,7 @@ namespace OC { * This function can be used to delete the contact identified by the given id * * @param object $id the unique identifier to a contact - * @param $address_book_key + * @param string $address_book_key identifier of the address book in which the contact shall be deleted * @return bool successful or not */ public function delete($id, $address_book_key) { @@ -66,7 +66,7 @@ namespace OC { * Otherwise the contact will be updated by replacing the entire data set. * * @param array $properties this array if key-value-pairs defines a contact - * @param $address_book_key string to identify the address book in which the contact shall be created or updated + * @param string $address_book_key identifier of the address book in which the contact shall be created or updated * @return array representing the contact just created or updated */ public function createOrUpdate($properties, $address_book_key) { diff --git a/lib/private/db.php b/lib/private/db.php index cfdac766bff..322a13642ae 100644 --- a/lib/private/db.php +++ b/lib/private/db.php @@ -313,9 +313,8 @@ class OC_DB { /** * @brief Insert a row if a matching row doesn't exists. - * @param string $table. The table to insert into in the form '*PREFIX*tableName' - * @param array $input. An array of fieldname/value pairs - * @param string $table + * @param string $table The table to insert into in the form '*PREFIX*tableName' + * @param array $input An array of fieldname/value pairs * @return boolean number of updated rows */ public static function insertIfNotExist($table, $input) { diff --git a/lib/private/image.php b/lib/private/image.php index 17caaa012f5..e0397ec8a00 100644 --- a/lib/private/image.php +++ b/lib/private/image.php @@ -34,7 +34,7 @@ class OC_Image { /** * @brief Get mime type for an image file. - * @param string|null $filepath The path to a local image file. + * @param string|null $filePath The path to a local image file. * @returns string The mime type if the it could be determined, otherwise an empty string. */ static public function getMimeTypeForFile($filePath) { diff --git a/lib/private/legacy/appconfig.php b/lib/private/legacy/appconfig.php index b6c3542a673..cb5cef7e350 100644 --- a/lib/private/legacy/appconfig.php +++ b/lib/private/legacy/appconfig.php @@ -116,8 +116,6 @@ class OC_Appconfig { /** * get multiply values, either the app or key can be used as wildcard by setting it to false * - * @param app - * @param key * @param string|false $app * @param string|false $key * @return array diff --git a/lib/private/request.php b/lib/private/request.php index afd3fda4f2d..59a9e395e85 100755 --- a/lib/private/request.php +++ b/lib/private/request.php @@ -26,7 +26,7 @@ class OC_Request { /** * @brief Checks whether a domain is considered as trusted. This is used to prevent Host Header Poisoning. - * @param string $host + * @param string $domain * @return bool */ public static function isTrustedDomain($domain) { diff --git a/lib/private/share/mailnotifications.php b/lib/private/share/mailnotifications.php index 360376294cc..afbf35aa397 100644 --- a/lib/private/share/mailnotifications.php +++ b/lib/private/share/mailnotifications.php @@ -30,7 +30,6 @@ class MailNotifications { /** * - * @param string $recipient user id * @param string $sender user id (if nothing is set we use the currently logged-in user) */ public function __construct($sender = null) { @@ -113,7 +112,7 @@ class MailNotifications { * @param string $filename the shared file * @param string $link the public link * @param int $expiration expiration date (timestamp) - * @return mixed $result true or error message + * @return string|boolean $result true or error message */ public function sendLinkShareMail($recipient, $filename, $link, $expiration) { $subject = (string)$this->l->t('%s shared »%s« with you', array($this->senderDisplayName, $filename)); diff --git a/lib/public/contacts/imanager.php b/lib/public/contacts/imanager.php index 5b9d64ecc41..005b71f298b 100644 --- a/lib/public/contacts/imanager.php +++ b/lib/public/contacts/imanager.php @@ -96,7 +96,7 @@ namespace OCP\Contacts { * This function can be used to delete the contact identified by the given id * * @param object $id the unique identifier to a contact - * @param $address_book_key + * @param string $address_book_key identifier of the address book in which the contact shall be deleted * @return bool successful or not */ function delete($id, $address_book_key); @@ -106,7 +106,7 @@ namespace OCP\Contacts { * Otherwise the contact will be updated by replacing the entire data set. * * @param array $properties this array if key-value-pairs defines a contact - * @param $address_book_key string to identify the address book in which the contact shall be created or updated + * @param string $address_book_key identifier of the address book in which the contact shall be created or updated * @return array representing the contact just created or updated */ function createOrUpdate($properties, $address_book_key); diff --git a/lib/public/iappconfig.php b/lib/public/iappconfig.php index 1f31898bf2c..2b014df2e42 100644 --- a/lib/public/iappconfig.php +++ b/lib/public/iappconfig.php @@ -55,9 +55,8 @@ interface IAppConfig { /** * get multiply values, either the app or key can be used as wildcard by setting it to false * - * @param app - * @param key - * @param string $key + * @param string|false $key + * @param string|false $app * @return array */ public function getValues($app, $key); diff --git a/tests/lib/appframework/routing/RoutingTest.php b/tests/lib/appframework/routing/RoutingTest.php index d0244cf2511..56e625fd168 100644 --- a/tests/lib/appframework/routing/RoutingTest.php +++ b/tests/lib/appframework/routing/RoutingTest.php @@ -166,9 +166,9 @@ class RouteConfigTest extends \PHPUnit_Framework_TestCase } /** - * @param $verb - * @param $controllerName - * @param $actionName + * @param string $verb + * @param string $controllerName + * @param string $actionName * @return \PHPUnit_Framework_MockObject_MockObject */ private function mockRoute($verb, $controllerName, $actionName) diff --git a/tests/lib/dbschema.php b/tests/lib/dbschema.php index 11e9fcdf4fa..cfa2d6fd9aa 100644 --- a/tests/lib/dbschema.php +++ b/tests/lib/dbschema.php @@ -71,6 +71,9 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase { $this->assertTableNotExist($this->table2); } + /** + * @param string $table + */ public function tableExist($table) { switch (OC_Config::getValue( 'dbtype', 'sqlite' )) { From e2286c659860b107e0d2791a231eb7b4ab3dca98 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 28 Feb 2014 14:37:20 +0100 Subject: [PATCH 3/4] Type is with a small letter --- lib/public/il10n.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/public/il10n.php b/lib/public/il10n.php index bba52b4c4bb..276e5d6a554 100644 --- a/lib/public/il10n.php +++ b/lib/public/il10n.php @@ -36,7 +36,7 @@ interface IL10N { * Translating * @param string $text_singular the string to translate for exactly one object * @param string $text_plural the string to translate for n objects - * @param Integer $count Number of objects + * @param integer $count Number of objects * @param array $parameters default:array() Parameters for sprintf * @return \OC_L10N_String Translation or the same text * From 8951328a87c16e5ebfe4d3e5c392347db1e54f92 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 28 Feb 2014 21:03:43 +0100 Subject: [PATCH 4/4] More PHPDoc updates --- lib/private/l10n.php | 9 +++++---- lib/private/server.php | 2 +- lib/public/il10n.php | 2 +- lib/public/iservercontainer.php | 2 +- settings/admin/controller.php | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/private/l10n.php b/lib/private/l10n.php index b98ccc9d58b..f0b4f9a70f6 100644 --- a/lib/private/l10n.php +++ b/lib/private/l10n.php @@ -351,7 +351,7 @@ class OC_L10N implements \OCP\IL10N { /** * @brief Localization * @param string $type Type of localization - * @param array $params parameters for this localization + * @param array $data parameters for this localization * @returns String or false * * Returns the localized data. @@ -413,9 +413,9 @@ class OC_L10N implements \OCP\IL10N { * This function is useful to avoid loading thousands of files if only one * simple string is needed, for example in appinfo.php */ - public static function selectLanguage($text) { - $lang = self::findLanguage(array_keys($text)); - return $text[$lang]; + public static function selectLanguage($texts) { + $lang = self::findLanguage(array_keys($texts)); + return $texts[$lang]; } /** @@ -533,6 +533,7 @@ class OC_L10N implements \OCP\IL10N { /** * @param string $lang + * @param string $app */ public static function languageExists($app, $lang) { if ($lang == 'en') {//english is always available diff --git a/lib/private/server.php b/lib/private/server.php index 7696fc207fd..3255713e12a 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -290,7 +290,7 @@ class Server extends SimpleContainer implements IServerContainer { /** * get an L10N instance - * @param $app string appid + * @param string $app appid * @return \OC_L10N */ function getL10N($app) { diff --git a/lib/public/il10n.php b/lib/public/il10n.php index 276e5d6a554..1388274c21a 100644 --- a/lib/public/il10n.php +++ b/lib/public/il10n.php @@ -52,7 +52,7 @@ interface IL10N { /** * Localization * @param string $type Type of localization - * @param array $params parameters for this localization + * @param array $data parameters for this localization * @return String or false * * Returns the localized data. diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index 5fb51f9ecd5..0eb358816d2 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -122,7 +122,7 @@ interface IServerContainer { /** * get an L10N instance - * @param $app string appid + * @param string $app appid * @return \OCP\IL10N */ function getL10N($app); diff --git a/settings/admin/controller.php b/settings/admin/controller.php index a075d774361..1a73c8fad3f 100644 --- a/settings/admin/controller.php +++ b/settings/admin/controller.php @@ -76,8 +76,8 @@ class Controller { /** * Get the field name to use it in error messages * - * @param $setting string - * @param $l \OC_L10N + * @param string $setting + * @param \OC_L10N $l * @return string */ public static function getFieldname($setting, $l) {