From b228716613ca4cbab2e9721ee6d2bd27c6003703 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Wed, 29 Oct 2014 18:06:05 +0300 Subject: [PATCH] Fix some issues found by code inspector --- controller/sessioncontroller.php | 3 +-- lib/db.php | 2 +- lib/downloadresponse.php | 9 ++++++++- lib/file.php | 7 +++++++ lib/genesis.php | 2 +- lib/helper.php | 20 ++++++++++++++++---- 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/controller/sessioncontroller.php b/controller/sessioncontroller.php index 9891a395..2c3a3eab 100644 --- a/controller/sessioncontroller.php +++ b/controller/sessioncontroller.php @@ -123,7 +123,7 @@ class SessionController extends Controller{ } try { - $file = new File($session->getFileId()); + new File($session->getFileId()); } catch (\Exception $e){ $this->logger->warning('Error. Session no longer exists. ' . $e->getMessage(), array('app' => $this->appName)); $ex = new BadRequestException(); @@ -199,7 +199,6 @@ class SessionController extends Controller{ implode(',', $this->request->getParams()) ); throw $ex; - break; } } catch (BadRequestException $e){ $response->setStatus(Http::STATUS_BAD_REQUEST); diff --git a/lib/db.php b/lib/db.php index 48bd720b..b4bdac40 100644 --- a/lib/db.php +++ b/lib/db.php @@ -48,7 +48,7 @@ abstract class Db { /** * Get single record by primary key - * @param type $value primary key value + * @param int $value primary key value * @return \OCA\Documents\Db */ public function load($value){ diff --git a/lib/downloadresponse.php b/lib/downloadresponse.php index 618aea9f..acd47df5 100644 --- a/lib/downloadresponse.php +++ b/lib/downloadresponse.php @@ -12,13 +12,19 @@ namespace OCA\Documents; use \OCP\AppFramework\Http; +use \OCP\IRequest; class DownloadResponse extends \OCP\AppFramework\Http\Response { private $request; private $view; private $path; - public function __construct($request, $user, $path) { + /** + * @param IRequest $request + * @param string $user + * @param string $path + */ + public function __construct(IRequest $request, $user, $path) { $this->request = $request; $this->user = $user; $this->path = $path; @@ -90,6 +96,7 @@ class DownloadResponse extends \OCP\AppFramework\Http\Response { /** * Send 416 if we can't satisfy the requested ranges + * @param integer $filesize */ protected function sendRangeNotSatisfiable($filesize){ $this->setStatus(Http::STATUS_REQUEST_RANGE_NOT_SATISFIABLE); diff --git a/lib/file.php b/lib/file.php index cc30a728..18699bd9 100644 --- a/lib/file.php +++ b/lib/file.php @@ -93,6 +93,10 @@ class File { return $this->passwordProtected; } + /** + * @param string $password + * @return boolean + */ public function checkPassword($password){ $shareId = $this->sharing[0]['id']; if (!$this->isPasswordProtected() @@ -119,6 +123,9 @@ class File { return false; } + /** + * @param boolean $value + */ public function setPasswordProtected($value){ $this->passwordProtected = $value; } diff --git a/lib/genesis.php b/lib/genesis.php index f1293364..65a92942 100644 --- a/lib/genesis.php +++ b/lib/genesis.php @@ -35,7 +35,7 @@ class Genesis { /** * Create new genesis document - * @param OCA\Documents\File $file + * @param File $file * */ public function __construct(\OCA\Documents\File $file){ list($view, $path) = $file->getOwnerViewAndPath(); diff --git a/lib/helper.php b/lib/helper.php index dc2ae3a5..a351672f 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -43,6 +43,10 @@ class Helper { return '#' . str_pad($str, 6, "0", STR_PAD_LEFT); } + /** + * @param string $name + * @return string + */ public static function getMemberColor($name){ $hash = md5($name); $maxRange = hexdec('ffffffffffffffffffffffffffffffff'); @@ -50,22 +54,30 @@ class Helper { return '#' . self::convertHSLToRGB($hue, 90, 60); } + /** + * @param string $message + */ public static function debugLog($message){ self::log($message, \OCP\Util::DEBUG); } + /** + * @param string $message + */ public static function warnLog($message){ self::log($message, \OCP\Util::WARN); } - public static function errorLog($message){ - self::log($message, \OCP\Util::ERROR); - } - public static function log($message, $level){ \OCP\Util::writeLog(self::APP_ID, $message, $level); } + /** + * @param integer $iH + * @param integer $iS + * @param integer $iV + * @return string + */ protected static function convertHSLToRGB($iH, $iS, $iV){ if ($iH < 0){ $iH = 0; // Hue: