25
25
*/
26
26
namespace OCA \WeatherStatus \Controller ;
27
27
28
+ use OCA \WeatherStatus \ResponseDefinitions ;
28
29
use OCA \WeatherStatus \Service \WeatherStatusService ;
29
30
use OCP \AppFramework \Http ;
30
31
use OCP \AppFramework \Http \DataResponse ;
31
32
use OCP \AppFramework \OCSController ;
32
33
use OCP \ILogger ;
33
34
use OCP \IRequest ;
34
35
36
+ /**
37
+ * @psalm-import-type WeatherStatusForecast from ResponseDefinitions
38
+ */
35
39
class WeatherStatusController extends OCSController {
36
40
37
41
/** @var string */
@@ -59,7 +63,7 @@ public function __construct(string $appName,
59
63
*
60
64
* Try to use the address set in user personal settings as weather location
61
65
*
62
- * @return DataResponse with success state and address information
66
+ * @return DataResponse<array{success: bool, lat: ?float, lon: ?float, address: ?string}, Http::STATUS_OK>
63
67
*/
64
68
public function usePersonalAddress (): DataResponse {
65
69
return new DataResponse ($ this ->service ->usePersonalAddress ());
@@ -73,7 +77,7 @@ public function usePersonalAddress(): DataResponse {
73
77
* - use the user defined address
74
78
*
75
79
* @param int $mode New mode
76
- * @return DataResponse success state
80
+ * @return DataResponse<array{ success: bool}, Http::STATUS_OK>
77
81
*/
78
82
public function setMode (int $ mode ): DataResponse {
79
83
return new DataResponse ($ this ->service ->setMode ($ mode ));
@@ -88,7 +92,7 @@ public function setMode(int $mode): DataResponse {
88
92
* @param string|null $address Any approximative or exact address
89
93
* @param float|null $lat Latitude in decimal degree format
90
94
* @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>
92
96
*/
93
97
public function setLocation (?string $ address , ?float $ lat , ?float $ lon ): DataResponse {
94
98
$ currentWeather = $ this ->service ->setLocation ($ address , $ lat , $ lon );
@@ -100,7 +104,7 @@ public function setLocation(?string $address, ?float $lat, ?float $lon): DataRes
100
104
*
101
105
* Get stored user location
102
106
*
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>
104
108
*/
105
109
public function getLocation (): DataResponse {
106
110
$ location = $ this ->service ->getLocation ();
@@ -112,7 +116,10 @@ public function getLocation(): DataResponse {
112
116
*
113
117
* Get forecast for current location
114
118
*
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
116
123
*/
117
124
public function getForecast (): DataResponse {
118
125
$ forecast = $ this ->service ->getForecast ();
@@ -128,7 +135,7 @@ public function getForecast(): DataResponse {
128
135
*
129
136
* Get favorites list
130
137
*
131
- * @return DataResponse which contains the favorite list
138
+ * @return DataResponse<string[], Http::STATUS_OK>
132
139
*/
133
140
public function getFavorites (): DataResponse {
134
141
return new DataResponse ($ this ->service ->getFavorites ());
@@ -139,8 +146,8 @@ public function getFavorites(): DataResponse {
139
146
*
140
147
* Set favorites list
141
148
*
142
- * @param array $favorites
143
- * @return DataResponse success state
149
+ * @param string[] $favorites Favorite addresses
150
+ * @return DataResponse<array{ success: bool}, Http::STATUS_OK>
144
151
*/
145
152
public function setFavorites (array $ favorites ): DataResponse {
146
153
return new DataResponse ($ this ->service ->setFavorites ($ favorites ));
0 commit comments