chore: update php-cs-fixer

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/803/head
Varun Patil 2023-08-30 11:10:08 -07:00
parent 5cffbf2197
commit f1ed890480
23 changed files with 48 additions and 48 deletions

View File

@ -99,7 +99,7 @@ class AlbumsBackend extends Backend
// Remove elements with duplicate album_id
$seenIds = [];
$list = array_filter($list, function ($item) use (&$seenIds) {
$list = array_filter($list, static function ($item) use (&$seenIds) {
if (\in_array($item['album_id'], $seenIds, true)) {
return false;
}
@ -110,7 +110,7 @@ class AlbumsBackend extends Backend
// Add display names for users
$userManager = \OC::$server->get(\OCP\IUserManager::class);
array_walk($list, function (&$item) use ($userManager) {
array_walk($list, static function (&$item) use ($userManager) {
$user = $userManager->get($item['user']);
$item['user_display'] = $user ? $user->getDisplayName() : null;
});

View File

@ -71,7 +71,7 @@ trait PeopleBackendUtils
}
// Sort previews by score descending
usort($list, fn ($a, $b) => $b['score'] <=> $a['score']);
usort($list, static fn ($a, $b) => $b['score'] <=> $a['score']);
}
/**

View File

@ -201,7 +201,7 @@ class Index extends Command
$this->output->writeln("<error>User {$uid} not found</error>");
}
} else {
$this->userManager->callForSeenUsers(fn (IUser $user) => $closure($user));
$this->userManager->callForSeenUsers(static fn (IUser $user) => $closure($user));
}
}
}

View File

@ -243,7 +243,7 @@ class MigrateGoogleTakeout extends Command
// Keep keys that are not in EXIF unless --override is specified
if (!((bool) $this->input->getOption('override'))) {
$txf = array_filter($txf, function ($value, $key) use ($exif) {
$txf = array_filter($txf, static function ($value, $key) use ($exif) {
return !isset($exif[$key]);
}, ARRAY_FILTER_USE_BOTH);
@ -297,7 +297,7 @@ class MigrateGoogleTakeout extends Command
protected function takeoutToExiftoolJson(array $json)
{
// Helper to get a value from nested JSON
$get = function (string $source) use ($json) {
$get = static function (string $source) use ($json) {
$keys = array_reverse(explode('.', $source));
while (\count($keys) > 0) {
$key = array_pop($keys);
@ -343,7 +343,7 @@ class MigrateGoogleTakeout extends Command
$txf['GPSAltitude'] = $get('geoData.altitude');
// Remove all null values
return array_filter($txf, function ($value) {
return array_filter($txf, static function ($value) {
return null !== $value;
});
}

View File

@ -93,14 +93,14 @@ class AdminController extends GenericApiController
// Check exiftool version
$exiftoolNoLocal = Util::getSystemConfig('memories.exiftool_no_local');
$status['exiftool'] = $this->getExecutableStatus(
fn () => BinExt::getExiftoolPBin(),
fn ($p) => BinExt::testExiftool(),
static fn () => BinExt::getExiftoolPBin(),
static fn ($p) => BinExt::testExiftool(),
!$exiftoolNoLocal,
!$exiftoolNoLocal,
);
// Check for system perl
$status['perl'] = $this->getExecutableStatus(exec('which perl'), fn ($p) => BinExt::testSystemPerl($p));
$status['perl'] = $this->getExecutableStatus(exec('which perl'), static fn ($p) => BinExt::testSystemPerl($p));
// Check number of indexed files
$status['indexed_count'] = $index->getIndexedCount();
@ -135,24 +135,24 @@ class AdminController extends GenericApiController
$status['ffmpeg_preview'] = $this->getExecutableStatus(
Util::getSystemConfig('preview_ffmpeg_path', null, true)
?: trim(shell_exec('which ffmpeg') ?: ''),
fn ($p) => BinExt::testFFmpeg($p, 'ffmpeg'),
static fn ($p) => BinExt::testFFmpeg($p, 'ffmpeg'),
);
// Check ffmpeg and ffprobe binaries for transcoding
$status['ffmpeg'] = $this->getExecutableStatus(
Util::getSystemConfig('memories.vod.ffmpeg'),
fn ($p) => BinExt::testFFmpeg($p, 'ffmpeg'),
static fn ($p) => BinExt::testFFmpeg($p, 'ffmpeg'),
);
$status['ffprobe'] = $this->getExecutableStatus(
Util::getSystemConfig('memories.vod.ffprobe'),
fn ($p) => BinExt::testFFmpeg($p, 'ffprobe'),
static fn ($p) => BinExt::testFFmpeg($p, 'ffprobe'),
);
// Check go-vod binary
$extGoVod = Util::getSystemConfig('memories.vod.external');
$status['govod'] = $this->getExecutableStatus(
fn () => BinExt::getGoVodBin(),
fn ($p) => BinExt::testStartGoVod(),
static fn () => BinExt::getGoVodBin(),
static fn ($p) => BinExt::testStartGoVod(),
!$extGoVod,
!$extGoVod,
);
@ -188,7 +188,7 @@ class AdminController extends GenericApiController
// Reset action token
$this->actionToken(true);
return Util::guardExDirect(function (Http\IOutput $out) {
return Util::guardExDirect(static function (Http\IOutput $out) {
try {
// Set PHP timeout to infinite
set_time_limit(0);

View File

@ -76,7 +76,7 @@ class DaysController extends GenericApiController
$dayIds = null;
} else {
// Split at commas and convert all parts to int
$dayIds = array_map(fn ($p) => (int) $p, explode(',', $id));
$dayIds = array_map(static fn ($p) => (int) $p, explode(',', $id));
}
// Check if $dayIds is empty

View File

@ -46,7 +46,7 @@ class DownloadController extends GenericApiController
*/
public function request($files): Http\Response
{
return Util::guardEx(function () use ($files) {
return Util::guardEx(static function () use ($files) {
// Get ids from body
if (null === $files || !\is_array($files)) {
throw Exceptions::MissingParameter('files');
@ -105,7 +105,7 @@ class DownloadController extends GenericApiController
$fileIds = $info[1];
/** @var int[] $fileIds */
$fileIds = array_filter(array_map('intval', $fileIds), fn ($id) => $id > 0);
$fileIds = array_filter(array_map('intval', $fileIds), static fn ($id) => $id > 0);
// Check if we have any valid ids
if (0 === \count($fileIds)) {

View File

@ -40,7 +40,7 @@ class FoldersController extends GenericApiController
$folders = $view->getDirectoryContent($node->getPath(), FileInfo::MIMETYPE_FOLDER, $node);
// Sort by name
usort($folders, fn ($a, $b) => strnatcmp($a->getName(), $b->getName()));
usort($folders, static fn ($a, $b) => strnatcmp($a->getName(), $b->getName()));
// Process to response type
$list = array_map(fn ($node) => [

View File

@ -84,7 +84,7 @@ class ImageController extends GenericApiController
$files = json_decode($body, true);
// Filter files with valid parameters
$files = array_filter($files, function ($file) {
$files = array_filter($files, static function ($file) {
return isset($file['reqid'], $file['fileid'], $file['x'], $file['y'], $file['a'])
&& (int) $file['fileid'] > 0
&& (int) $file['x'] > 0
@ -92,7 +92,7 @@ class ImageController extends GenericApiController
});
// Sort files by size, ascending
usort($files, function ($a, $b) {
usort($files, static function ($a, $b) {
$aArea = (int) $a['x'] * (int) $a['y'];
$bArea = (int) $b['x'] * (int) $b['y'];
@ -453,9 +453,9 @@ class ImageController extends GenericApiController
/** @var \OCP\SystemTag\ISystemTag[] */
$tags = $tagManager->getTagsByIds($tagIds);
$visible = array_filter($tags, fn ($t) => $t->isUserVisible());
$visible = array_filter($tags, static fn ($t) => $t->isUserVisible());
// Get the tag names
return array_map(fn ($t) => $t->getName(), $visible);
return array_map(static fn ($t) => $t->getName(), $visible);
}
}

View File

@ -50,7 +50,7 @@ class MapController extends GenericApiController
$clusters = $this->timelineQuery->getMapClusters($gridLen, $bounds);
// Get previews for each cluster
$clusterIds = array_map(fn ($cluster) => (int) $cluster['id'], $clusters);
$clusterIds = array_map(static fn ($cluster) => (int) $cluster['id'], $clusters);
$previews = $this->timelineQuery->getMapClusterPreviews($clusterIds);
// Merge the responses

View File

@ -125,7 +125,7 @@ class OtherController extends GenericApiController
*/
public function describeApi(): JSONResponse
{
return Util::guardEx(function () {
return Util::guardEx(static function () {
$appManager = \OC::$server->get(\OCP\App\IAppManager::class);
$urlGenerator = \OC::$server->get(\OCP\IURLGenerator::class);

View File

@ -69,7 +69,7 @@ class PageController extends Controller
{
// Image domains MUST be added to the connect domain list
// because of the service worker fetch() call
$addImageDomain = function ($url) use (&$policy) {
$addImageDomain = static function ($url) use (&$policy) {
$policy->addAllowedImageDomain($url);
$policy->addAllowedConnectDomain($url);
};

View File

@ -129,7 +129,7 @@ class PublicAlbumController extends Controller
// Get list of files
$albumId = (int) $album['album_id'];
$files = $this->albumsQuery->getAlbumPhotos($albumId, null) ?? [];
$fileIds = array_map(fn ($file) => (int) $file['file_id'], $files);
$fileIds = array_map(static fn ($file) => (int) $file['file_id'], $files);
// Get download handle
$downloadController = \OC::$server->get(\OCA\Memories\Controller\DownloadController::class);

View File

@ -93,7 +93,7 @@ class ShareController extends GenericApiController
*/
public function deleteShare(string $id): Http\Response
{
return Util::guardEx(function () use ($id) {
return Util::guardEx(static function () use ($id) {
$uid = Util::getUID();
/** @var \OCP\Share\IManager $shareManager */

View File

@ -263,7 +263,7 @@ class VideoController extends GenericApiController
// Stream the response to the browser without reading it into memory
$headersWritten = false;
curl_setopt($ch, CURLOPT_WRITEFUNCTION, function ($curl, $data) use (&$headersWritten, $profile) {
curl_setopt($ch, CURLOPT_WRITEFUNCTION, static function ($curl, $data) use (&$headersWritten, $profile) {
$returnCode = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
if (200 === $returnCode) {
@ -353,8 +353,8 @@ class VideoController extends GenericApiController
// Get file paths for all live photos
$liveFiles = array_map(fn ($r) => $this->rootFolder->getById((int) $r['fileid']), $liveRecords);
$liveFiles = array_filter($liveFiles, fn ($files) => \count($files) > 0 && $files[0] instanceof File);
$liveFiles = array_map(fn ($files) => $files[0], $liveFiles);
$liveFiles = array_filter($liveFiles, static fn ($files) => \count($files) > 0 && $files[0] instanceof File);
$liveFiles = array_map(static fn ($files) => $files[0], $liveFiles);
// Should be filtered enough by now
if (!\count($liveFiles)) {
@ -362,7 +362,7 @@ class VideoController extends GenericApiController
}
// All paths including the image and videos need to be processed
$paths = array_map(function (File $file) {
$paths = array_map(static function (File $file) {
$path = $file->getPath();
$filename = strtolower($file->getName());
@ -382,7 +382,7 @@ class VideoController extends GenericApiController
// Find closest path match
$imagePath = array_pop($paths);
$scores = array_map(function ($path) use ($imagePath) {
$scores = array_map(static function ($path) use ($imagePath) {
$score = 0;
$length = min(\count($path), \count($imagePath));
for ($i = 0; $i < $length; ++$i) {

View File

@ -52,7 +52,7 @@ class IndexJob extends TimedJob
// Run for a maximum of 5 minutes
$startTime = microtime(true);
$this->service->continueCheck = function () use ($startTime) {
$this->service->continueCheck = static function () use ($startTime) {
return (microtime(true) - $startTime) < MAX_RUN_TIME;
};

View File

@ -170,7 +170,7 @@ class FsManager
]);
$search = $root->search(new SearchQuery($comp, 0, 0, [], Util::getUser()));
$paths = array_unique(array_map(fn (Node $node) => \dirname($node->getPath()), $search));
$paths = array_unique(array_map(static fn (Node $node) => \dirname($node->getPath()), $search));
$this->nomediaCache->set($key, $paths, 60 * 60); // 1 hour
return $paths;

View File

@ -92,7 +92,7 @@ trait TimelineQuerySingleItem
$places = $qb->executeQuery()->fetchAll();
$lang = Util::getUserLang();
if (\count($places) > 0) {
$places = array_map(fn ($p) => PlacesBackend::choosePlaceLang($p, $lang)['name'], $places);
$places = array_map(static fn ($p) => PlacesBackend::choosePlaceLang($p, $lang)['name'], $places);
$info['address'] = implode(', ', $places);
}
}

View File

@ -65,7 +65,7 @@ trait TimelineWriteOrphans
}
// Mark all files as not orphaned.
$fileIds = array_map(fn ($row) => $row['fileid'], $orphans);
$fileIds = array_map(static fn ($row) => $row['fileid'], $orphans);
$this->orphanAll(false, $fileIds, true);
$this->connection->commit();

View File

@ -50,7 +50,7 @@ trait TimelineWritePlaces
$rows = \OC::$server->get(\OCA\Memories\Service\Places::class)->queryPoint($lat, $lon);
// Get last ID, i.e. the ID with highest admin_level but <= 8
$crows = array_filter($rows, fn ($row) => $row['admin_level'] <= 8);
$crows = array_filter($rows, static fn ($row) => $row['admin_level'] <= 8);
$markRow = array_pop($crows);
// Insert records in transaction
@ -74,7 +74,7 @@ trait TimelineWritePlaces
$this->connection->commit();
// Return list of osm_id
return array_map(fn ($row) => $row['osm_id'], $rows);
return array_map(static fn ($row) => $row['osm_id'], $rows);
}
/**

View File

@ -131,10 +131,10 @@ class Index
// Filter files that are supported
$mimes = self::getMimeList();
$files = array_filter($nodes, fn ($n) => $n instanceof File && \in_array($n->getMimeType(), $mimes, true));
$files = array_filter($nodes, static fn ($n) => $n instanceof File && \in_array($n->getMimeType(), $mimes, true));
// Create an associative array with file ID as key
$files = array_combine(array_map(fn ($n) => $n->getId(), $files), $files);
$files = array_combine(array_map(static fn ($n) => $n->getId(), $files), $files);
// Chunk array into some files each (DBs have limitations on IN clause)
$chunks = array_chunk($files, 250, true);
@ -151,7 +151,7 @@ class Index
;
// Filter out files that are already indexed
$addFilter = function (string $table, string $alias) use (&$query) {
$addFilter = static function (string $table, string $alias) use (&$query) {
$query->leftJoin('f', $table, $alias, $query->expr()->andX(
$query->expr()->eq('f.fileid', "{$alias}.fileid"),
$query->expr()->eq('f.mtime', "{$alias}.mtime"),
@ -174,7 +174,7 @@ class Index
}
// All folders
$folders = array_filter($nodes, fn ($n) => $n instanceof Folder);
$folders = array_filter($nodes, static fn ($n) => $n instanceof Folder);
foreach ($folders as $folder) {
$this->ensureContinueOk();
@ -250,7 +250,7 @@ class Index
{
$preview = \OC::$server->get(IPreview::class);
return array_filter($source, fn ($m) => $preview->isMimeSupported($m));
return array_filter($source, static fn ($m) => $preview->isMimeSupported($m));
}
/**

View File

@ -315,7 +315,7 @@ class Places
}
if (GIS_TYPE_MYSQL === $gis) {
$points = implode(',', array_map(function ($point) {
$points = implode(',', array_map(static function ($point) {
$x = $point[0];
$y = $point[1];
@ -324,7 +324,7 @@ class Places
$geometry = "POLYGON(({$points}))";
} elseif (GIS_TYPE_POSTGRES === $gis) {
$geometry = implode(',', array_map(function ($point) {
$geometry = implode(',', array_map(static function ($point) {
$x = $point[0];
$y = $point[1];

View File

@ -318,7 +318,7 @@ class Util
$config = \OC::$server->get(IConfig::class);
$paths = $config->getUserValue($uid, Application::APPNAME, 'timelinePath', null) ?? 'Photos/';
return array_map(fn ($p) => self::sanitizePath(trim($p)), explode(';', $paths));
return array_map(static fn ($p) => self::sanitizePath(trim($p)), explode(';', $paths));
}
/**