2828use OCP \Notification \IManager as INotificationManager ;
2929
3030class APIv2Controller extends OCSController {
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 ;
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 ;
3954
4055 public function __construct (
4156 $ appName ,
@@ -56,19 +71,26 @@ public function __construct(
5671 }
5772
5873 /**
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
5981 * @throws InvalidFilterException when the filter is invalid
6082 * @throws \OutOfBoundsException when no user is given
6183 */
62- protected function validateParameters (string $ filter , int $ since , int $ limit , bool $ previews , string $ objectType , int $ objectId , string $ sort ): void {
63- $ this ->filter = $ filter ;
84+ protected function validateParameters ($ filter , $ since , $ limit , $ previews , $ objectType , $ objectId , $ sort ) {
85+ $ this ->filter = \is_string ( $ filter) ? $ filter : ' all ' ;
6486 if ($ this ->filter !== $ this ->data ->validateFilter ($ this ->filter )) {
6587 throw new InvalidFilterException ('Invalid filter ' );
6688 }
67- $ this ->since = $ since ;
68- $ this ->limit = $ limit ;
69- $ this ->loadPreviews = $ previews ;
70- $ this ->objectType = $ objectType ;
71- $ this ->objectId = $ objectId ;
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 ;
7294 $ this ->sort = \in_array ($ sort , ['asc ' , 'desc ' ], true ) ? $ sort : 'desc ' ;
7395
7496 if (($ this ->objectType !== '' && $ this ->objectId === 0 ) || ($ this ->objectType === '' && $ this ->objectId !== 0 )) {
@@ -88,15 +110,32 @@ protected function validateParameters(string $filter, int $since, int $limit, bo
88110
89111 /**
90112 * @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
91121 */
92- public function getDefault (int $ since = 0 , int $ limit = 50 , bool $ previews = false , string $ object_type = '' , int $ object_id = 0 , string $ sort = 'desc ' ): DataResponse {
122+ public function getDefault ($ since = 0 , $ limit = 50 , $ previews = false , $ object_type = '' , $ object_id = 0 , $ sort = 'desc ' ): DataResponse {
93123 return $ this ->get ('all ' , $ since , $ limit , $ previews , $ object_type , $ object_id , $ sort );
94124 }
95125
96126 /**
97127 * @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
98137 */
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 {
138+ public function getFilter ($ filter , $ since = 0 , $ limit = 50 , $ previews = false , $ object_type = '' , $ object_id = 0 , $ sort = 'desc ' ): DataResponse {
100139 return $ this ->get ($ filter , $ since , $ limit , $ previews , $ object_type , $ object_id , $ sort );
101140 }
102141
@@ -152,7 +191,17 @@ public function listFilters(): DataResponse {
152191 return new DataResponse ($ filters );
153192 }
154193
155- protected function get (string $ filter , int $ since , int $ limit , bool $ previews , string $ filterObjectType , int $ filterObjectId , string $ sort ): DataResponse {
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 {
156205 try {
157206 $ this ->validateParameters ($ filter , $ since , $ limit , $ previews , $ filterObjectType , $ filterObjectId , $ sort );
158207 } catch (InvalidFilterException $ e ) {
0 commit comments