1111
1212namespace OCA \Google \Service ;
1313
14- use Ds \Set ;
1514use DateTime ;
1615use DateTimeZone ;
16+ use Ds \Set ;
1717use Exception ;
1818use Generator ;
1919use OCA \DAV \CalDAV \CalDavBackend ;
2020use OCA \Google \AppInfo \Application ;
21- use OCP \IL10N ;
22- use OCP \BackgroundJob \IJobList ;
2321use OCA \Google \BackgroundJob \ImportCalendarJob ;
22+ use OCP \BackgroundJob \IJobList ;
23+ use OCP \IL10N ;
2424
2525use Ortic \ColorConverter \Color ;
2626use Ortic \ColorConverter \Colors \Named ;
@@ -86,7 +86,6 @@ private function getClosestCssColor(string $hexColor): string {
8686 ];
8787 // init
8888 $ closestColor = 'black ' ;
89- /** @var Color $color */
9089 $ black = Color::fromString (Named::CSS_COLORS ['black ' ]);
9190 $ rgbBlack = [
9291 'r ' => $ black ->getRed (),
@@ -96,7 +95,6 @@ private function getClosestCssColor(string $hexColor): string {
9695 $ closestDiff = $ this ->colorDiff ($ rbgColor , $ rgbBlack );
9796
9897 foreach (Named::CSS_COLORS as $ name => $ hex ) {
99- /** @var Color $color */
10098 $ c = Color::fromString ($ hex );
10199 $ rgb = [
102100 'r ' => $ c ->getRed (),
@@ -170,7 +168,7 @@ private function getCalendarLastEventModificationTimestamp(int $calendarId): int
170168 * @param string $calId
171169 * @param string $calName
172170 * @param ?string $color
173- * @return array
171+ * @return array{error: string}|array{nbAdded: int, nbUpdated: int, calName: string}
174172 */
175173 public function safeImportCalendar (string $ userId , string $ calId , string $ calName , ?string $ color = null ): array {
176174 $ startTime = microtime (true );
@@ -201,7 +199,7 @@ public function safeImportCalendar(string $userId, string $calId, string $calNam
201199 * @param string $calId
202200 * @param string $calName
203201 * @param ?string $color
204- * @return array
202+ * @return array{nbAdded: int, nbUpdated: int, calName: string}
205203 */
206204 public function importCalendar (string $ userId , string $ calId , string $ calName , ?string $ color = null ): array {
207205 $ params = [];
@@ -216,13 +214,16 @@ public function importCalendar(string $userId, string $calId, string $calName, ?
216214 $ ncCalId = $ this ->caldavBackend ->createCalendar ('principals/users/ ' . $ userId , $ newCalName , $ params );
217215 }
218216
217+ /** @var Set<string> $unseenURIs */
219218 $ unseenURIs = new Set ();
219+ /** @var array{uri: string} $e */
220220 foreach ($ this ->caldavBackend ->getCalendarObjects ($ ncCalId ) as $ e ) {
221221 $ unseenURIs ->add ($ e ['uri ' ]);
222222 }
223223
224224 // get color list
225225 $ eventColors = [];
226+ /** @type array{error: string}|array{event: array} $colors */
226227 $ colors = $ this ->googleApiService ->request ($ userId , 'calendar/v3/colors ' );
227228 if (!isset ($ colors ['error ' ]) && isset ($ colors ['event ' ])) {
228229 $ eventColors = $ colors ['event ' ];
@@ -385,7 +386,7 @@ public function importCalendar(string $userId, string $calId, string $calName, ?
385386
386387 $ eventGeneratorReturn = $ events ->getReturn ();
387388 if (isset ($ eventGeneratorReturn ['error ' ])) {
388- return $ eventGeneratorReturn ;
389+ /* return $eventGeneratorReturn; */
389390 }
390391 return [
391392 'nbAdded ' => $ nbAdded ,
@@ -405,7 +406,7 @@ public function resetRegisteredSyncCalendar(): void {
405406 * Check if a background job is registered.
406407 * @param string $userId The user id of the job.
407408 * @param string $calId The calendar id of the job.
408- * @return Whether the job with the given parameters is registered.
409+ * @return bool Whether the job with the given parameters is registered.
409410 */
410411 public function isJobRegisteredForCalendar (string $ userId , string $ calId ): bool {
411412 foreach ($ this ->jobList ->getJobsIterator (ImportCalendarJob::class, null , 0 ) as $ job ) {
@@ -426,7 +427,7 @@ public function isJobRegisteredForCalendar(string $userId, string $calId): bool
426427 * @param string $calId
427428 * @param string $calName
428429 * @param ?string $color
429- * @return array
430+ * @return void
430431 */
431432 public function registerSyncCalendar (string $ userId , string $ calId , string $ calName , ?string $ color = null ): void {
432433 $ argument = [
@@ -437,7 +438,6 @@ public function registerSyncCalendar(string $userId, string $calId, string $calN
437438 ];
438439
439440 foreach ($ this ->jobList ->getJobsIterator (ImportCalendarJob::class, null , 0 ) as $ job ) {
440- $ id = $ job ->getId ();
441441 $ args = $ job ->getArgument ();
442442
443443 if ($ args ["user_id " ] == $ argument ["user_id " ] && $ args ["cal_id " ] == $ argument ["cal_id " ]) {
@@ -456,12 +456,12 @@ public function registerSyncCalendar(string $userId, string $calId, string $calN
456456 * @param string $calId
457457 * @param string $calName
458458 * @param ?string $color
459- * @return array
459+ * @return void
460460 */
461461 public function unregisterSyncCalendar (string $ userId , string $ calId ): void {
462462
463463 foreach ($ this ->jobList ->getJobsIterator (ImportCalendarJob::class, null , 0 ) as $ job ) {
464- $ id = $ job -> getId ();
464+ /** @var array{user_id: string, cal_id: string} $args */
465465 $ args = $ job ->getArgument ();
466466
467467 if ($ args ["user_id " ] == $ userId && $ args ["cal_id " ] == $ calId ) {
0 commit comments