2525 */
2626namespace OCA \WeatherStatus \Controller ;
2727
28+ use OCA \WeatherStatus \ResponseDefinitions ;
2829use OCA \WeatherStatus \Service \WeatherStatusService ;
2930use OCP \AppFramework \Http ;
3031use OCP \AppFramework \Http \DataResponse ;
3132use OCP \AppFramework \OCSController ;
3233use OCP \ILogger ;
3334use OCP \IRequest ;
3435
36+ /**
37+ * @psalm-import-type WeatherStatusForecast from ResponseDefinitions
38+ */
3539class WeatherStatusController extends OCSController {
3640
3741 /** @var string */
@@ -59,7 +63,7 @@ public function __construct(string $appName,
5963 *
6064 * Try to use the address set in user personal settings as weather location
6165 *
62- * @return DataResponse with success state and address information
66+ * @return DataResponse<array{success: bool, lat: ?float, lon: ?float, address: ?string}, Http::STATUS_OK>
6367 */
6468 public function usePersonalAddress (): DataResponse {
6569 return new DataResponse ($ this ->service ->usePersonalAddress ());
@@ -73,7 +77,7 @@ public function usePersonalAddress(): DataResponse {
7377 * - use the user defined address
7478 *
7579 * @param int $mode New mode
76- * @return DataResponse success state
80+ * @return DataResponse<array{ success: bool}, Http::STATUS_OK>
7781 */
7882 public function setMode (int $ mode ): DataResponse {
7983 return new DataResponse ($ this ->service ->setMode ($ mode ));
@@ -88,7 +92,7 @@ public function setMode(int $mode): DataResponse {
8892 * @param string|null $address Any approximative or exact address
8993 * @param float|null $lat Latitude in decimal degree format
9094 * @param float|null $lon Longitude in decimal degree format
91- * @return DataResponse with success state and address information
95+ * @return DataResponse<array{success: bool, lat: ?float, lon: ?float, address: ?string}, Http::STATUS_OK>
9296 */
9397 public function setLocation (?string $ address , ?float $ lat , ?float $ lon ): DataResponse {
9498 $ currentWeather = $ this ->service ->setLocation ($ address , $ lat , $ lon );
@@ -100,7 +104,7 @@ public function setLocation(?string $address, ?float $lat, ?float $lon): DataRes
100104 *
101105 * Get stored user location
102106 *
103- * @return DataResponse which contains coordinates, formatted address and current weather status mode
107+ * @return DataResponse<array{lat: float, lon: float, address: string, mode: int}, Http::STATUS_OK>
104108 */
105109 public function getLocation (): DataResponse {
106110 $ location = $ this ->service ->getLocation ();
@@ -112,7 +116,10 @@ public function getLocation(): DataResponse {
112116 *
113117 * Get forecast for current location
114118 *
115- * @return DataResponse which contains success state and filtered forecast data
119+ * @return DataResponse<WeatherStatusForecast[], Http::STATUS_OK>|DataResponse<array{success: bool}, Http::STATUS_NOT_FOUND>
120+ *
121+ * 200: Forecast returned
122+ * 404: Forecast not found
116123 */
117124 public function getForecast (): DataResponse {
118125 $ forecast = $ this ->service ->getForecast ();
@@ -128,7 +135,7 @@ public function getForecast(): DataResponse {
128135 *
129136 * Get favorites list
130137 *
131- * @return DataResponse which contains the favorite list
138+ * @return DataResponse<string[], Http::STATUS_OK>
132139 */
133140 public function getFavorites (): DataResponse {
134141 return new DataResponse ($ this ->service ->getFavorites ());
@@ -139,8 +146,8 @@ public function getFavorites(): DataResponse {
139146 *
140147 * Set favorites list
141148 *
142- * @param array $favorites
143- * @return DataResponse success state
149+ * @param string[] $favorites Favorite addresses
150+ * @return DataResponse<array{ success: bool}, Http::STATUS_OK>
144151 */
145152 public function setFavorites (array $ favorites ): DataResponse {
146153 return new DataResponse ($ this ->service ->setFavorites ($ favorites ));
0 commit comments