6
6
7
7
use daos \DatabaseInterface ;
8
8
use daos \ItemOptions ;
9
- use DateTime ;
9
+ use DateTimeImmutable ;
10
10
use DateTimeImmutable ;
11
11
use helpers \Configuration ;
12
12
use helpers \HtmlString ;
@@ -206,9 +206,9 @@ public function updateLastSeen(array $itemIds): void {
206
206
/**
207
207
* cleanup orphaned and old items
208
208
*
209
- * @param ?DateTime $date date to delete all items older than this value
209
+ * @param ?DateTimeImmutable $date date to delete all items older than this value
210
210
*/
211
- public function cleanup (?DateTime $ date ): void {
211
+ public function cleanup (?DateTimeImmutable $ date ): void {
212
212
$ this ->database ->exec ('DELETE FROM ' . $ this ->configuration ->dbPrefix . 'items
213
213
WHERE source NOT IN (
214
214
SELECT id FROM ' . $ this ->configuration ->dbPrefix . 'sources) ' );
@@ -226,7 +226,7 @@ public function cleanup(?DateTime $date): void {
226
226
*
227
227
* @param ItemOptions $options search, offset and filter params
228
228
*
229
- * @return array<array{id: int, datetime: DateTime , title: string, content: string, unread: bool, starred: bool, source: int, thumbnail: string, icon: string, uid: string, link: string, updatetime: DateTime , author: string, sourcetitle: string, tags: string[]}> items as array
229
+ * @return array<array{id: int, datetime: DateTimeImmutable , title: string, content: string, unread: bool, starred: bool, source: int, thumbnail: string, icon: string, uid: string, link: string, updatetime: DateTimeImmutable , author: string, sourcetitle: string, tags: string[]}> items as array
230
230
*/
231
231
public function get (ItemOptions $ options ): array {
232
232
$ params = [];
@@ -375,12 +375,12 @@ public function hasMore(): bool {
375
375
* Obtain new or changed items in the database for synchronization with clients.
376
376
*
377
377
* @param int $sinceId id of last seen item
378
- * @param DateTime $notBefore cut off time stamp
379
- * @param DateTime $since timestamp of last seen item
378
+ * @param DateTimeImmutable $notBefore cut off time stamp
379
+ * @param DateTimeImmutable $since timestamp of last seen item
380
380
*
381
- * @return array<array{id: int, datetime: DateTime , title: string, content: string, unread: bool, starred: bool, source: int, thumbnail: string, icon: string, uid: string, link: string, updatetime: DateTime , author: string, sourcetitle: string, tags: string[]}> of items
381
+ * @return array<array{id: int, datetime: DateTimeImmutable , title: string, content: string, unread: bool, starred: bool, source: int, thumbnail: string, icon: string, uid: string, link: string, updatetime: DateTimeImmutable , author: string, sourcetitle: string, tags: string[]}> of items
382
382
*/
383
- public function sync (int $ sinceId , DateTime $ notBefore , DateTime $ since , int $ howMany ): array {
383
+ public function sync (int $ sinceId , DateTimeImmutable $ notBefore , DateTimeImmutable $ since , int $ howMany ): array {
384
384
$ query = 'SELECT
385
385
items.id, datetime, items.title AS title, content, unread, starred, source, thumbnail, icon, uid, link, updatetime, author, sources.title as sourcetitle, sources.tags as tags
386
386
FROM ' . $ this ->configuration ->dbPrefix . 'items AS items, ' . $ this ->configuration ->dbPrefix . 'sources AS sources
@@ -575,11 +575,11 @@ public function lastUpdate(): ?DateTimeImmutable {
575
575
/**
576
576
* returns the statuses of items last update
577
577
*
578
- * @param DateTime $since minimal date of returned items
578
+ * @param DateTimeImmutable $since minimal date of returned items
579
579
*
580
580
* @return array<array{id: int, unread: bool, starred: bool}> of unread, starred, etc. status of specified items
581
581
*/
582
- public function statuses (DateTime $ since ): array {
582
+ public function statuses (DateTimeImmutable $ since ): array {
583
583
$ res = $ this ->database ->exec (
584
584
'SELECT id, unread, starred
585
585
FROM ' . $ this ->configuration ->dbPrefix . 'items
@@ -627,7 +627,7 @@ public function bulkStatusUpdate(array $statuses): void {
627
627
628
628
// sanitize update time
629
629
if (array_key_exists ('datetime ' , $ status )) {
630
- $ updateDate = new \DateTime ($ status ['datetime ' ]);
630
+ $ updateDate = new \DateTimeImmutable ($ status ['datetime ' ]);
631
631
} else {
632
632
$ updateDate = null ;
633
633
}
0 commit comments