18
18
class Repository
19
19
{
20
20
/**
21
- * services properties.
21
+ * Repository properties.
22
+ *
23
+ * @var string[]
22
24
*/
23
25
private static $ properties = array (
24
26
'label ' ,
@@ -28,7 +30,11 @@ class Repository
28
30
);
29
31
30
32
/**
31
- * services properties options.
33
+ * Repository properties options.
34
+ *
35
+ * @var array<string, array<string, bool|string>>
36
+ *
37
+ * @phpstan-var array<string, array{fieldType: string, required: bool}>
32
38
*/
33
39
private static $ propertiesOptions = array (
34
40
'label ' => array (
@@ -51,26 +57,38 @@ class Repository
51
57
52
58
/**
53
59
* Lizmap repository key.
60
+ *
61
+ * @var string
54
62
*/
55
63
private $ key = '' ;
56
64
57
65
/**
58
66
* Lizmap repository configuration data.
67
+ *
68
+ * @var array
59
69
*/
60
70
private $ data = array ();
61
71
62
72
/**
63
- * @var Project[] list of projects. keys are projects names
73
+ * @var array<string, Project> list of projects instances . keys are projects names
64
74
*/
65
75
protected $ projectInstances = array ();
66
76
67
77
/**
68
78
* The configuration files folder path.
79
+ *
80
+ * @var string
69
81
*/
70
82
private $ varPath = '' ;
71
83
84
+ /**
85
+ * @var \lizmapServices
86
+ */
72
87
protected $ services ;
73
88
89
+ /**
90
+ * @var AppContextInterface
91
+ */
74
92
protected $ appContext ;
75
93
76
94
/**
@@ -103,7 +121,7 @@ public function __construct($key, $data, $varPath, $services, $appContext)
103
121
/**
104
122
* @return string the technical name of the repository
105
123
*/
106
- public function getKey ()
124
+ public function getKey (): string
107
125
{
108
126
return $ this ->key ;
109
127
}
@@ -113,7 +131,7 @@ public function getKey()
113
131
*
114
132
* @return string the repository label
115
133
*/
116
- public function getLabel ()
134
+ public function getLabel (): string
117
135
{
118
136
return $ this ->getData ('label ' );
119
137
}
@@ -123,7 +141,7 @@ public function getLabel()
123
141
*
124
142
* @return bool true if it is allowed
125
143
*/
126
- public function allowUserDefinedThemes ()
144
+ public function allowUserDefinedThemes (): bool
127
145
{
128
146
$ value = $ this ->getData ('allowUserDefinedThemes ' );
129
147
if (empty ($ value )) {
@@ -147,7 +165,7 @@ public function allowUserDefinedThemes()
147
165
*
148
166
* @return string the value of the ACAO header. If empty, the header should not be set.
149
167
*/
150
- public function getACAOHeaderValue ($ referer )
168
+ public function getACAOHeaderValue ($ referer ): string
151
169
{
152
170
$ origins = $ this ->getData ('accessControlAllowOrigin ' );
153
171
if (!$ origins || $ referer == '' ) {
@@ -173,6 +191,9 @@ public function getACAOHeaderValue($referer)
173
191
return '' ;
174
192
}
175
193
194
+ /**
195
+ * @var null|string the cleaned path of the repository, with a trailing slash
196
+ */
176
197
protected $ cleanedPath ;
177
198
178
199
/**
@@ -210,27 +231,48 @@ public function getPath()
210
231
return $ this ->cleanedPath ;
211
232
}
212
233
213
- public function getOriginalPath ()
234
+ /**
235
+ * Get the original path.
236
+ */
237
+ public function getOriginalPath (): string
214
238
{
215
239
return $ this ->data ['path ' ];
216
240
}
217
241
242
+ /**
243
+ * Check if the repository has a valid path.
244
+ */
218
245
public function hasValidPath (): bool
219
246
{
220
247
return $ this ->getPath () !== false ;
221
248
}
222
249
223
- public static function getProperties ()
250
+ /**
251
+ * Get the list of properties of a repository.
252
+ *
253
+ * @return string[]
254
+ */
255
+ public static function getProperties (): array
224
256
{
225
257
return self ::$ properties ;
226
258
}
227
259
228
- public static function getRepoProperties ()
260
+ /**
261
+ * Get theR repository properties options.
262
+ *
263
+ * @return array<string, array{fieldType: string, required: bool}>
264
+ */
265
+ public static function getRepoProperties (): array
229
266
{
230
267
return self ::$ propertiesOptions ;
231
268
}
232
269
233
- public static function getPropertiesOptions ()
270
+ /**
271
+ * Get theR repository properties options.
272
+ *
273
+ * @return array<string, array{fieldType: string, required: bool}>
274
+ */
275
+ public static function getPropertiesOptions (): array
234
276
{
235
277
return self ::$ propertiesOptions ;
236
278
}
@@ -259,7 +301,7 @@ public function getData($key)
259
301
*
260
302
* @return bool true if there is at least one valid data in $data
261
303
*/
262
- public function update ($ data , $ ini )
304
+ public function update ($ data , $ ini ): bool
263
305
{
264
306
// Set section
265
307
$ section = 'repository: ' .$ this ->key ;
@@ -291,6 +333,8 @@ public function update($data, $ini)
291
333
* @param bool $keepReference if we need to keep reference in the repository property projectInstances
292
334
*
293
335
* @return null|Project null if it does not exist
336
+ *
337
+ * @throws UnknownLizmapProjectException if the project does not exist
294
338
*/
295
339
public function getProject ($ key , $ keepReference = true )
296
340
{
@@ -320,7 +364,7 @@ public function getProject($key, $keepReference = true)
320
364
*
321
365
* @return Project[]
322
366
*/
323
- public function getProjects ()
367
+ public function getProjects (): array
324
368
{
325
369
$ projects = array ();
326
370
$ dir = $ this ->getPath ();
@@ -370,7 +414,7 @@ public function getProjects()
370
414
*
371
415
* @return ProjectMetadata[]
372
416
*/
373
- public function getProjectsMetadata ($ checkAcl = true )
417
+ public function getProjectsMetadata ($ checkAcl = true ): array
374
418
{
375
419
$ data = array ();
376
420
$ dir = $ this ->getPath ();
@@ -422,7 +466,7 @@ public function getProjectsMetadata($checkAcl = true)
422
466
*
423
467
* @return ProjectMainData[]
424
468
*/
425
- public function getProjectsMainData ()
469
+ public function getProjectsMainData (): array
426
470
{
427
471
$ data = array ();
428
472
$ dir = $ this ->getPath ();
0 commit comments