2828use OCP \Notification \IManager as INotificationManager ;
2929
3030class APIv2Controller extends OCSController {
31- /** @var string */
32- protected $ filter ;
33-
34- /** @var int */
35- protected $ since ;
36-
37- /** @var int */
38- protected $ limit ;
39-
40- /** @var string */
41- protected $ sort ;
42-
43- /** @var string */
44- protected $ objectType ;
45-
46- /** @var int */
47- protected $ objectId ;
48-
49- /** @var string */
50- protected $ user ;
51-
52- /** @var bool */
53- protected $ loadPreviews ;
31+ protected string $ filter = 'all ' ;
32+ protected int $ since = 0 ;
33+ protected int $ limit = 50 ;
34+ protected string $ sort = 'desc ' ;
35+ protected string $ objectType = '' ;
36+ protected int $ objectId = 0 ;
37+ protected string $ user = '' ;
38+ protected bool $ loadPreviews = false ;
5439
5540 public function __construct (
5641 $ appName ,
@@ -71,26 +56,19 @@ public function __construct(
7156 }
7257
7358 /**
74- * @param string $filter
75- * @param int $since
76- * @param int $limit
77- * @param bool $previews
78- * @param string $objectType
79- * @param int $objectId
80- * @param string $sort
8159 * @throws InvalidFilterException when the filter is invalid
8260 * @throws \OutOfBoundsException when no user is given
8361 */
84- protected function validateParameters ($ filter , $ since , $ limit , $ previews , $ objectType , $ objectId , $ sort ) {
85- $ this ->filter = \is_string ( $ filter) ? $ filter : ' all ' ;
62+ protected function validateParameters (string $ filter , int $ since , int $ limit , bool $ previews , string $ objectType , int $ objectId , string $ sort ): void {
63+ $ this ->filter = $ filter ;
8664 if ($ this ->filter !== $ this ->data ->validateFilter ($ this ->filter )) {
8765 throw new InvalidFilterException ('Invalid filter ' );
8866 }
89- $ this ->since = ( int ) $ since ;
90- $ this ->limit = ( int ) $ limit ;
91- $ this ->loadPreviews = ( bool ) $ previews ;
92- $ this ->objectType = ( string ) $ objectType ;
93- $ this ->objectId = ( int ) $ objectId ;
67+ $ this ->since = $ since ;
68+ $ this ->limit = $ limit ;
69+ $ this ->loadPreviews = $ previews ;
70+ $ this ->objectType = $ objectType ;
71+ $ this ->objectId = $ objectId ;
9472 $ this ->sort = \in_array ($ sort , ['asc ' , 'desc ' ], true ) ? $ sort : 'desc ' ;
9573
9674 if (($ this ->objectType !== '' && $ this ->objectId === 0 ) || ($ this ->objectType === '' && $ this ->objectId !== 0 )) {
@@ -110,32 +88,15 @@ protected function validateParameters($filter, $since, $limit, $previews, $objec
11088
11189 /**
11290 * @NoAdminRequired
113- *
114- * @param int $since
115- * @param int $limit
116- * @param bool $previews
117- * @param string $object_type
118- * @param int $object_id
119- * @param string $sort
120- * @return DataResponse
12191 */
122- public function getDefault ($ since = 0 , $ limit = 50 , $ previews = false , $ object_type = '' , $ object_id = 0 , $ sort = 'desc ' ): DataResponse {
92+ public function getDefault (int $ since = 0 , int $ limit = 50 , bool $ previews = false , string $ object_type = '' , int $ object_id = 0 , string $ sort = 'desc ' ): DataResponse {
12393 return $ this ->get ('all ' , $ since , $ limit , $ previews , $ object_type , $ object_id , $ sort );
12494 }
12595
12696 /**
12797 * @NoAdminRequired
128- *
129- * @param string $filter
130- * @param int $since
131- * @param int $limit
132- * @param bool $previews
133- * @param string $object_type
134- * @param int $object_id
135- * @param string $sort
136- * @return DataResponse
13798 */
138- public function getFilter ($ filter , $ since = 0 , $ limit = 50 , $ previews = false , $ object_type = '' , $ object_id = 0 , $ sort = 'desc ' ): DataResponse {
99+ public function getFilter (string $ filter , int $ since = 0 , int $ limit = 50 , bool $ previews = false , string $ object_type = '' , int $ object_id = 0 , string $ sort = 'desc ' ): DataResponse {
139100 return $ this ->get ($ filter , $ since , $ limit , $ previews , $ object_type , $ object_id , $ sort );
140101 }
141102
@@ -191,17 +152,7 @@ public function listFilters(): DataResponse {
191152 return new DataResponse ($ filters );
192153 }
193154
194- /**
195- * @param string $filter
196- * @param int $since
197- * @param int $limit
198- * @param bool $previews
199- * @param string $filterObjectType
200- * @param int $filterObjectId
201- * @param string $sort
202- * @return DataResponse
203- */
204- protected function get ($ filter , $ since , $ limit , $ previews , $ filterObjectType , $ filterObjectId , $ sort ): DataResponse {
155+ protected function get (string $ filter , int $ since , int $ limit , bool $ previews , string $ filterObjectType , int $ filterObjectId , string $ sort ): DataResponse {
205156 try {
206157 $ this ->validateParameters ($ filter , $ since , $ limit , $ previews , $ filterObjectType , $ filterObjectId , $ sort );
207158 } catch (InvalidFilterException $ e ) {
0 commit comments