From 89bda46890fcdc12281b8272b9b590a2195a0014 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Wed, 19 Oct 2022 10:15:14 -0700 Subject: [PATCH] More lint --- lib/Command/Index.php | 3 +-- lib/Controller/ApiController.php | 11 +++++------ lib/Controller/PageController.php | 3 +-- lib/Db/TimelineQuery.php | 4 ++-- lib/Db/TimelineQueryDays.php | 14 +++++++------- lib/Db/TimelineQueryFaces.php | 20 ++++++++++---------- lib/Db/TimelineQueryTags.php | 12 ++++++------ lib/Db/TimelineWrite.php | 2 +- lib/Listeners/PostWriteListener.php | 3 +-- 9 files changed, 34 insertions(+), 38 deletions(-) diff --git a/lib/Command/Index.php b/lib/Command/Index.php index 2b033dec..6a908a5f 100644 --- a/lib/Command/Index.php +++ b/lib/Command/Index.php @@ -72,8 +72,7 @@ class Index extends Command IManager $encryptionManager, IDBConnection $connection, ContainerInterface $container - ) - { + ) { parent::__construct(); $this->userManager = $userManager; diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index eab6dd05..b4f1cd44 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -63,8 +63,7 @@ class ApiController extends Controller IRootFolder $rootFolder, IAppManager $appManager, IPreview $previewManager - ) - { + ) { parent::__construct(Application::APPNAME, $request); $this->config = $config; @@ -369,10 +368,10 @@ class ApiController extends Controller $image->readImageBlob($preview->getContent()); $iw = $image->getImageWidth(); $ih = $image->getImageHeight(); - $dw = (float) ($detection['width']); - $dh = (float) ($detection['height']); - $dcx = (float) ($detection['x']) + (float) ($detection['width']) / 2; - $dcy = (float) ($detection['y']) + (float) ($detection['height']) / 2; + $dw = (float) $detection['width']; + $dh = (float) $detection['height']; + $dcx = (float) $detection['x'] + (float) $detection['width'] / 2; + $dcy = (float) $detection['y'] + (float) $detection['height'] / 2; $faceDim = max($dw * $iw, $dh * $ih) * 1.5; $image->cropImage( (int) $faceDim, diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 2a3adfdf..9187818f 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -35,8 +35,7 @@ class PageController extends Controller IInitialState $initialState, IUserSession $userSession, IConfig $config - ) - { + ) { parent::__construct($AppName, $request); $this->userId = $UserId; $this->appName = $AppName; diff --git a/lib/Db/TimelineQuery.php b/lib/Db/TimelineQuery.php index 62a19fed..f4d798c0 100644 --- a/lib/Db/TimelineQuery.php +++ b/lib/Db/TimelineQuery.php @@ -41,8 +41,8 @@ class TimelineQuery } return [ - 'fileid' => (int) ($row['fileid']), - 'dayid' => (int) ($row['dayid']), + 'fileid' => (int) $row['fileid'], + 'dayid' => (int) $row['dayid'], 'datetaken' => $utcTs, ]; } diff --git a/lib/Db/TimelineQueryDays.php b/lib/Db/TimelineQueryDays.php index e8e0e31d..f1844a2e 100644 --- a/lib/Db/TimelineQueryDays.php +++ b/lib/Db/TimelineQueryDays.php @@ -120,8 +120,8 @@ trait TimelineQueryDays private function processDays(&$days) { foreach ($days as &$row) { - $row['dayid'] = (int) ($row['dayid']); - $row['count'] = (int) ($row['count']); + $row['dayid'] = (int) $row['dayid']; + $row['count'] = (int) $row['count']; // All transform processing $this->processFace($row, true); @@ -142,11 +142,11 @@ trait TimelineQueryDays unset($row['datetaken']); // Convert field types - $row['fileid'] = (int) ($row['fileid']); - $row['isvideo'] = (int) ($row['isvideo']); - $row['dayid'] = (int) ($row['dayid']); - $row['w'] = (int) ($row['w']); - $row['h'] = (int) ($row['h']); + $row['fileid'] = (int) $row['fileid']; + $row['isvideo'] = (int) $row['isvideo']; + $row['dayid'] = (int) $row['dayid']; + $row['w'] = (int) $row['w']; + $row['h'] = (int) $row['h']; if (!$row['isvideo']) { unset($row['isvideo']); } diff --git a/lib/Db/TimelineQueryFaces.php b/lib/Db/TimelineQueryFaces.php index ca5af177..6a9f1a6b 100644 --- a/lib/Db/TimelineQueryFaces.php +++ b/lib/Db/TimelineQueryFaces.php @@ -77,10 +77,10 @@ trait TimelineQueryFaces // Post process foreach ($faces as &$row) { - $row['id'] = (int) ($row['id']); + $row['id'] = (int) $row['id']; $row['name'] = $row['title']; unset($row['title']); - $row['count'] = (int) ($row['count']); + $row['count'] = (int) $row['count']; } return $faces; @@ -128,12 +128,12 @@ trait TimelineQueryFaces // Get actual pixel size of face $iw = min((int) ($p['image_width'] ?: 512), 2048); $ih = min((int) ($p['image_height'] ?: 512), 2048); - $w = (float) ($p['width']) * $iw; - $h = (float) ($p['height']) * $ih; + $w = (float) $p['width'] * $iw; + $h = (float) $p['height'] * $ih; // Get center of face - $x = (float) ($p['x']) + (float) ($p['width']) / 2; - $y = (float) ($p['y']) + (float) ($p['height']) / 2; + $x = (float) $p['x'] + (float) $p['width'] / 2; + $y = (float) $p['y'] + (float) $p['height'] / 2; // 3D normal distribution - if the face is closer to the center, it's better $positionScore = exp(-($x - 0.5) ** 2 * 4) * exp(-($y - 0.5) ** 2 * 4); @@ -163,10 +163,10 @@ trait TimelineQueryFaces if (!$days) { $row['facerect'] = [ - 'w' => (float) ($row['face_w']), - 'h' => (float) ($row['face_h']), - 'x' => (float) ($row['face_x']), - 'y' => (float) ($row['face_y']), + 'w' => (float) $row['face_w'], + 'h' => (float) $row['face_h'], + 'x' => (float) $row['face_x'], + 'y' => (float) $row['face_y'], ]; } diff --git a/lib/Db/TimelineQueryTags.php b/lib/Db/TimelineQueryTags.php index 6b026068..d5a82d48 100644 --- a/lib/Db/TimelineQueryTags.php +++ b/lib/Db/TimelineQueryTags.php @@ -70,8 +70,8 @@ trait TimelineQueryTags // Post process foreach ($tags as &$row) { - $row['id'] = (int) ($row['id']); - $row['count'] = (int) ($row['count']); + $row['id'] = (int) $row['id']; + $row['count'] = (int) $row['count']; } return $tags; @@ -89,8 +89,8 @@ trait TimelineQueryTags 'systemtag_object_mapping', 'stom' )->where( - $query->expr()->eq('stom.objecttype', $query->createNamedParameter('files')), - ); + $query->expr()->eq('stom.objecttype', $query->createNamedParameter('files')), + ); // WHERE these items are memories indexed photos $query->innerJoin('stom', 'memories', 'm', $query->expr()->eq('m.fileid', 'stom.objectid')); @@ -113,8 +113,8 @@ trait TimelineQueryTags // Post-process foreach ($previews as &$row) { - $row['fileid'] = (int) ($row['fileid']); - $row['systemtagid'] = (int) ($row['systemtagid']); + $row['fileid'] = (int) $row['fileid']; + $row['systemtagid'] = (int) $row['systemtagid']; unset($row['n']); } diff --git a/lib/Db/TimelineWrite.php b/lib/Db/TimelineWrite.php index 87945074..d6b050f7 100644 --- a/lib/Db/TimelineWrite.php +++ b/lib/Db/TimelineWrite.php @@ -71,7 +71,7 @@ class TimelineWrite $cursor = $query->executeQuery(); $prevRow = $cursor->fetch(); $cursor->closeCursor(); - if ($prevRow && !$force && (int) ($prevRow['mtime']) === $mtime) { + if ($prevRow && !$force && (int) $prevRow['mtime'] === $mtime) { return 1; } diff --git a/lib/Listeners/PostWriteListener.php b/lib/Listeners/PostWriteListener.php index 131bd8fe..30c69564 100644 --- a/lib/Listeners/PostWriteListener.php +++ b/lib/Listeners/PostWriteListener.php @@ -37,8 +37,7 @@ class PostWriteListener implements IEventListener public function __construct( IDBConnection $connection, IUserManager $userManager - ) - { + ) { $this->userManager = $userManager; $this->timelineWrite = new TimelineWrite($connection); }