1
1
<?php
2
- function param_to_bool ($ p ) {
2
+ function param_to_bool ($ p ): bool {
3
3
return $ p && ($ p !== "f " && $ p !== "false " );
4
4
}
5
5
@@ -26,7 +26,7 @@ class FeverAPI extends Handler {
26
26
private $ xml ;
27
27
28
28
// find the user in the db with a particular api key
29
- private function setUser ()
29
+ private function setUser (): void
30
30
{
31
31
$ apikey = isset ($ _REQUEST ["api_key " ]) ? clean ($ _REQUEST ["api_key " ]) : "" ;
32
32
@@ -77,7 +77,7 @@ private function setUser()
77
77
}
78
78
79
79
// set whether xml or json
80
- private function setXml ()
80
+ private function setXml (): void
81
81
{
82
82
$ this ->xml = false ;
83
83
if (isset ($ _REQUEST ["api " ]))
@@ -89,7 +89,7 @@ private function setXml()
89
89
}
90
90
}
91
91
92
- private function setIdHack ()
92
+ private function setIdHack (): void
93
93
{
94
94
$ this ->id_hack = false ;
95
95
@@ -110,7 +110,7 @@ private function setIdHack()
110
110
}
111
111
112
112
// validate the api_key, user preferences
113
- function before ($ method ) {
113
+ function before ($ method ): bool {
114
114
/* classes/api.php before */
115
115
116
116
if (parent ::before ($ method )) {
@@ -152,7 +152,7 @@ function before($method) {
152
152
153
153
// always include api_version, status as 'auth'
154
154
// output json/xml
155
- function wrap ($ status , $ reply )
155
+ function wrap ($ status , $ reply ): void
156
156
{
157
157
/* classes/api.php wrap */
158
158
$ arr = array ("api_version " => self ::API_LEVEL ,
@@ -189,7 +189,7 @@ function wrap($status, $reply)
189
189
190
190
// fever supports xml wrapped in <response> tags
191
191
// TODO: holy crap replace this junk
192
- private function array_to_xml ($ array , $ container = 'response ' , $ is_root = true )
192
+ private function array_to_xml ($ array , $ container = 'response ' , $ is_root = true ): string
193
193
{
194
194
if (!is_array ($ array )) return array_to_xml (array ($ array ));
195
195
@@ -241,7 +241,7 @@ private function array_to_xml($array, $container = 'response', $is_root = true)
241
241
}
242
242
243
243
// every authenticated method includes last_refreshed_on_time
244
- private function lastRefreshedOnTime ()
244
+ private function lastRefreshedOnTime (): int
245
245
{
246
246
$ sth = $ this ->pdo ->prepare ("SELECT " . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated
247
247
FROM ttrss_feeds
@@ -261,7 +261,7 @@ private function lastRefreshedOnTime()
261
261
return $ last_refreshed_on_time ;
262
262
}
263
263
264
- private function flattenGroups (&$ groupsToGroups , &$ groups , &$ groupsToTitle , $ index )
264
+ private function flattenGroups (&$ groupsToGroups , &$ groups , &$ groupsToTitle , $ index ): void
265
265
{
266
266
foreach ($ groupsToGroups [$ index ] as $ item )
267
267
{
@@ -272,7 +272,7 @@ private function flattenGroups(&$groupsToGroups, &$groups, &$groupsToTitle, $ind
272
272
}
273
273
}
274
274
275
- function getGroups ()
275
+ function getGroups (): array
276
276
{
277
277
// TODO: ordering of child categories etc
278
278
$ groups = array ();
@@ -320,7 +320,7 @@ function getGroups()
320
320
return $ groups ;
321
321
}
322
322
323
- function getFeeds ()
323
+ function getFeeds (): array
324
324
{
325
325
$ feeds = array ();
326
326
@@ -344,7 +344,7 @@ function getFeeds()
344
344
return $ feeds ;
345
345
}
346
346
347
- function getFavicons ()
347
+ function getFavicons (): array
348
348
{
349
349
$ favicons = array ();
350
350
@@ -369,7 +369,7 @@ function getFavicons()
369
369
return $ favicons ;
370
370
}
371
371
372
- function getLinks ()
372
+ function getLinks (): array
373
373
{
374
374
// TODO: is there a 'hot links' alternative in ttrss?
375
375
// use ttrss_user_entries / score > 0 / unread
@@ -459,7 +459,7 @@ function getLinks()
459
459
return $ links ;
460
460
}
461
461
462
- function formatBytes ($ bytes , $ precision = 2 ) {
462
+ function formatBytes ($ bytes , $ precision = 2 ): string {
463
463
$ units = array ('B ' , 'KB ' , 'MB ' , 'GB ' , 'TB ' );
464
464
465
465
$ bytes = max ($ bytes , 0 );
@@ -473,7 +473,7 @@ function formatBytes($bytes, $precision = 2) {
473
473
return round ($ bytes , $ precision ) . ' ' . $ units [$ pow ];
474
474
}
475
475
476
- function getItems ()
476
+ function getItems (): array
477
477
{
478
478
// items from specific groups, feeds
479
479
$ items = array ();
@@ -590,10 +590,10 @@ function getItems()
590
590
591
591
while ($ line = $ sth ->fetch ())
592
592
{
593
- $ line_content = sanitize (
593
+ $ line_content = Sanitizer:: sanitize (
594
594
$ line ["content " ],
595
595
param_to_bool ($ line ['hide_images ' ]),
596
- false , $ line ["site_url " ], false , $ line ["id " ]);
596
+ false , $ line ["site_url " ], [] , $ line ["id " ]);
597
597
598
598
if ($ this ->add_attached_files ){
599
599
$ enclosures = Article::_get_enclosures ($ line ["id " ]);
@@ -631,7 +631,7 @@ function getItems()
631
631
return $ items ;
632
632
}
633
633
634
- function getTotalItems ()
634
+ function getTotalItems (): int
635
635
{
636
636
// number of total items
637
637
$ total_items = 0 ;
@@ -649,7 +649,7 @@ function getTotalItems()
649
649
return $ total_items ;
650
650
}
651
651
652
- function getFeedsGroup ()
652
+ function getFeedsGroup (): array
653
653
{
654
654
$ feeds_groups = array ();
655
655
@@ -683,7 +683,7 @@ function getFeedsGroup()
683
683
return $ feeds_groups ;
684
684
}
685
685
686
- function getUnreadItemIds ()
686
+ function getUnreadItemIds (): string
687
687
{
688
688
$ unreadItemIdsCSV = "" ;
689
689
$ sth = $ this ->pdo ->prepare ("SELECT ref_id
@@ -700,7 +700,7 @@ function getUnreadItemIds()
700
700
return $ unreadItemIdsCSV ;
701
701
}
702
702
703
- function getSavedItemIds ()
703
+ function getSavedItemIds (): string
704
704
{
705
705
$ savedItemIdsCSV = "" ;
706
706
$ sth = $ this ->pdo ->prepare ("SELECT ref_id
@@ -717,7 +717,7 @@ function getSavedItemIds()
717
717
return $ savedItemIdsCSV ;
718
718
}
719
719
720
- function getEqualItems ($ id )
720
+ function getEqualItems ($ id ): string
721
721
{
722
722
//get all ids which have identical links (Reference is found by id)
723
723
$ sth = $ this ->pdo ->prepare ("SELECT id
@@ -741,7 +741,7 @@ function getEqualItems($id)
741
741
return $ ids ;
742
742
}
743
743
744
- function setItem ($ id , $ field_raw , $ mode )
744
+ function setItem ($ id , $ field_raw , $ mode ): void
745
745
{
746
746
/* classes/api.php updateArticle */
747
747
@@ -790,30 +790,30 @@ function setItem($id, $field_raw, $mode)
790
790
}
791
791
}
792
792
793
- function setItemAsRead ($ id )
793
+ function setItemAsRead ($ id ): void
794
794
{
795
795
//action is true for all Equal Items
796
796
$ ids = $ this ->getEqualItems ($ id );
797
797
$ this ->setItem ($ ids , 1 , 0 );
798
798
}
799
799
800
- function setItemAsUnread ($ id )
800
+ function setItemAsUnread ($ id ): void
801
801
{
802
802
$ ids = $ this ->getEqualItems ($ id );
803
803
$ this ->setItem ($ ids , 1 , 1 );
804
804
}
805
805
806
- function setItemAsSaved ($ id )
806
+ function setItemAsSaved ($ id ): void
807
807
{
808
808
$ this ->setItem ($ id , 0 , 1 );
809
809
}
810
810
811
- function setItemAsUnsaved ($ id )
811
+ function setItemAsUnsaved ($ id ): void
812
812
{
813
813
$ this ->setItem ($ id , 0 , 0 );
814
814
}
815
815
816
- function setFeed ($ id , $ cat , $ before =0 )
816
+ function setFeed ($ id , $ cat , $ before =0 ): void
817
817
{
818
818
/* classes/feeds.php catchup_feed */
819
819
@@ -863,18 +863,18 @@ function setFeed($id, $cat, $before=0)
863
863
}
864
864
}
865
865
866
- function setFeedAsRead ($ id , $ before )
866
+ function setFeedAsRead ($ id , $ before ): void
867
867
{
868
868
$ this ->setFeed ($ id , false , $ before );
869
869
}
870
870
871
- function setGroupAsRead ($ id , $ before )
871
+ function setGroupAsRead ($ id , $ before ): void
872
872
{
873
873
$ this ->setFeed ($ id , true , $ before );
874
874
}
875
875
876
876
// this does all the processing, since the fever api does not have a specific variable that specifies the operation
877
- function index ()
877
+ function index (): void
878
878
{
879
879
$ response_arr = array ();
880
880
@@ -926,7 +926,7 @@ function index()
926
926
927
927
}
928
928
929
- function markId ($ id )
929
+ function markId ($ id ): void
930
930
{
931
931
if (is_numeric ($ id ))
932
932
{
0 commit comments