php-cs: add trailing commas

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/877/head
Varun Patil 2023-10-14 18:59:00 -07:00
parent fb32a94e2e
commit 03c55a8d67
25 changed files with 44 additions and 43 deletions

View File

@ -25,6 +25,7 @@ $config
->setRules([
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'parameters', 'arguments']],
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']], // one should use PHPUnit built-in method instead
'modernize_strpos' => false, // needs PHP 8+ or polyfill
'phpdoc_to_comment' => ['ignored_tags' => ['psalm-suppress', 'template-implements']],

View File

@ -118,7 +118,7 @@ class FaceRecognitionBackend extends Backend
{
$faces = array_merge(
$this->getFaceRecognitionPersons($fileid),
$this->getFaceRecognitionClusters($fileid)
$this->getFaceRecognitionClusters($fileid),
);
// Post process

View File

@ -117,7 +117,7 @@ trait PeopleBackendUtils
(int) ($dcx * $iw - $faceDim / 2),
(int) ($dcy * $ih - $faceDim / 2),
(int) $faceDim,
(int) $faceDim
(int) $faceDim,
);
// Max 512x512

View File

@ -91,7 +91,7 @@ class RecognizeBackend extends Backend
if ('NULL' === $faceName) {
$clusterQuery = $query->expr()->andX(
$query->expr()->eq('rfd.user_id', $query->createNamedParameter(Util::getUID())),
$query->expr()->eq('rfd.cluster_id', $query->expr()->literal(-1))
$query->expr()->eq('rfd.cluster_id', $query->expr()->literal(-1)),
);
} else {
$nameField = is_numeric($faceName) ? 'rfc.id' : 'rfc.title';

View File

@ -119,7 +119,7 @@ class TagsBackend extends Backend
// SELECT all photos with this tag
$query->select('f.fileid', 'f.etag', 'stom.systemtagid')->from(
'systemtag_object_mapping',
'stom'
'stom',
)->where(
$query->expr()->eq('stom.objecttype', $query->expr()->literal('files')),
$query->expr()->eq('stom.systemtagid', $query->createNamedParameter($tagId)),
@ -148,7 +148,7 @@ class TagsBackend extends Backend
$sqb->expr()->andX(
$sqb->expr()->eq('name', $sqb->createNamedParameter($tagName)),
$sqb->expr()->eq('visibility', $sqb->expr()->literal(1, \PDO::PARAM_INT)),
)
),
)->executeQuery()->fetchOne();
if (false === $res) {

View File

@ -58,7 +58,7 @@ class MigrateGoogleTakeout extends Command
protected IConfig $config,
protected IDBConnection $connection,
protected ITempManager $tempManager,
protected TimelineWrite $timelineWrite
protected TimelineWrite $timelineWrite,
) {
parent::__construct();
}

View File

@ -103,7 +103,7 @@ class AdminController extends GenericApiController
/** @psalm-suppress ForbiddenCode */
$status['perl'] = $this->getExecutableStatus(
trim(shell_exec('which perl') ?: '/bin/perl'),
static fn ($p) => BinExt::testSystemPerl($p)
static fn ($p) => BinExt::testSystemPerl($p),
);
// Check number of indexed files
@ -229,7 +229,7 @@ class AdminController extends GenericApiController
$path,
?\Closure $testFunction = null,
bool $testIfFile = true,
bool $testIfExecutable = true
bool $testIfExecutable = true,
): string {
if ($path instanceof \Closure) {
try {

View File

@ -46,7 +46,7 @@ abstract class GenericApiController extends ApiController
protected IAppManager $appManager,
protected LoggerInterface $logger,
protected TimelineQuery $tq,
protected FsManager $fs
protected FsManager $fs,
) {
parent::__construct(Application::APPNAME, $request);
}

View File

@ -49,7 +49,7 @@ class ImageController extends GenericApiController
int $x = 32,
int $y = 32,
bool $a = false,
string $mode = 'fill'
string $mode = 'fill',
): Http\Response {
return Util::guardEx(function () use ($id, $x, $y, $a, $mode) {
if (-1 === $id || 0 === $x || 0 === $y) {
@ -181,7 +181,7 @@ class ImageController extends GenericApiController
bool $basic = false,
bool $current = false,
bool $tags = false,
string $clusters = ''
string $clusters = '',
): Http\Response {
return Util::guardEx(function () use ($id, $basic, $current, $tags, $clusters) {
$file = $this->fs->getUserFile($id);
@ -319,7 +319,7 @@ class ImageController extends GenericApiController
int $height,
?float $quality,
string $extension,
array $state
array $state,
): Http\Response {
return Util::guardEx(function () use ($id, $name, $width, $height, $quality, $extension, $state) {
// Get the file

View File

@ -17,7 +17,7 @@ class PageController extends Controller
{
public function __construct(
IRequest $request,
protected IEventDispatcher $eventDispatcher
protected IEventDispatcher $eventDispatcher,
) {
parent::__construct(Application::APPNAME, $request);
}

View File

@ -33,7 +33,7 @@ class PublicAlbumController extends Controller
protected IRootFolder $rootFolder,
protected IURLGenerator $urlGenerator,
protected AlbumsQuery $albumsQuery,
protected IL10N $l10n
protected IL10N $l10n,
) {
parent::__construct(Application::APPNAME, $request);
}

View File

@ -35,7 +35,7 @@ class PublicController extends AuthPublicShareController
protected IRootFolder $rootFolder,
protected IShareManager $shareManager,
protected IConfig $config,
protected TimelineQuery $tq
protected TimelineQuery $tq,
) {
parent::__construct(Application::APPNAME, $request, $session, $urlGenerator);
}

View File

@ -117,7 +117,7 @@ class VideoController extends GenericApiController
int $fileid,
string $liveid = '',
string $format = '',
string $transcode = ''
string $transcode = '',
): Http\Response {
return Util::guardEx(function () use ($fileid, $liveid, $format, $transcode) {
$file = $this->fs->getUserFile($fileid);

View File

@ -23,7 +23,7 @@ class IndexJob extends TimedJob
private Service\Index $service,
private IUserManager $userManager,
private LoggerInterface $logger,
private IConfig $config
private IConfig $config,
) {
parent::__construct($time);

View File

@ -31,7 +31,7 @@ class AlbumsQuery
'pa.created',
'pa.location',
'pa.last_added_photo',
$count
$count,
)->from('photos_albums', 'pa');
if ($shared) {
@ -100,7 +100,7 @@ class AlbumsQuery
$query->expr()->andX(
$query->expr()->eq('file_id', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)),
$query->expr()->eq('album_id', $query->createNamedParameter($albumId, IQueryBuilder::PARAM_INT)),
)
),
);
return $query->executeQuery()->fetchOne() ?: null;
@ -121,7 +121,7 @@ class AlbumsQuery
$query->expr()->eq('pa.album_id', 'paf.album_id'),
$query->expr()->eq('pc.album_id', 'paf.album_id'),
),
)
),
);
// Check if user-owned album or shared album
@ -162,7 +162,7 @@ class AlbumsQuery
$query->expr()->andX(
$query->expr()->eq('name', $query->createNamedParameter($albumName)),
$query->expr()->eq('user', $query->createNamedParameter($albumUid)),
)
),
);
$album = $query->executeQuery()->fetch();
}
@ -202,7 +202,7 @@ class AlbumsQuery
$query->expr()->andX(
$query->expr()->eq('album_id', $query->createNamedParameter($albumId, IQueryBuilder::PARAM_INT)),
$query->expr()->in('collaborator_id', $query->createNamedParameter($ids, IQueryBuilder::PARAM_STR_ARRAY)),
)
),
);
return false !== $query->executeQuery()->fetchOne();

View File

@ -53,7 +53,7 @@ class FsManager
private IRootFolder $rootFolder,
private AlbumsQuery $albumsQuery,
private IRequest $request,
ICacheFactory $cacheFactory
ICacheFactory $cacheFactory,
) {
$this->nomediaCache = $cacheFactory->createLocal('memories:nomedia');
}

View File

@ -29,7 +29,7 @@ trait TimelineQueryDays
bool $recursive,
bool $archive,
bool $monthView,
array $queryTransforms = []
array $queryTransforms = [],
): array {
$query = $this->connection->getQueryBuilder();
@ -75,7 +75,7 @@ trait TimelineQueryDays
bool $archive,
bool $hidden,
bool $monthView,
array $queryTransforms = []
array $queryTransforms = [],
): array {
// Check if we have any dayIds
if (empty($dayIds)) {
@ -107,7 +107,7 @@ trait TimelineQueryDays
// Convert monthIds to dayIds
$query->andWhere($query->expr()->orX(...array_map(fn ($monthId) => $query->expr()->andX(
$query->expr()->gte('m.dayid', $query->createNamedParameter($monthId, IQueryBuilder::PARAM_INT)),
$query->expr()->lte('m.dayid', $query->createNamedParameter($this->dayIdMonthEnd($monthId), IQueryBuilder::PARAM_INT))
$query->expr()->lte('m.dayid', $query->createNamedParameter($this->dayIdMonthEnd($monthId), IQueryBuilder::PARAM_INT)),
), $dayIds)));
} else {
// Filter by list of dayIds
@ -171,7 +171,7 @@ trait TimelineQueryDays
?TimelineRoot $root = null,
bool $recursive = true,
bool $archive = false,
bool $hidden = false
bool $hidden = false,
): IQueryBuilder {
// Get the timeline root object
if (null === $root) {
@ -315,7 +315,7 @@ trait TimelineQueryDays
IQueryBuilder &$query,
TimelineRoot &$root,
bool $archive,
bool $hidden
bool $hidden,
): void {
// Add query parameters
$query->setParameter('topFolderIds', $root->getIds(), IQueryBuilder::PARAM_INT_ARRAY);

View File

@ -63,8 +63,8 @@ trait TimelineQueryFilters
$query->expr()->eq('type', $query->expr()->literal('files')),
$query->expr()->eq('uid', $query->createNamedParameter(Util::getUID())),
$query->expr()->eq('category', $query->expr()->literal(ITags::TAG_FAVORITE)),
)
)->getSQL()
),
)->getSQL(),
);
}
}

View File

@ -28,14 +28,14 @@ trait TimelineQueryMap
$query->expr()->gte($latCol, $query->createNamedParameter($bounds[0], IQueryBuilder::PARAM_STR)),
$query->expr()->lte($latCol, $query->createNamedParameter($bounds[1], IQueryBuilder::PARAM_STR)),
$query->expr()->gte($lonCol, $query->createNamedParameter($bounds[2], IQueryBuilder::PARAM_STR)),
$query->expr()->lte($lonCol, $query->createNamedParameter($bounds[3], IQueryBuilder::PARAM_STR))
)
$query->expr()->lte($lonCol, $query->createNamedParameter($bounds[3], IQueryBuilder::PARAM_STR)),
),
);
}
public function getMapClusters(
float $gridLen,
string $bounds
string $bounds,
): array {
$query = $this->connection->getQueryBuilder();
@ -93,7 +93,7 @@ trait TimelineQueryMap
->from('memories', 'm')
->where($query->expr()->in('m.mapcluster', $query->createNamedParameter(
$clusterIds,
IQueryBuilder::PARAM_INT_ARRAY
IQueryBuilder::PARAM_INT_ARRAY,
)))
;
@ -145,7 +145,7 @@ trait TimelineQueryMap
// WHERE this photo has coordinates
$query->where($query->expr()->andX(
$query->expr()->isNotNull('m.lat'),
$query->expr()->isNotNull('m.lon')
$query->expr()->isNotNull('m.lon'),
));
// ORDER BY datetaken DESC

View File

@ -43,7 +43,7 @@ class TimelineWrite
public function processFile(
File $file,
bool $lock = true,
bool $force = false
bool $force = false,
): bool {
// Check if we want to process this file
if (!Index::isSupported($file)) {

View File

@ -37,7 +37,7 @@ class PostWriteListener implements IEventListener
{
public function __construct(
private TimelineWrite $tw,
private LoggerInterface $logger
private LoggerInterface $logger,
) {}
public function handle(Event $event): void

View File

@ -188,7 +188,7 @@ class FileRobotMagick
(int) (($this->state->cropWidth ?? 1) * $iw),
(int) (($this->state->cropHeight ?? 1) * $ih),
(int) (($this->state->cropX ?? 0) * $iw),
(int) (($this->state->cropY ?? 0) * $ih)
(int) (($this->state->cropY ?? 0) * $ih),
);
}
}
@ -213,7 +213,7 @@ class FileRobotMagick
$this->state->resizeWidth ?? 0,
$this->state->resizeHeight ?? 0,
\Imagick::FILTER_LANCZOS,
1
1,
);
}
}

View File

@ -56,7 +56,7 @@ class Index
protected TimelineWrite $tw,
protected IDBConnection $db,
protected ITempManager $tempManager,
protected LoggerInterface $logger
protected LoggerInterface $logger,
) {}
/**
@ -145,7 +145,7 @@ class Index
$query->leftJoin('f', $table, $alias, $query->expr()->andX(
$query->expr()->eq('f.fileid', "{$alias}.fileid"),
$query->expr()->eq('f.mtime', "{$alias}.mtime"),
$query->expr()->eq("{$alias}.orphan", $query->expr()->literal(0))
$query->expr()->eq("{$alias}.orphan", $query->expr()->literal(0)),
));
$query->andWhere($query->expr()->isNull("{$alias}.fileid"));

View File

@ -19,7 +19,7 @@ class Places
public function __construct(
protected IConfig $config,
protected IDBConnection $connection,
protected TimelineWrite $tw
protected TimelineWrite $tw,
) {}
/**

View File

@ -11,7 +11,7 @@ class AdminSection implements IIconSection
{
public function __construct(
private IL10N $l,
private IURLGenerator $urlGenerator
private IURLGenerator $urlGenerator,
) {}
/**