diff --git a/composer.json b/composer.json index 9fb359420..fe38a55aa 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "bamarni/composer-bin-plugin": true }, "platform": { - "php": "8.3" + "php": "8.1.17" } }, "autoload": { @@ -25,6 +25,7 @@ "psalm:clear": "psalm --clear-cache && psalm --clear-global-cache", "psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType", "test:unit": "phpunit -c tests/phpunit.xml --color --fail-on-warning --fail-on-risky", + "rector": "rector && composer cs:fix", "post-install-cmd": [ "[ $COMPOSER_DEV_MODE -eq 0 ] || composer bin all install --ansi" ], diff --git a/lib/Album/AlbumFile.php b/lib/Album/AlbumFile.php index a0e9d73c3..b3f49bb0b 100644 --- a/lib/Album/AlbumFile.php +++ b/lib/Album/AlbumFile.php @@ -11,9 +11,6 @@ use OCA\Photos\DB\PhotosFile; class AlbumFile extends PhotosFile { - private int $added; - private string $owner; - public function __construct( int $fileId, string $name, @@ -21,8 +18,8 @@ public function __construct( int $size, int $mtime, string $etag, - int $added, - string $owner, + private readonly int $added, + private readonly string $owner, ) { parent::__construct( $fileId, @@ -32,9 +29,6 @@ public function __construct( $mtime, $etag ); - - $this->added = $added; - $this->owner = $owner; } public function getAdded(): int { diff --git a/lib/Album/AlbumInfo.php b/lib/Album/AlbumInfo.php index 12c7faa4f..437a374ab 100644 --- a/lib/Album/AlbumInfo.php +++ b/lib/Album/AlbumInfo.php @@ -9,30 +9,15 @@ namespace OCA\Photos\Album; class AlbumInfo { - private int $id; - private string $userId; - private string $title; - private string $location; - private int $created; - private int $lastAdded; - private ?int $receivedFrom; - public function __construct( - int $id, - string $userId, - string $title, - string $location, - int $created, - int $lastAdded, - ?int $receivedFrom = null, + private readonly int $id, + private readonly string $userId, + private readonly string $title, + private readonly string $location, + private readonly int $created, + private readonly int $lastAdded, + private readonly ?int $receivedFrom = null, ) { - $this->id = $id; - $this->userId = $userId; - $this->title = $title; - $this->location = $location; - $this->created = $created; - $this->lastAdded = $lastAdded; - $this->receivedFrom = $receivedFrom; } public function getId(): int { diff --git a/lib/Album/AlbumMapper.php b/lib/Album/AlbumMapper.php index 1a0e60f61..be8fdaaf9 100644 --- a/lib/Album/AlbumMapper.php +++ b/lib/Album/AlbumMapper.php @@ -20,11 +20,11 @@ use OCP\Security\ISecureRandom; class AlbumMapper { - private IDBConnection $connection; - private IMimeTypeLoader $mimeTypeLoader; - private ITimeFactory $timeFactory; - private IUserManager $userManager; - private IGroupManager $groupManager; + private readonly IDBConnection $connection; + private readonly IMimeTypeLoader $mimeTypeLoader; + private readonly ITimeFactory $timeFactory; + private readonly IUserManager $userManager; + private readonly IGroupManager $groupManager; protected IL10N $l; protected ISecureRandom $random; @@ -91,9 +91,7 @@ public function getForUser(string $userId): array { ->from('photos_albums') ->where($query->expr()->eq('user', $query->createNamedParameter($userId))); $rows = $query->executeQuery()->fetchAll(); - return array_map(function (array $row) use ($userId) { - return new AlbumInfo((int)$row['album_id'], $userId, $row['name'], $row['location'], (int)$row['created'], (int)$row['last_added_photo']); - }, $rows); + return array_map(fn (array $row): AlbumInfo => new AlbumInfo((int)$row['album_id'], $userId, $row['name'], $row['location'], (int)$row['created'], (int)$row['last_added_photo']), $rows); } /** @@ -126,9 +124,7 @@ public function getForFile(int $fileId): array { ->leftJoin('a', 'photos_albums_files', 'p', $query->expr()->eq('a.album_id', 'p.album_id')) ->where($query->expr()->eq('file_id', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT))); $rows = $query->executeQuery()->fetchAll(); - return array_map(function (array $row) { - return new AlbumInfo((int)$row['album_id'], $row['user'], $row['name'], $row['location'], (int)$row['created'], (int)$row['last_added_photo']); - }, $rows); + return array_map(fn (array $row): AlbumInfo => new AlbumInfo((int)$row['album_id'], $row['user'], $row['name'], $row['location'], (int)$row['created'], (int)$row['last_added_photo']), $rows); } /** @@ -144,9 +140,7 @@ public function getForUserAndFile(string $userId, int $fileId): array { ->where($query->expr()->eq('user', $query->createNamedParameter($userId))) ->andWhere($query->expr()->eq('file_id', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT))); $rows = $query->executeQuery()->fetchAll(); - return array_map(function (array $row) { - return new AlbumInfo((int)$row['album_id'], $row['user'], $row['name'], $row['location'], (int)$row['created'], (int)$row['last_added_photo']); - }, $rows); + return array_map(fn (array $row): AlbumInfo => new AlbumInfo((int)$row['album_id'], $row['user'], $row['name'], $row['location'], (int)$row['created'], (int)$row['last_added_photo']), $rows); } public function rename(int $id, string $newName): void { @@ -352,19 +346,12 @@ public function getCollaborators(int $albumId): array { /** @var string|null */ $displayName = null; - switch ($row['collaborator_type']) { - case self::TYPE_USER: - $displayName = $this->userManager->get($row['collaborator_id'])?->getDisplayName(); - break; - case self::TYPE_GROUP: - $displayName = $this->groupManager->get($row['collaborator_id'])?->getDisplayName(); - break; - case self::TYPE_LINK: - $displayName = $this->l->t('Public link'); - break; - default: - throw new \Exception('Invalid collaborator type: ' . $row['collaborator_type']); - } + $displayName = match ($row['collaborator_type']) { + self::TYPE_USER => $this->userManager->get($row['collaborator_id'])?->getDisplayName(), + self::TYPE_GROUP => $this->groupManager->get($row['collaborator_id'])?->getDisplayName(), + self::TYPE_LINK => $this->l->t('Public link'), + default => throw new \Exception('Invalid collaborator type: ' . $row['collaborator_type']), + }; if (is_null($displayName)) { return null; @@ -377,7 +364,7 @@ public function getCollaborators(int $albumId): array { ]; }, $rows); - return array_values(array_filter($collaborators, fn ($c) => $c !== null)); + return array_values(array_filter($collaborators, fn ($c): bool => $c !== null)); } @@ -422,12 +409,10 @@ public function setCollaborators(int $albumId, array $collaborators): void { $existingCollaborators = $this->getCollaborators($albumId); // Different behavior if type is link to prevent creating multiple link. - $computeKey = function ($c) { - return ($c['type'] === AlbumMapper::TYPE_LINK ? '' : $c['id']) . $c['type']; - }; + $computeKey = (fn ($c): string => ($c['type'] === AlbumMapper::TYPE_LINK ? '' : $c['id']) . $c['type']); - $collaboratorsToAdd = array_udiff($collaborators, $existingCollaborators, fn ($a, $b) => strcmp($computeKey($a), $computeKey($b))); - $collaboratorsToRemove = array_udiff($existingCollaborators, $collaborators, fn ($a, $b) => strcmp($computeKey($a), $computeKey($b))); + $collaboratorsToAdd = array_udiff($collaborators, $existingCollaborators, fn ($a, $b): int => strcmp($computeKey($a), $computeKey($b))); + $collaboratorsToRemove = array_udiff($existingCollaborators, $collaborators, fn ($a, $b): int => strcmp($computeKey($a), $computeKey($b))); $this->connection->beginTransaction(); @@ -492,16 +477,14 @@ public function getSharedAlbumsForCollaborator(string $collaboratorId, int $coll ->executeQuery() ->fetchAll(); - return array_map(function (array $row) { - return new AlbumInfo( - (int)$row['album_id'], - $row['user'], - $row['name'] . ' (' . $row['user'] . ')', - $row['location'], - (int)$row['created'], - (int)$row['last_added_photo'] - ); - }, $rows); + return array_map(fn (array $row): AlbumInfo => new AlbumInfo( + (int)$row['album_id'], + $row['user'], + $row['name'] . ' (' . $row['user'] . ')', + $row['location'], + (int)$row['created'], + (int)$row['last_added_photo'] + ), $rows); } /** @@ -604,15 +587,13 @@ public function getAlbumsForCollaboratorIdAndFileId(string $collaboratorId, int ->fetchAll(); - return array_map(function (array $row) { - return new AlbumInfo( - (int)$row['album_id'], - $row['user'], - $row['name'] . ' (' . $row['user'] . ')', - $row['location'], - (int)$row['created'], - (int)$row['last_added_photo'] - ); - }, $rows); + return array_map(fn (array $row): AlbumInfo => new AlbumInfo( + (int)$row['album_id'], + $row['user'], + $row['name'] . ' (' . $row['user'] . ')', + $row['location'], + (int)$row['created'], + (int)$row['last_added_photo'] + ), $rows); } } diff --git a/lib/Album/AlbumWithFiles.php b/lib/Album/AlbumWithFiles.php index 1ffc638c9..f4c5ab0a8 100644 --- a/lib/Album/AlbumWithFiles.php +++ b/lib/Album/AlbumWithFiles.php @@ -9,19 +9,12 @@ namespace OCA\Photos\Album; class AlbumWithFiles { - private AlbumInfo $info; - private AlbumMapper $albumMapper; - - /** @var AlbumFile[] */ - private array $files; - public function __construct( - AlbumInfo $info, - AlbumMapper $albumMapper, - array $files = []) { - $this->info = $info; - $this->albumMapper = $albumMapper; - $this->files = $files; + private readonly AlbumInfo $info, + private readonly AlbumMapper $albumMapper, + /** @var AlbumFile[] */ + private array $files = [], + ) { } public function getAlbum(): AlbumInfo { @@ -54,9 +47,7 @@ public function addFile(AlbumFile $file): array { * @return int[] */ public function getFileIds(): array { - return array_map(function (AlbumFile $file) { - return $file->getFileId(); - }, $this->getFiles()); + return array_map(fn (AlbumFile $file): int => $file->getFileId(), $this->getFiles()); } /** diff --git a/lib/Command/AlbumAddCommand.php b/lib/Command/AlbumAddCommand.php index 9937467f0..a094adaa6 100644 --- a/lib/Command/AlbumAddCommand.php +++ b/lib/Command/AlbumAddCommand.php @@ -17,18 +17,12 @@ use Symfony\Component\Console\Output\OutputInterface; class AlbumAddCommand extends Command { - private IRootFolder $rootFolder; - private IUserManager $userManager; - private AlbumMapper $albumMapper; public function __construct( - AlbumMapper $albumMapper, - IRootFolder $rootFolder, - IUserManager $userManager, + private readonly AlbumMapper $albumMapper, + private readonly IRootFolder $rootFolder, + private readonly IUserManager $userManager, ) { - $this->rootFolder = $rootFolder; - $this->userManager = $userManager; - $this->albumMapper = $albumMapper; parent::__construct(); } diff --git a/lib/Command/AlbumCreateCommand.php b/lib/Command/AlbumCreateCommand.php index 5ca484d9c..0c58d33e9 100644 --- a/lib/Command/AlbumCreateCommand.php +++ b/lib/Command/AlbumCreateCommand.php @@ -17,15 +17,11 @@ use Symfony\Component\Console\Output\OutputInterface; class AlbumCreateCommand extends Command { - private IUserManager $userManager; - private AlbumMapper $albumMapper; public function __construct( - AlbumMapper $albumMapper, - IUserManager $userManager, + private readonly AlbumMapper $albumMapper, + private readonly IUserManager $userManager, ) { - $this->userManager = $userManager; - $this->albumMapper = $albumMapper; parent::__construct(); } diff --git a/lib/Command/UpdateReverseGeocodingFilesCommand.php b/lib/Command/UpdateReverseGeocodingFilesCommand.php index fdf59e4e6..1d1140dec 100644 --- a/lib/Command/UpdateReverseGeocodingFilesCommand.php +++ b/lib/Command/UpdateReverseGeocodingFilesCommand.php @@ -14,7 +14,7 @@ class UpdateReverseGeocodingFilesCommand extends Command { public function __construct( - private ReverseGeoCoderService $rgcService, + private readonly ReverseGeoCoderService $rgcService, ) { parent::__construct(); } diff --git a/lib/Controller/AlbumsController.php b/lib/Controller/AlbumsController.php index 07f0f47c9..2c30ac1bd 100644 --- a/lib/Controller/AlbumsController.php +++ b/lib/Controller/AlbumsController.php @@ -24,19 +24,16 @@ use OCP\IRequest; class AlbumsController extends Controller { - private string $userId; - private IRootFolder $rootFolder; - private IPreview $previewManager; + private readonly IRootFolder $rootFolder; + private readonly IPreview $previewManager; public function __construct( - string $userId, + private readonly string $userId, IRequest $request, IRootFolder $rootFolder, IPreview $previewManager, ) { parent::__construct(Application::APP_ID, $request); - - $this->userId = $userId; $this->rootFolder = $rootFolder; $this->previewManager = $previewManager; } @@ -62,7 +59,7 @@ private function generate(string $path, bool $shared): JSONResponse { if ($path !== '') { try { $folder = $userFolder->get($path); - } catch (NotFoundException $e) { + } catch (NotFoundException) { return new JSONResponse([], Http::STATUS_NOT_FOUND); } } @@ -171,7 +168,7 @@ private function scanFolder(Folder $folder, int $depth, bool $shared): bool { } $nodes = $folder->getDirectoryListing(); - } catch (StorageNotAvailableException $e) { + } catch (StorageNotAvailableException) { return false; } diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index af60b07bd..3ea7eb733 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -20,8 +20,8 @@ use OCP\IUserSession; class ApiController extends Controller { - private IConfig $config; - private IUserSession $userSession; + private readonly IConfig $config; + private readonly IUserSession $userSession; public function __construct( IRequest $request, diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 046642003..f770ac190 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -39,41 +39,37 @@ use Psr\Log\LoggerInterface; class PageController extends Controller { - private IAppManager $appManager; - private IEventDispatcher $eventDispatcher; - private UserConfigService $userConfig; - private IInitialState $initialState; - private IUserSession $userSession; - private IRootFolder $rootFolder; - private ICacheFactory $cacheFactory; - private IL10N $l10n; - private ICache $nomediaPathsCache; - private LoggerInterface $logger; + private readonly IAppManager $appManager; + private readonly IEventDispatcher $eventDispatcher; + private readonly IInitialState $initialState; + private readonly IUserSession $userSession; + private readonly IRootFolder $rootFolder; + private readonly ICacheFactory $cacheFactory; + private readonly IL10N $l10n; + private readonly ICache $nomediaPathsCache; public function __construct( IRequest $request, IAppManager $appManager, IEventDispatcher $eventDispatcher, - UserConfigService $userConfig, + private readonly UserConfigService $userConfig, IInitialState $initialState, IUserSession $userSession, IRootFolder $rootFolder, ICacheFactory $cacheFactory, - LoggerInterface $logger, - private IConfig $config, + private readonly LoggerInterface $logger, + private readonly IConfig $config, IL10N $l10n, ) { parent::__construct(Application::APP_ID, $request); $this->appManager = $appManager; $this->eventDispatcher = $eventDispatcher; - $this->userConfig = $userConfig; $this->initialState = $initialState; $this->userSession = $userSession; $this->rootFolder = $rootFolder; $this->cacheFactory = $cacheFactory; $this->nomediaPathsCache = $this->cacheFactory->createLocal('photos:nomedia-paths'); - $this->logger = $logger; $this->l10n = $l10n; } @@ -113,9 +109,7 @@ public function index(): TemplateResponse { new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', '.nomedia'), new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', '.noimage') ]), 0, 0, [], $user)); - $paths = array_map(function (Node $node) use ($userFolder) { - return substr(dirname($node->getPath()), strlen($userFolder->getPath())); - }, $search); + $paths = array_map(fn (Node $node): string => substr(dirname($node->getPath()), strlen((string)$userFolder->getPath())), $search); $this->nomediaPathsCache->set($key, $paths, 60 * 60 * 24 * 28); // 28 days } } catch (InvalidPathException|NotFoundException|NotPermittedException|NoUserException $e) { diff --git a/lib/Controller/PreviewController.php b/lib/Controller/PreviewController.php index f3bd3f45c..0b5909e4c 100644 --- a/lib/Controller/PreviewController.php +++ b/lib/Controller/PreviewController.php @@ -8,12 +8,14 @@ namespace OCA\Photos\Controller; +use OCA\Photos\Album\AlbumInfo; use OCA\Photos\Album\AlbumMapper; use OCA\Photos\AppInfo\Application; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\FileDisplayResponse; +use OCP\AppFramework\Http\Response; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; @@ -26,28 +28,24 @@ use OCP\IUserSession; class PreviewController extends Controller { - private IUserSession $userSession; - private ?Folder $userFolder; - private IRootFolder $rootFolder; - protected AlbumMapper $albumMapper; - private IPreview $preview; - private IGroupManager $groupManager; + private readonly IUserSession $userSession; + private readonly IRootFolder $rootFolder; + private readonly IPreview $preview; + private readonly IGroupManager $groupManager; public function __construct( IRequest $request, IUserSession $userSession, - ?Folder $userFolder, + private readonly ?Folder $userFolder, IRootFolder $rootFolder, - AlbumMapper $albumMapper, + protected AlbumMapper $albumMapper, IPreview $preview, IGroupManager $groupManager, ) { parent::__construct(Application::APP_ID, $request); $this->userSession = $userSession; - $this->userFolder = $userFolder; $this->rootFolder = $rootFolder; - $this->albumMapper = $albumMapper; $this->preview = $preview; $this->groupManager = $groupManager; } @@ -90,7 +88,7 @@ function ($node) { }, ); - /** @var \OCA\Photos\Album\AlbumInfo[] */ + /** @var AlbumInfo[] */ $checkedAlbums = []; if (\count($nodes) === 0) { $albumsOfCurrentUser = $this->albumMapper->getForUserAndFile($user->getUID(), $fileId); @@ -100,7 +98,7 @@ function ($node) { if (\count($nodes) === 0) { $receivedAlbums = $this->albumMapper->getAlbumsForCollaboratorIdAndFileId($user->getUID(), AlbumMapper::TYPE_USER, $fileId); - $receivedAlbums = array_udiff($receivedAlbums, $checkedAlbums, fn ($a, $b) => ($a->getId() - $b->getId())); + $receivedAlbums = array_udiff($receivedAlbums, $checkedAlbums, fn ($a, $b): int => ($a->getId() - $b->getId())); $nodes = $this->getFileIdForAlbums($fileId, $receivedAlbums); $checkedAlbums = array_merge($checkedAlbums, $receivedAlbums); } @@ -109,7 +107,7 @@ function ($node) { $userGroups = $this->groupManager->getUserGroupIds($user); foreach ($userGroups as $groupId) { $albumsForGroup = $this->albumMapper->getAlbumsForCollaboratorIdAndFileId($groupId, AlbumMapper::TYPE_GROUP, $fileId); - $albumsForGroup = array_udiff($albumsForGroup, $checkedAlbums, fn ($a, $b) => ($a->getId() - $b->getId())); + $albumsForGroup = array_udiff($albumsForGroup, $checkedAlbums, fn ($a, $b): int => ($a->getId() - $b->getId())); $nodes = $this->getFileIdForAlbums($fileId, $albumsForGroup); $checkedAlbums = array_merge($checkedAlbums, $receivedAlbums); if (\count($nodes) !== 0) { @@ -149,7 +147,7 @@ protected function fetchPreview( Node $node, int $x, int $y, - ) : Http\Response { + ) : Response { if (!($node instanceof File) || !$this->preview->isAvailable($node)) { return new DataResponse([], Http::STATUS_NOT_FOUND); } @@ -164,9 +162,9 @@ protected function fetchPreview( ]); $response->cacheFor(3600 * 24, false, true); return $response; - } catch (NotFoundException $e) { + } catch (NotFoundException) { return new DataResponse([], Http::STATUS_NOT_FOUND); - } catch (\InvalidArgumentException $e) { + } catch (\InvalidArgumentException) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } } diff --git a/lib/Controller/PublicAlbumController.php b/lib/Controller/PublicAlbumController.php index 1b9090148..7d2e83dac 100644 --- a/lib/Controller/PublicAlbumController.php +++ b/lib/Controller/PublicAlbumController.php @@ -18,8 +18,8 @@ use OCP\Util; class PublicAlbumController extends Controller { - private IEventDispatcher $eventDispatcher; - private IInitialState $initialState; + private readonly IEventDispatcher $eventDispatcher; + private readonly IInitialState $initialState; public function __construct( IRequest $request, diff --git a/lib/DB/PhotosFile.php b/lib/DB/PhotosFile.php index cd0468bd9..28ef47136 100644 --- a/lib/DB/PhotosFile.php +++ b/lib/DB/PhotosFile.php @@ -10,12 +10,12 @@ class PhotosFile { public function __construct( - private int $fileId, - private string $name, - private string $mimeType, - private int $size, - private int $mtime, - private string $etag, + private readonly int $fileId, + private readonly string $name, + private readonly string $mimeType, + private readonly int $size, + private readonly int $mtime, + private readonly string $etag, ) { } diff --git a/lib/DB/Place/PlaceFile.php b/lib/DB/Place/PlaceFile.php index 73912d96e..15f61c8c3 100644 --- a/lib/DB/Place/PlaceFile.php +++ b/lib/DB/Place/PlaceFile.php @@ -18,7 +18,7 @@ public function __construct( int $size, int $mtime, string $etag, - private string $place, + private readonly string $place, ) { parent::__construct( $fileId, diff --git a/lib/DB/Place/PlaceInfo.php b/lib/DB/Place/PlaceInfo.php index 407e757cc..619d6119a 100644 --- a/lib/DB/Place/PlaceInfo.php +++ b/lib/DB/Place/PlaceInfo.php @@ -10,8 +10,8 @@ class PlaceInfo { public function __construct( - private string $userId, - private string $place, + private readonly string $userId, + private readonly string $place, ) { } diff --git a/lib/DB/Place/PlaceMapper.php b/lib/DB/Place/PlaceMapper.php index 4c8248f5c..99d828dda 100644 --- a/lib/DB/Place/PlaceMapper.php +++ b/lib/DB/Place/PlaceMapper.php @@ -20,10 +20,10 @@ class PlaceMapper { public const METADATA_KEY = 'photos-place'; public function __construct( - private IDBConnection $connection, - private IMimeTypeLoader $mimeTypeLoader, - private IRootFolder $rootFolder, - private IFilesMetadataManager $filesMetadataManager, + private readonly IDBConnection $connection, + private readonly IMimeTypeLoader $mimeTypeLoader, + private readonly IRootFolder $rootFolder, + private readonly IFilesMetadataManager $filesMetadataManager, ) { } @@ -49,7 +49,7 @@ public function findPlacesForUser(string $userId): array { ->executeQuery() ->fetchAll(); - return array_map(fn ($row) => new PlaceInfo($userId, $row['meta_value_string']), $rows); + return array_map(fn ($row): PlaceInfo => new PlaceInfo($userId, $row['meta_value_string']), $rows); } /** @return PlaceInfo */ @@ -104,7 +104,7 @@ public function findFilesForUserAndPlace(string $userId, string $place) { ->fetchAll(); return array_map( - fn ($row) => new PlaceFile( + fn ($row): PlaceFile => new PlaceFile( (int)$row['fileid'], $row['name'], $this->mimeTypeLoader->getMimetypeById($row['mimetype']), diff --git a/lib/Dashboard/OnThisDay.php b/lib/Dashboard/OnThisDay.php index c930fe99f..9d9bd6906 100644 --- a/lib/Dashboard/OnThisDay.php +++ b/lib/Dashboard/OnThisDay.php @@ -15,9 +15,9 @@ class OnThisDay implements IIconWidget { public function __construct( - private IL10N $l, - private IURLGenerator $url, - private IInitialState $initialState, + private readonly IL10N $l, + private readonly IURLGenerator $url, + private readonly IInitialState $initialState, ) { } diff --git a/lib/Jobs/AutomaticPlaceMapperJob.php b/lib/Jobs/AutomaticPlaceMapperJob.php index 2a54daf25..4d842ab53 100644 --- a/lib/Jobs/AutomaticPlaceMapperJob.php +++ b/lib/Jobs/AutomaticPlaceMapperJob.php @@ -11,6 +11,7 @@ use OCA\Photos\AppInfo\Application; use OCA\Photos\Service\MediaPlaceManager; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\BackgroundJob\IJob; use OCP\BackgroundJob\TimedJob; use OCP\Files\Folder; use OCP\Files\IRootFolder; @@ -21,15 +22,15 @@ class AutomaticPlaceMapperJob extends TimedJob { public function __construct( ITimeFactory $time, - private IConfig $config, - private IRootFolder $rootFolder, - private IUserManager $userManager, + private readonly IConfig $config, + private readonly IRootFolder $rootFolder, + private readonly IUserManager $userManager, private MediaPlaceManager $mediaPlaceManager, ) { parent::__construct($time); $this->mediaPlaceManager = $mediaPlaceManager; - $this->setTimeSensitivity(\OCP\BackgroundJob\IJob::TIME_INSENSITIVE); + $this->setTimeSensitivity(IJob::TIME_INSENSITIVE); $this->setInterval(24 * 3600); } @@ -88,7 +89,7 @@ private function scanFolder(Folder $folder): void { continue; } - if (!str_starts_with($node->getMimeType(), 'image')) { + if (!str_starts_with((string)$node->getMimeType(), 'image')) { continue; } diff --git a/lib/Listener/AlbumsManagementEventListener.php b/lib/Listener/AlbumsManagementEventListener.php index 412277c5f..352cc8444 100644 --- a/lib/Listener/AlbumsManagementEventListener.php +++ b/lib/Listener/AlbumsManagementEventListener.php @@ -23,15 +23,10 @@ * @template-implements IEventListener */ class AlbumsManagementEventListener implements IEventListener { - private AlbumMapper $albumMapper; - private LoggerInterface $logger; - public function __construct( - AlbumMapper $albumMapper, - LoggerInterface $logger, + private readonly AlbumMapper $albumMapper, + private readonly LoggerInterface $logger, ) { - $this->albumMapper = $albumMapper; - $this->logger = $logger; } public function handle(Event $event): void { @@ -74,7 +69,7 @@ public function handle(Event $event): void { // Get all albums shared with this specific user: $albums_user = $this->albumMapper->getSharedAlbumsForCollaborator($event->getUser()->getUID(), AlbumMapper::TYPE_USER); // Get all group-shared albums that are not directly shared with the removed user in addition - $albums = array_udiff($albums_group, $albums_user, fn ($a, $b) => ($a->getId() - $b->getId())); + $albums = array_udiff($albums_group, $albums_user, fn ($a, $b): int => ($a->getId() - $b->getId())); // Remove their photos from theses albums: foreach ($albums as $album) { @@ -92,7 +87,7 @@ public function handle(Event $event): void { $albums_user = $this->albumMapper->getSharedAlbumsForCollaborator($user->getUID(), AlbumMapper::TYPE_USER); // Get all group-shared albums that are not directly shared with the removed user in addition - $albums = array_udiff($albums_group, $albums_user, fn ($a, $b) => ($a->getId() - $b->getId())); + $albums = array_udiff($albums_group, $albums_user, fn ($a, $b): int => ($a->getId() - $b->getId())); // Remove their photos from theses albums: foreach ($albums as $album) { diff --git a/lib/Listener/ExifMetadataProvider.php b/lib/Listener/ExifMetadataProvider.php index 6d72d2476..10f3f68e8 100644 --- a/lib/Listener/ExifMetadataProvider.php +++ b/lib/Listener/ExifMetadataProvider.php @@ -24,7 +24,7 @@ */ class ExifMetadataProvider implements IEventListener { public function __construct( - private LoggerInterface $logger, + private readonly LoggerInterface $logger, ) { } @@ -117,7 +117,7 @@ private function gpsDegreesToDecimal($coordinates, ?string $hemisphere): float { throw new \Exception('Invalid coordinate format: ' . json_encode($coordinates)); } - [$degrees, $minutes, $seconds] = array_map(fn ($rawDegree) => $this->parseGPSData($rawDegree), $coordinates); + [$degrees, $minutes, $seconds] = array_map(fn ($rawDegree): float => $this->parseGPSData($rawDegree), $coordinates); $sign = ($hemisphere === 'W' || $hemisphere === 'S') ? -1 : 1; return $sign * ($degrees + $minutes / 60 + $seconds / 3600); diff --git a/lib/Listener/LoadSidebarScripts.php b/lib/Listener/LoadSidebarScripts.php index 7c78afc81..d7138a6d9 100644 --- a/lib/Listener/LoadSidebarScripts.php +++ b/lib/Listener/LoadSidebarScripts.php @@ -21,7 +21,7 @@ class LoadSidebarScripts implements IEventListener { public function __construct( - private IRequest $request, + private readonly IRequest $request, ) { } @@ -31,7 +31,7 @@ public function handle(Event $event): void { } // Only load sidebar tab in the photos app. - if (!preg_match('/^photos\.page\..+/', $this->request->getParams()['_route'])) { + if (!preg_match('/^photos\.page\..+/', (string)$this->request->getParams()['_route'])) { return; } diff --git a/lib/Listener/OriginalDateTimeMetadataProvider.php b/lib/Listener/OriginalDateTimeMetadataProvider.php index 7cd7b7bc1..48402d62f 100644 --- a/lib/Listener/OriginalDateTimeMetadataProvider.php +++ b/lib/Listener/OriginalDateTimeMetadataProvider.php @@ -22,7 +22,7 @@ */ class OriginalDateTimeMetadataProvider implements IEventListener { public function __construct( - private LoggerInterface $logger, + private readonly LoggerInterface $logger, ) { } diff --git a/lib/Listener/PlaceMetadataProvider.php b/lib/Listener/PlaceMetadataProvider.php index 29b15d95c..3337bac57 100644 --- a/lib/Listener/PlaceMetadataProvider.php +++ b/lib/Listener/PlaceMetadataProvider.php @@ -21,7 +21,7 @@ */ class PlaceMetadataProvider implements IEventListener { public function __construct( - private MediaPlaceManager $mediaPlaceManager, + private readonly MediaPlaceManager $mediaPlaceManager, ) { } diff --git a/lib/Listener/SabrePluginAuthInitListener.php b/lib/Listener/SabrePluginAuthInitListener.php index 862a8712f..a81cb0f53 100644 --- a/lib/Listener/SabrePluginAuthInitListener.php +++ b/lib/Listener/SabrePluginAuthInitListener.php @@ -16,10 +16,9 @@ * @template-implements IEventListener */ class SabrePluginAuthInitListener implements IEventListener { - private PublicAlbumAuthBackend $publicAlbumAuthBackend; - - public function __construct(PublicAlbumAuthBackend $publicAlbumAuthBackend) { - $this->publicAlbumAuthBackend = $publicAlbumAuthBackend; + public function __construct( + private readonly PublicAlbumAuthBackend $publicAlbumAuthBackend, + ) { } public function handle(Event $event): void { @@ -29,7 +28,7 @@ public function handle(Event $event): void { $server = $event->getServer(); - if (!str_starts_with($server->getRequestUri(), 'photospublic/')) { + if (!str_starts_with((string)$server->getRequestUri(), 'photospublic/')) { return; } diff --git a/lib/Listener/SizeMetadataProvider.php b/lib/Listener/SizeMetadataProvider.php index 32a826e85..2d3221de3 100644 --- a/lib/Listener/SizeMetadataProvider.php +++ b/lib/Listener/SizeMetadataProvider.php @@ -21,7 +21,7 @@ */ class SizeMetadataProvider implements IEventListener { public function __construct( - private LoggerInterface $logger, + private readonly LoggerInterface $logger, ) { } diff --git a/lib/Listener/TagListener.php b/lib/Listener/TagListener.php index 1bc4b034e..554a1e14b 100644 --- a/lib/Listener/TagListener.php +++ b/lib/Listener/TagListener.php @@ -11,6 +11,7 @@ use OCP\Files\Config\ICachedMountInfo; use OCP\Files\Config\IUserMountCache; use OCP\Files\IRootFolder; +use OCP\ICache; use OCP\ICacheFactory; use OCP\SystemTag\MapperEvent; @@ -18,9 +19,9 @@ * @template-implements IEventListener */ class TagListener implements IEventListener { - private \OCP\ICache $tagCountsCache; - private IRootFolder $rootFolder; - private IUserMountCache $userMountCache; + private readonly ICache $tagCountsCache; + private readonly IRootFolder $rootFolder; + private readonly IUserMountCache $userMountCache; public function __construct(ICacheFactory $cacheFactory, IRootFolder $rootFolder, IUserMountCache $userMountCache) { $this->tagCountsCache = $cacheFactory->createLocal('photos:tag-counts'); @@ -41,9 +42,7 @@ public function handle(Event $event): void { return; } $mounts = $this->userMountCache->getMountsForRootId($node->getMountPoint()->getStorageRootId()); - $userIds = array_map(static function (ICachedMountInfo $mount) { - return $mount->getUser()->getUID(); - }, $mounts); + $userIds = array_map(static fn (ICachedMountInfo $mount) => $mount->getUser()->getUID(), $mounts); foreach ($userIds as $userId) { $this->tagCountsCache->remove($userId); } diff --git a/lib/Migration/Version30000Date20240417075405.php b/lib/Migration/Version30000Date20240417075405.php index ed3c59b9a..2fc76412d 100644 --- a/lib/Migration/Version30000Date20240417075405.php +++ b/lib/Migration/Version30000Date20240417075405.php @@ -21,7 +21,7 @@ */ class Version30000Date20240417075405 extends SimpleMigrationStep { public function __construct( - private IDBConnection $db, + private readonly IDBConnection $db, ) { } diff --git a/lib/RepairStep/InitMetadata.php b/lib/RepairStep/InitMetadata.php index 9f0c01955..5ee818ce5 100644 --- a/lib/RepairStep/InitMetadata.php +++ b/lib/RepairStep/InitMetadata.php @@ -15,11 +15,11 @@ class InitMetadata implements IRepairStep { public function __construct( - private IFilesMetadataManager $metadataManager, + private readonly IFilesMetadataManager $metadataManager, ) { } - public function getName() { + public function getName(): string { return 'init metadata'; } diff --git a/lib/Sabre/Album/AlbumPhoto.php b/lib/Sabre/Album/AlbumPhoto.php index 4c2a7434d..f888209e0 100644 --- a/lib/Sabre/Album/AlbumPhoto.php +++ b/lib/Sabre/Album/AlbumPhoto.php @@ -21,10 +21,10 @@ class AlbumPhoto extends CollectionPhoto implements IFile { public function __construct( - private AlbumMapper $albumMapper, - private AlbumInfo $album, - private AlbumFile $albumFile, - private IRootFolder $rootFolder, + private readonly AlbumMapper $albumMapper, + private readonly AlbumInfo $album, + private readonly AlbumFile $albumFile, + private readonly IRootFolder $rootFolder, Folder $userFolder, ) { parent::__construct($albumFile, $userFolder); diff --git a/lib/Sabre/Album/AlbumRoot.php b/lib/Sabre/Album/AlbumRoot.php index 78af26a0c..32dff4dba 100644 --- a/lib/Sabre/Album/AlbumRoot.php +++ b/lib/Sabre/Album/AlbumRoot.php @@ -106,7 +106,7 @@ public function createFile($name, $data = null) { /** * @return never */ - public function createDirectory($name) { + public function createDirectory($name): never { throw new Forbidden('Not allowed to create directories in this folder'); } @@ -114,9 +114,7 @@ public function createDirectory($name) { * @return AlbumPhoto[] */ public function getChildren(): array { - return array_map(function (AlbumFile $file) { - return new AlbumPhoto($this->albumMapper, $this->album->getAlbum(), $file, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId)); - }, $this->album->getFiles()); + return array_map(fn (AlbumFile $file): AlbumPhoto => new AlbumPhoto($this->albumMapper, $this->album->getAlbum(), $file, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId)), $this->album->getFiles()); } public function getChild($name): AlbumPhoto { @@ -132,7 +130,7 @@ public function childExists($name): bool { try { $this->getChild($name); return true; - } catch (NotFound $e) { + } catch (NotFound) { return false; } } @@ -180,7 +178,7 @@ public function getDateRange(): array { foreach ($this->getChildren() as $child) { try { $childCreationDate = $child->getFileInfo()->getMtime(); - } catch (NotFoundException $e) { + } catch (NotFoundException) { continue; } @@ -214,7 +212,7 @@ public function getCover() { */ public function getCollaborators(): array { return array_map( - fn (array $collaborator) => [ 'nc:collaborator' => $collaborator ], + fn (array $collaborator): array => [ 'nc:collaborator' => $collaborator ], $this->albumMapper->getCollaborators($this->album->getAlbum()->getId()), ); } diff --git a/lib/Sabre/Album/AlbumsHome.php b/lib/Sabre/Album/AlbumsHome.php index 73438ca2c..3fb6ccb39 100644 --- a/lib/Sabre/Album/AlbumsHome.php +++ b/lib/Sabre/Album/AlbumsHome.php @@ -39,7 +39,7 @@ public function __construct( /** * @return never */ - public function delete() { + public function delete(): never { throw new Forbidden(); } @@ -50,11 +50,11 @@ public function getName(): string { /** * @return never */ - public function setName($name) { + public function setName($name): never { throw new Forbidden('Permission denied to rename this folder'); } - public function createFile($name, $data = null) { + public function createFile($name, $data = null): never { throw new Forbidden('Not allowed to create files in this folder'); } @@ -81,16 +81,14 @@ public function getChild($name) { public function getChildren(): array { if ($this->children === null) { $albumInfos = $this->albumMapper->getForUser($this->userId); - $this->children = array_map(function (AlbumInfo $albumInfo) { - return new AlbumRoot( - $this->albumMapper, - new AlbumWithFiles($albumInfo, $this->albumMapper), - $this->rootFolder, - $this->userId, - $this->userConfigService, - $this->logger, - ); - }, $albumInfos); + $this->children = array_map(fn (AlbumInfo $albumInfo): AlbumRoot => new AlbumRoot( + $this->albumMapper, + new AlbumWithFiles($albumInfo, $this->albumMapper), + $this->rootFolder, + $this->userId, + $this->userConfigService, + $this->logger, + ), $albumInfos); } return $this->children; @@ -100,7 +98,7 @@ public function childExists($name): bool { try { $this->getChild($name); return true; - } catch (NotFound $e) { + } catch (NotFound) { return false; } } diff --git a/lib/Sabre/Album/PublicAlbumPhoto.php b/lib/Sabre/Album/PublicAlbumPhoto.php index 40c0ab370..6a53b0f96 100644 --- a/lib/Sabre/Album/PublicAlbumPhoto.php +++ b/lib/Sabre/Album/PublicAlbumPhoto.php @@ -12,13 +12,11 @@ use Sabre\DAV\IFile; class PublicAlbumPhoto extends AlbumPhoto implements IFile { - /** @return void */ - public function delete() { + public function delete(): never { throw new NotFoundException('Deleting photos from a public album is not allowed.'); } - /** @return void */ - public function put($data) { + public function put($data): never { throw new NotFoundException('Changing a photo from a public album is not allowed.'); } } diff --git a/lib/Sabre/Album/PublicAlbumRoot.php b/lib/Sabre/Album/PublicAlbumRoot.php index 2fe06dee6..156549bdf 100644 --- a/lib/Sabre/Album/PublicAlbumRoot.php +++ b/lib/Sabre/Album/PublicAlbumRoot.php @@ -14,17 +14,11 @@ use Sabre\DAV\INode; class PublicAlbumRoot extends AlbumRoot { - /** - * @return void - */ - public function delete() { + public function delete(): never { throw new Forbidden('Not allowed to delete a public album'); } - /** - * @return void - */ - public function setName($name) { + public function setName($name): never { throw new Forbidden('Not allowed to rename a public album'); } @@ -39,7 +33,7 @@ protected function getPhotosLocationInfo() { return [$photosLocation, $userFolder]; } - public function createFile($name, $data = null) { + public function createFile($name, $data = null): never { throw new Forbidden('Not allowed to create a file in a public album'); } @@ -58,9 +52,7 @@ public function setCollaborators($collaborators): array { } public function getChildren(): array { - return array_map(function (AlbumFile $file) { - return new PublicAlbumPhoto($this->albumMapper, $this->album->getAlbum(), $file, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId)); - }, $this->album->getFiles()); + return array_map(fn (AlbumFile $file): PublicAlbumPhoto => new PublicAlbumPhoto($this->albumMapper, $this->album->getAlbum(), $file, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId)), $this->album->getFiles()); } public function getChild($name): PublicAlbumPhoto { diff --git a/lib/Sabre/Album/SharedAlbumRoot.php b/lib/Sabre/Album/SharedAlbumRoot.php index 6ddb47f8f..893b19ee7 100644 --- a/lib/Sabre/Album/SharedAlbumRoot.php +++ b/lib/Sabre/Album/SharedAlbumRoot.php @@ -25,7 +25,7 @@ public function __construct( string $userId, UserConfigService $userConfigService, LoggerInterface $logger, - private IUserManager $userManager, + private readonly IUserManager $userManager, ) { parent::__construct( $albumMapper, @@ -37,17 +37,11 @@ public function __construct( ); } - /** - * @return void - */ public function delete() { $this->albumMapper->deleteUserFromAlbumCollaboratorsList($this->userId, $this->album->getAlbum()->getId()); } - /** - * @return void - */ - public function setName($name) { + public function setName($name): never { throw new Forbidden('Not allowed to rename a shared album'); } diff --git a/lib/Sabre/Album/SharedAlbumsHome.php b/lib/Sabre/Album/SharedAlbumsHome.php index ed61f20e0..911456803 100644 --- a/lib/Sabre/Album/SharedAlbumsHome.php +++ b/lib/Sabre/Album/SharedAlbumsHome.php @@ -25,8 +25,8 @@ public function __construct( AlbumMapper $albumMapper, string $userId, IRootFolder $rootFolder, - private IUserManager $userManager, - private IGroupManager $groupManager, + private readonly IUserManager $userManager, + private readonly IGroupManager $groupManager, UserConfigService $userConfigService, LoggerInterface $logger, ) { @@ -43,7 +43,7 @@ public function __construct( /** * @return never */ - public function createDirectory($name) { + public function createDirectory($name): never { throw new Forbidden('Not allowed to create folders in this folder'); } @@ -58,21 +58,19 @@ public function getChildren(): array { $userGroups = $this->groupManager->getUserGroupIds($user); foreach ($userGroups as $groupId) { $albumsForGroup = $this->albumMapper->getSharedAlbumsForCollaboratorWithFiles($groupId, AlbumMapper::TYPE_GROUP); - $albumsForGroup = array_udiff($albumsForGroup, $albums, fn ($a, $b) => $a->getAlbum()->getId() - $b->getAlbum()->getId()); + $albumsForGroup = array_udiff($albumsForGroup, $albums, fn ($a, $b): int => $a->getAlbum()->getId() - $b->getAlbum()->getId()); $albums = array_merge($albums, $albumsForGroup); } - $this->children = array_map(function (AlbumWithFiles $album) { - return new SharedAlbumRoot( - $this->albumMapper, - $album, - $this->rootFolder, - $this->userId, - $this->userConfigService, - $this->logger, - $this->userManager, - ); - }, $albums); + $this->children = array_map(fn (AlbumWithFiles $album): SharedAlbumRoot => new SharedAlbumRoot( + $this->albumMapper, + $album, + $this->rootFolder, + $this->userId, + $this->userConfigService, + $this->logger, + $this->userManager, + ), $albums); } return $this->children; diff --git a/lib/Sabre/CollectionPhoto.php b/lib/Sabre/CollectionPhoto.php index 89c464272..5d50b8601 100644 --- a/lib/Sabre/CollectionPhoto.php +++ b/lib/Sabre/CollectionPhoto.php @@ -13,7 +13,9 @@ use OCP\Files\Folder; use OCP\Files\Node; use OCP\Files\NotFoundException; +use OCP\ITagManager; use OCP\ITags; +use OCP\Server; use Sabre\DAV\Exception\Forbidden; class CollectionPhoto { @@ -30,7 +32,7 @@ public function getName() { /** * @return never */ - public function setName($name) { + public function setName($name): never { throw new Forbidden('Can\'t rename photos trough this api'); } @@ -74,7 +76,7 @@ public function getFile(): PhotosFile { } public function isFavorite(): bool { - $tagManager = \OCP\Server::get(\OCP\ITagManager::class); + $tagManager = Server::get(ITagManager::class); $tagger = $tagManager->load('files'); if ($tagger === null) { return false; @@ -89,7 +91,7 @@ public function isFavorite(): bool { } public function setFavoriteState($favoriteState): bool { - $tagManager = \OCP\Server::get(\OCP\ITagManager::class); + $tagManager = Server::get(ITagManager::class); $tagger = $tagManager->load('files'); switch ($favoriteState) { diff --git a/lib/Sabre/PhotosHome.php b/lib/Sabre/PhotosHome.php index 37730c690..3c4ed0f12 100644 --- a/lib/Sabre/PhotosHome.php +++ b/lib/Sabre/PhotosHome.php @@ -26,59 +26,56 @@ class PhotosHome implements ICollection { public function __construct( private array $principalInfo, - private AlbumMapper $albumMapper, - private PlaceMapper $placeMapper, - private ReverseGeoCoderService $reverseGeoCoderService, - private string $userId, - private IRootFolder $rootFolder, - private IUserManager $userManager, - private IGroupManager $groupManager, - private UserConfigService $userConfigService, - private LoggerInterface $logger, + private readonly AlbumMapper $albumMapper, + private readonly PlaceMapper $placeMapper, + private readonly ReverseGeoCoderService $reverseGeoCoderService, + private readonly string $userId, + private readonly IRootFolder $rootFolder, + private readonly IUserManager $userManager, + private readonly IGroupManager $groupManager, + private readonly UserConfigService $userConfigService, + private readonly LoggerInterface $logger, ) { } /** * @return never */ - public function delete() { + public function delete(): never { throw new Forbidden(); } public function getName(): string { [, $name] = \Sabre\Uri\split($this->principalInfo['uri']); + return $name; } /** * @return never */ - public function setName($name) { + public function setName($name): never { throw new Forbidden('Permission denied to rename this folder'); } - public function createFile($name, $data = null) { + public function createFile($name, $data = null): never { throw new Forbidden('Not allowed to create files in this folder'); } /** * @return never */ - public function createDirectory($name) { + public function createDirectory($name): never { throw new Forbidden('Permission denied to create folders in this folder'); } public function getChild($name) { - switch ($name) { - case AlbumsHome::NAME: - return new AlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userConfigService, $this->logger); - case SharedAlbumsHome::NAME: - return new SharedAlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userManager, $this->groupManager, $this->userConfigService, $this->logger); - case PlacesHome::NAME: - return new PlacesHome($this->userId, $this->rootFolder, $this->reverseGeoCoderService, $this->placeMapper); - } - - throw new NotFound(); + return match ($name) { + AlbumsHome::NAME => new AlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userConfigService, $this->logger), + SharedAlbumsHome::NAME => new SharedAlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userManager, $this->groupManager, $this->userConfigService, $this->logger), + PlacesHome::NAME => new PlacesHome($this->userId, $this->rootFolder, $this->reverseGeoCoderService, $this->placeMapper), + default => throw new NotFound(), + }; } /** diff --git a/lib/Sabre/Place/PlacePhoto.php b/lib/Sabre/Place/PlacePhoto.php index a896af323..3c5945331 100644 --- a/lib/Sabre/Place/PlacePhoto.php +++ b/lib/Sabre/Place/PlacePhoto.php @@ -21,18 +21,15 @@ class PlacePhoto extends CollectionPhoto implements IFile { public function __construct( - private PlaceInfo $placeInfo, + private readonly PlaceInfo $placeInfo, PlaceFile $file, - private IRootFolder $rootFolder, + private readonly IRootFolder $rootFolder, Folder $userFolder, ) { parent::__construct($file, $userFolder); } - /** - * @return void - */ - public function delete() { + public function delete(): never { throw new Forbidden('Cannot remove from a place'); } diff --git a/lib/Sabre/Place/PlaceRoot.php b/lib/Sabre/Place/PlaceRoot.php index 060624d54..e09fd5c79 100644 --- a/lib/Sabre/Place/PlaceRoot.php +++ b/lib/Sabre/Place/PlaceRoot.php @@ -34,7 +34,7 @@ public function __construct( /** * @return never */ - public function delete() { + public function delete(): never { throw new Forbidden('Not allowed to delete a place collection'); } @@ -45,7 +45,7 @@ public function getName(): string { /** * @return never */ - public function setName($name) { + public function setName($name): never { throw new Forbidden('Cannot change the place collection name'); } @@ -54,14 +54,14 @@ public function setName($name) { * @param null|resource|string $data * @return never */ - public function createFile($name, $data = null) { + public function createFile($name, $data = null): never { throw new Forbidden('Cannot create a file in a place collection'); } /** * @return never */ - public function createDirectory($name) { + public function createDirectory($name): never { throw new Forbidden('Not allowed to create directories in this folder'); } @@ -71,7 +71,7 @@ public function createDirectory($name) { public function getChildren(): array { if ($this->children === null) { $this->children = array_map( - fn (PlaceFile $file) => new PlacePhoto($this->placeInfo, $file, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId)), + fn (PlaceFile $file): PlacePhoto => new PlacePhoto($this->placeInfo, $file, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId)), $this->placeMapper->findFilesForUserAndPlace($this->placeInfo->getUserId(), $this->placeInfo->getPlace()) ); } @@ -81,7 +81,7 @@ public function getChildren(): array { public function getChild($name): PlacePhoto { try { - [$fileId, $fileName] = explode('-', $name, 2); + [$fileId, $fileName] = explode('-', (string)$name, 2); $placeFile = $this->placeMapper->findFileForUserAndPlace($this->placeInfo->getUserId(), $this->placeInfo->getPlace(), $fileId, $fileName); return new PlacePhoto($this->placeInfo, $placeFile, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId)); } catch (NotFoundException $ex) { @@ -93,7 +93,7 @@ public function childExists($name): bool { try { $this->getChild($name); return true; - } catch (NotFound $e) { + } catch (NotFound) { return false; } } @@ -115,9 +115,7 @@ public function getFirstPhoto(): int { * @return int[] */ public function getFileIds(): array { - return array_map(function (PlacePhoto $file) { - return $file->getFileId(); - }, $this->getChildren()); + return array_map(fn (PlacePhoto $file): int => $file->getFileId(), $this->getChildren()); } /** diff --git a/lib/Sabre/Place/PlacesHome.php b/lib/Sabre/Place/PlacesHome.php index 560f1d1c8..0242ad425 100644 --- a/lib/Sabre/Place/PlacesHome.php +++ b/lib/Sabre/Place/PlacesHome.php @@ -36,7 +36,7 @@ public function __construct( /** * @return never */ - public function delete() { + public function delete(): never { throw new Forbidden(); } @@ -47,15 +47,15 @@ public function getName(): string { /** * @return never */ - public function setName($name) { + public function setName($name): never { throw new Forbidden('Permission denied to rename this folder'); } - public function createFile($name, $data = null) { + public function createFile($name, $data = null): never { throw new Forbidden('Not allowed to create files in this folder'); } - public function createDirectory($name) { + public function createDirectory($name): never { throw new Forbidden('Not allowed to create folder in this folder'); } @@ -74,7 +74,7 @@ public function getChild($name): PlaceRoot { public function getChildren(): array { if ($this->children === null) { $this->children = array_map( - fn (PlaceInfo $placeInfo) => new PlaceRoot($this->placeMapper, $this->reverseGeoCoderService, $placeInfo, $this->userId, $this->rootFolder), + fn (PlaceInfo $placeInfo): PlaceRoot => new PlaceRoot($this->placeMapper, $this->reverseGeoCoderService, $placeInfo, $this->userId, $this->rootFolder), $this->placeMapper->findPlacesForUser($this->userId) ); } @@ -86,7 +86,7 @@ public function childExists($name): bool { try { $this->getChild($name); return true; - } catch (NotFound $e) { + } catch (NotFound) { return false; } } diff --git a/lib/Sabre/PropFindPlugin.php b/lib/Sabre/PropFindPlugin.php index 5fc762f55..644ad8397 100644 --- a/lib/Sabre/PropFindPlugin.php +++ b/lib/Sabre/PropFindPlugin.php @@ -38,17 +38,15 @@ class PropFindPlugin extends ServerPlugin { public const COLLABORATORS_PROPERTYNAME = '{http://nextcloud.org/ns}collaborators'; public const PERMISSIONS_PROPERTYNAME = '{http://owncloud.org/ns}permissions'; - private IPreview $previewManager; - private ?Tree $tree; - private AlbumMapper $albumMapper; + private readonly IPreview $previewManager; + private ?Tree $tree = null; public function __construct( IPreview $previewManager, - AlbumMapper $albumMapper, - private IFilesMetadataManager $filesMetadataManager, + private readonly AlbumMapper $albumMapper, + private readonly IFilesMetadataManager $filesMetadataManager, ) { $this->previewManager = $previewManager; - $this->albumMapper = $albumMapper; } /** @@ -69,8 +67,8 @@ public function getPluginName() { */ public function initialize(Server $server) { $this->tree = $server->tree; - $server->on('propFind', [$this, 'propFind']); - $server->on('propPatch', [$this, 'handleUpdateProperties']); + $server->on('propFind', $this->propFind(...)); + $server->on('propPatch', $this->handleUpdateProperties(...)); } public function propFind(PropFind $propFind, INode $node): void { @@ -79,14 +77,14 @@ public function propFind(PropFind $propFind, INode $node): void { // Should be pre-emptively handled by the NodeDeletedEvent try { $fileInfo = $node->getFileInfo(); - } catch (NotFoundException $e) { + } catch (NotFoundException) { return; } - $propFind->handle(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, fn () => $node->getFile()->getFileId()); + $propFind->handle(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, fn (): int => $node->getFile()->getFileId()); $propFind->handle(FilesPlugin::GETETAG_PROPERTYNAME, fn () => $node->getETag()); - $propFind->handle(self::FILE_NAME_PROPERTYNAME, fn () => $node->getFile()->getName()); - $propFind->handle(self::FAVORITE_PROPERTYNAME, fn () => $node->isFavorite() ? 1 : 0); + $propFind->handle(self::FILE_NAME_PROPERTYNAME, fn (): string => $node->getFile()->getName()); + $propFind->handle(self::FAVORITE_PROPERTYNAME, fn (): int => $node->isFavorite() ? 1 : 0); $propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, fn () => json_encode($this->previewManager->isAvailable($fileInfo))); $propFind->handle(FilesPlugin::PERMISSIONS_PROPERTYNAME, function () use ($node): string { $permissions = DavUtil::getDavPermissions($node->getFileInfo()); @@ -113,17 +111,17 @@ public function propFind(PropFind $propFind, INode $node): void { } if ($node instanceof AlbumRoot) { - $propFind->handle(self::ORIGINAL_NAME_PROPERTYNAME, fn () => $node->getAlbum()->getAlbum()->getTitle()); - $propFind->handle(self::LAST_PHOTO_PROPERTYNAME, fn () => $node->getAlbum()->getAlbum()->getLastAddedPhoto()); - $propFind->handle(self::NBITEMS_PROPERTYNAME, fn () => count($node->getChildren())); - $propFind->handle(self::LOCATION_PROPERTYNAME, fn () => $node->getAlbum()->getAlbum()->getLocation()); + $propFind->handle(self::ORIGINAL_NAME_PROPERTYNAME, fn (): string => $node->getAlbum()->getAlbum()->getTitle()); + $propFind->handle(self::LAST_PHOTO_PROPERTYNAME, fn (): int => $node->getAlbum()->getAlbum()->getLastAddedPhoto()); + $propFind->handle(self::NBITEMS_PROPERTYNAME, fn (): int => count($node->getChildren())); + $propFind->handle(self::LOCATION_PROPERTYNAME, fn (): string => $node->getAlbum()->getAlbum()->getLocation()); $propFind->handle(self::DATE_RANGE_PROPERTYNAME, fn () => json_encode($node->getDateRange())); - $propFind->handle(self::COLLABORATORS_PROPERTYNAME, fn () => $node->getCollaborators()); + $propFind->handle(self::COLLABORATORS_PROPERTYNAME, fn (): array => $node->getCollaborators()); } if ($node instanceof PlaceRoot) { - $propFind->handle(self::LAST_PHOTO_PROPERTYNAME, fn () => $node->getFirstPhoto()); - $propFind->handle(self::NBITEMS_PROPERTYNAME, fn () => count($node->getChildren())); + $propFind->handle(self::LAST_PHOTO_PROPERTYNAME, fn (): int => $node->getFirstPhoto()); + $propFind->handle(self::NBITEMS_PROPERTYNAME, fn (): int => count($node->getChildren())); } } diff --git a/lib/Sabre/PublicRootCollection.php b/lib/Sabre/PublicRootCollection.php index 67dc85710..72476feeb 100644 --- a/lib/Sabre/PublicRootCollection.php +++ b/lib/Sabre/PublicRootCollection.php @@ -15,21 +15,22 @@ use OCP\IRequest; use OCP\Security\Bruteforce\IThrottler; use Psr\Log\LoggerInterface; +use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\NotFound; use Sabre\DAVACL\AbstractPrincipalCollection; -use Sabre\DAVACL\PrincipalBackend; +use Sabre\DAVACL\PrincipalBackend\BackendInterface; class PublicRootCollection extends AbstractPrincipalCollection { private const BRUTEFORCE_ACTION = 'publicphotos_webdav_auth'; public function __construct( - private AlbumMapper $albumMapper, - private IRootFolder $rootFolder, - PrincipalBackend\BackendInterface $principalBackend, - private UserConfigService $userConfigService, - private IRequest $request, - private IThrottler $throttler, - private LoggerInterface $logger, + private readonly AlbumMapper $albumMapper, + private readonly IRootFolder $rootFolder, + BackendInterface $principalBackend, + private readonly UserConfigService $userConfigService, + private readonly IRequest $request, + private readonly IThrottler $throttler, + private readonly LoggerInterface $logger, ) { parent::__construct($principalBackend, 'principals/token'); } @@ -44,7 +45,7 @@ public function getName(): string { * @param array $principalInfo */ public function getChildForPrincipal(array $principalInfo): PublicAlbumRoot { - throw new \Sabre\DAV\Exception\Forbidden(); + throw new Forbidden(); } /** @@ -60,7 +61,7 @@ public function getChild($name) { $this->throttler->sleepDelayOrThrowOnMax($this->request->getRemoteAddress(), self::BRUTEFORCE_ACTION); if (is_null($name)) { - throw new \Sabre\DAV\Exception\Forbidden(); + throw new Forbidden(); } $albums = $this->albumMapper->getSharedAlbumsForCollaboratorWithFiles($name, AlbumMapper::TYPE_LINK); diff --git a/lib/Sabre/RootCollection.php b/lib/Sabre/RootCollection.php index 6a5e74899..081bc2cef 100644 --- a/lib/Sabre/RootCollection.php +++ b/lib/Sabre/RootCollection.php @@ -17,21 +17,22 @@ use OCP\IUserManager; use OCP\IUserSession; use Psr\Log\LoggerInterface; +use Sabre\DAV\Exception\Forbidden; use Sabre\DAVACL\AbstractPrincipalCollection; -use Sabre\DAVACL\PrincipalBackend; +use Sabre\DAVACL\PrincipalBackend\BackendInterface; class RootCollection extends AbstractPrincipalCollection { public function __construct( - private AlbumMapper $albumMapper, - private PlaceMapper $placeMapper, - private ReverseGeoCoderService $reverseGeoCoderService, - private IUserSession $userSession, - private IRootFolder $rootFolder, - PrincipalBackend\BackendInterface $principalBackend, - private IUserManager $userManager, - private IGroupManager $groupManager, - private UserConfigService $userConfigService, - private LoggerInterface $logger, + private readonly AlbumMapper $albumMapper, + private readonly PlaceMapper $placeMapper, + private readonly ReverseGeoCoderService $reverseGeoCoderService, + private readonly IUserSession $userSession, + private readonly IRootFolder $rootFolder, + BackendInterface $principalBackend, + private readonly IUserManager $userManager, + private readonly IGroupManager $groupManager, + private readonly UserConfigService $userConfigService, + private readonly LoggerInterface $logger, ) { parent::__construct($principalBackend, 'principals/users'); } @@ -49,7 +50,7 @@ public function getChildForPrincipal(array $principalInfo): PhotosHome { [, $name] = \Sabre\Uri\split($principalInfo['uri']); $user = $this->userSession->getUser(); if (is_null($user) || $name !== $user->getUID()) { - throw new \Sabre\DAV\Exception\Forbidden(); + throw new Forbidden(); } return new PhotosHome($principalInfo, $this->albumMapper, $this->placeMapper, $this->reverseGeoCoderService, $name, $this->rootFolder, $this->userManager, $this->groupManager, $this->userConfigService, $this->logger); } diff --git a/lib/Service/MediaPlaceManager.php b/lib/Service/MediaPlaceManager.php index 5bc1f6076..d1f9f3723 100644 --- a/lib/Service/MediaPlaceManager.php +++ b/lib/Service/MediaPlaceManager.php @@ -14,9 +14,9 @@ class MediaPlaceManager { public function __construct( - private IFilesMetadataManager $filesMetadataManager, - private ReverseGeoCoderService $rgcService, - private PlaceMapper $placeMapper, + private readonly IFilesMetadataManager $filesMetadataManager, + private readonly ReverseGeoCoderService $rgcService, + private readonly PlaceMapper $placeMapper, ) { } diff --git a/lib/Service/ReverseGeoCoderService.php b/lib/Service/ReverseGeoCoderService.php index da48688a7..da2151092 100644 --- a/lib/Service/ReverseGeoCoderService.php +++ b/lib/Service/ReverseGeoCoderService.php @@ -30,9 +30,9 @@ class ReverseGeoCoderService { private ?array $citiesMapping = null; public function __construct( - private IAppData $appData, - private IClientService $clientService, - private IConfig $config, + private readonly IAppData $appData, + private readonly IClientService $clientService, + private readonly IConfig $config, ) { } @@ -46,7 +46,7 @@ private function geoNameFolder(): ISimpleFolder { if ($this->geoNameFolderCache === null) { try { $this->geoNameFolderCache = $this->appData->getFolder('geonames'); - } catch (NotFoundException $ex) { + } catch (NotFoundException) { $this->geoNameFolderCache = $this->appData->newFolder('geonames'); } } diff --git a/lib/Service/UserConfigService.php b/lib/Service/UserConfigService.php index f4ec1c768..80cd88d85 100644 --- a/lib/Service/UserConfigService.php +++ b/lib/Service/UserConfigService.php @@ -20,8 +20,8 @@ class UserConfigService { 'photosSourceFolders' => '["/Photos"]', ]; - private IConfig $config; - private IUserSession $userSession; + private readonly IConfig $config; + private readonly IUserSession $userSession; public function __construct( IConfig $config, diff --git a/rector.php b/rector.php new file mode 100644 index 000000000..0bab04cee --- /dev/null +++ b/rector.php @@ -0,0 +1,24 @@ +withPaths([ + __DIR__ . '/appinfo', + __DIR__ . '/lib', + __DIR__ . '/tests', + ]) + ->withPhpSets(php81: true) + ->withTypeCoverageLevel(10) + ->withImportNames(importShortClasses: false) + ->withSets([ + NextcloudSets::NEXTCLOUD_27, + ]); diff --git a/tests/Album/AlbumMapperTest.php b/tests/Album/AlbumMapperTest.php index 5d07480bc..d81d503d8 100644 --- a/tests/Album/AlbumMapperTest.php +++ b/tests/Album/AlbumMapperTest.php @@ -21,6 +21,7 @@ use OCP\IL10N; use OCP\IUserManager; use OCP\Security\ISecureRandom; +use OCP\Server; use Test\TestCase; /** @@ -50,16 +51,14 @@ protected function setUp(): void { parent::setUp(); $this->createdFiles = []; - $this->connection = \OC::$server->get(IDBConnection::class); - $this->mimeLoader = \OC::$server->get(IMimeTypeLoader::class); + $this->connection = Server::get(IDBConnection::class); + $this->mimeLoader = Server::get(IMimeTypeLoader::class); $this->timeFactory = $this->createMock(ITimeFactory::class); $this->userManager = $this->createMock(IUserManager::class); $this->groupManager = $this->createMock(IGroupManager::class); $this->l10n = $this->createMock(IL10N::class); $this->secureRandom = $this->createMock(ISecureRandom::class); - $this->timeFactory->method('getTime')->willReturnCallback(function () { - return $this->time; - }); + $this->timeFactory->method('getTime')->willReturnCallback(fn (): int => $this->time); if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) { $this->markTestSkipped('Feature is broken on oracle'); @@ -134,9 +133,7 @@ public function testCreateList() { $this->mapper->create('user2', 'album3'); $retrievedAlbums = $this->mapper->getForUser('user1'); - usort($retrievedAlbums, function (AlbumInfo $a, AlbumInfo $b) { - return $a->getId() <=> $b->getId(); - }); + usort($retrievedAlbums, fn (AlbumInfo $a, AlbumInfo $b): int => $a->getId() <=> $b->getId()); $this->assertEquals([$album1, $album2], $retrievedAlbums); } @@ -159,9 +156,7 @@ public function testCreateDeleteList() { $this->mapper->delete($album1->getId()); $retrievedAlbums = $this->mapper->getForUser('user1'); - usort($retrievedAlbums, function (AlbumInfo $a, AlbumInfo $b) { - return $a->getId() <=> $b->getId(); - }); + usort($retrievedAlbums, fn (AlbumInfo $a, AlbumInfo $b): int => $a->getId() <=> $b->getId()); $this->assertEquals([$album2], $retrievedAlbums); } diff --git a/tests/Migration/Version30000Date20240417075405Test.php b/tests/Migration/Version30000Date20240417075405Test.php index 4d0d73055..b4e982873 100644 --- a/tests/Migration/Version30000Date20240417075405Test.php +++ b/tests/Migration/Version30000Date20240417075405Test.php @@ -12,6 +12,7 @@ use OCA\Photos\Migration\Version30000Date20240417075405; use OCP\IDBConnection; use OCP\Migration\IOutput; +use OCP\Server; use Test\TestCase; /** @@ -23,7 +24,7 @@ class Version30000Date20240417075405Test extends TestCase { protected function setUp(): void { parent::setUp(); - $this->connection = \OCP\Server::get(IDBConnection::class); + $this->connection = Server::get(IDBConnection::class); } protected function tearDown(): void { @@ -75,7 +76,7 @@ public function testPostSchemaChange(): void { $migration->postSchemaChange( $this->createMock(IOutput::class), - \Closure::fromCallable(fn () => false), + \Closure::fromCallable(fn (): bool => false), [] ); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 865a2eeca..301798cec 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,5 +1,7 @@ =27", + "php": "^8.1", + "rector/rector": "^2.0.4", + "webmozart/assert": "^1.11" + }, + "require-dev": { + "phpunit/phpunit": "^10.5", + "ramsey/devtools": "^2.0" + }, + "type": "library", + "extra": { + "captainhook": { + "force-install": true + }, + "ramsey/devtools": { + "memory-limit": "-1", + "command-prefix": "dev" + }, + "ramsey/conventional-commits": { + "configFile": "conventional-commits.json" + } + }, + "autoload": { + "psr-4": { + "OCP\\": "vendor/nextcloud/ocp/OCP", + "Nextcloud\\Rector\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "AGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Christoph Wurst", + "email": "christoph@winzerhof-wurst.at", + "homepage": "https://wuc.me" + } + ], + "description": "Rector upgrade rules for Nextcloud", + "keywords": [ + "nextcloud", + "refactoring" + ], + "support": { + "issues": "https://github.com/nextcloud-libraries/rector/issues", + "source": "https://github.com/nextcloud-libraries/rector/tree/v0.4.1" + }, + "time": "2025-03-31T15:27:10+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "2.1.15", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "402d11c1aa40ae2e1c3a512e6a4edb957527b20b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/402d11c1aa40ae2e1c3a512e6a4edb957527b20b", + "reference": "402d11c1aa40ae2e1c3a512e6a4edb957527b20b", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2025-05-14T11:16:08+00:00" + }, + { + "name": "psr/clock", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/clock.git", + "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d", + "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Clock\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for reading the clock.", + "homepage": "https://github.com/php-fig/clock", + "keywords": [ + "clock", + "now", + "psr", + "psr-20", + "time" + ], + "support": { + "issues": "https://github.com/php-fig/clock/issues", + "source": "https://github.com/php-fig/clock/tree/1.0.0" + }, + "time": "2022-11-25T14:36:26+00:00" + }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, + "time": "2019-01-08T18:20:26+00:00" + }, + { + "name": "psr/log", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.2" + }, + "time": "2024-09-11T13:17:53+00:00" + }, + { + "name": "rector/rector", + "version": "2.0.16", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "f1366d1f8c7490541c8f7af6e5c7cef7cca1b5a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/f1366d1f8c7490541c8f7af6e5c7cef7cca1b5a2", + "reference": "f1366d1f8c7490541c8f7af6e5c7cef7cca1b5a2", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0", + "phpstan/phpstan": "^2.1.14" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "suggest": { + "ext-dom": "To manipulate phpunit.xml via the custom-rule command" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/2.0.16" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2025-05-12T16:37:16+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.11.0", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "php": "^7.2 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<4.6.1 || 4.6.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.13" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.11.0" + }, + "time": "2022-06-03T18:03:27+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": {}, + "platform-dev": {}, + "plugin-api-version": "2.6.0" +}