Skip to content

Commit 2b95dc1

Browse files
committed
feature #6992 Add phpdoc for some arrays (VincentLanglet)
This PR was merged into the 4.x branch. Discussion ---------- Add phpdoc for some arrays Time to add phpdoc to arrays `@javiereguiluz` There is ~400 errors, this PR solve 250 errors I will try the 150 others in another PR. Commits ------- 1a8a64f Add phpdoc for some arrays
2 parents 7c2e00a + 1a8a64f commit 2b95dc1

25 files changed

+219
-11
lines changed

src/Attribute/AdminDashboard.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ public function __construct(
1919
public /* ?string */ $routeName = null,
2020
/**
2121
* @var array{
22-
* requirements?: array,
23-
* options?: array,
24-
* defaults?: array,
22+
* requirements?: array<string, string>,
23+
* options?: array<string, mixed>,
24+
* defaults?: array<string, mixed>,
2525
* host?: string,
26-
* methods?: array|string,
27-
* schemes?: array|string,
26+
* methods?: array<string>|string,
27+
* schemes?: array<string>|string,
2828
* condition?: string,
2929
* locale?: string,
3030
* format?: string,

src/Command/MakeCrudControllerCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9595
return Command::SUCCESS;
9696
}
9797

98+
/**
99+
* @return array<class-string>
100+
*/
98101
private function getAllDoctrineEntitiesFqcn(): array
99102
{
100103
$entitiesFqcn = [];

src/Config/Action.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ public function displayAsForm(): self
165165
return $this;
166166
}
167167

168+
/**
169+
* @param array<string, string> $attributes
170+
*/
168171
public function setHtmlAttributes(array $attributes): self
169172
{
170173
$this->dto->setHtmlAttributes($attributes);
@@ -187,7 +190,7 @@ public function linkToCrudAction(string $crudActionName): self
187190
}
188191

189192
/**
190-
* @param array|callable $routeParameters The callable has the signature: function ($entity): array
193+
* @param array<string, mixed>|callable $routeParameters The callable has the signature: function ($entity): array
191194
*
192195
* Route parameters can be defined as a callable with the signature: function ($entityInstance): array
193196
* Example: ->linkToRoute('invoice_send', fn (Invoice $entity) => ['uuid' => $entity->getId()]);
@@ -222,6 +225,9 @@ public function linkToUrl($url): self
222225
return $this;
223226
}
224227

228+
/**
229+
* @param array<string, mixed> $parameters
230+
*/
225231
public function setTranslationParameters(array $parameters): self
226232
{
227233
$this->dto->setTranslationParameters($parameters);

src/Config/Crud.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public function setDecimalSeparator(string $separator): self
256256
}
257257

258258
/**
259-
* @param array $sortFieldsAndOrder ['fieldName' => 'ASC|DESC', ...]
259+
* @param array<string, 'ASC'|'DESC'> $sortFieldsAndOrder ['fieldName' => 'ASC|DESC', ...]
260260
*/
261261
public function setDefaultSort(array $sortFieldsAndOrder): self
262262
{
@@ -276,6 +276,9 @@ public function setDefaultSort(array $sortFieldsAndOrder): self
276276
return $this;
277277
}
278278

279+
/**
280+
* @param array<string>|null $fieldNames
281+
*/
279282
public function setSearchFields(?array $fieldNames): self
280283
{
281284
$this->dto->setSearchFields($fieldNames);
@@ -360,6 +363,8 @@ public function overrideTemplate(string $templateName, string $templatePath): se
360363

361364
/**
362365
* Format: ['templateName' => 'templatePath', ...].
366+
*
367+
* @param array<string, string> $templateNamesAndPaths
363368
*/
364369
public function overrideTemplates(array $templateNamesAndPaths): self
365370
{
@@ -377,6 +382,9 @@ public function addFormTheme(string $themePath): self
377382
return $this;
378383
}
379384

385+
/**
386+
* @param array<string, string> $themePaths
387+
*/
380388
public function setFormThemes(array $themePaths): self
381389
{
382390
foreach ($themePaths as $path) {
@@ -390,6 +398,12 @@ public function setFormThemes(array $themePaths): self
390398
return $this;
391399
}
392400

401+
/**
402+
* @param array<string, mixed> $newFormOptions
403+
* @param array<string, mixed>|null $editFormOptions
404+
*
405+
* @return $this
406+
*/
393407
public function setFormOptions(array $newFormOptions, ?array $editFormOptions = null): self
394408
{
395409
$this->dto->setNewFormOptions(KeyValueStore::new($newFormOptions));
@@ -433,6 +447,9 @@ public function getAsDto(): CrudDto
433447
return $this->dto;
434448
}
435449

450+
/**
451+
* @return array<self::PAGE_*>
452+
*/
436453
private function getValidPageNames(): array
437454
{
438455
return [self::PAGE_DETAIL, self::PAGE_EDIT, self::PAGE_INDEX, self::PAGE_NEW];

src/Config/KeyValueStore.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,20 @@
1010
*/
1111
final class KeyValueStore
1212
{
13+
/** @var array<string, mixed> */
1314
private array $map;
1415

16+
/**
17+
* @param array<string, mixed> $keyValueMap
18+
*/
1519
private function __construct(array $keyValueMap)
1620
{
1721
$this->map = $keyValueMap;
1822
}
1923

24+
/**
25+
* @param array<string, mixed> $keyValuePairs
26+
*/
2027
public static function new(array $keyValuePairs = []): self
2128
{
2229
return new self($keyValuePairs);
@@ -92,6 +99,9 @@ public function setIfNotSet(string $key, mixed $value): void
9299
}
93100
}
94101

102+
/**
103+
* @param array<string, mixed> $keyValuePairs
104+
*/
95105
public function setAll(array $keyValuePairs): void
96106
{
97107
foreach ($keyValuePairs as $key => $value) {
@@ -122,6 +132,9 @@ public function delete(string $key): void
122132
unset($items[$lastSegment]);
123133
}
124134

135+
/**
136+
* @return array<string, mixed>
137+
*/
125138
public function all(): array
126139
{
127140
return $this->map;

src/Config/Menu/CrudMenuItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function setEntityId(/* AbstractUid|int|string */ $entityId): self
8686
}
8787

8888
/**
89-
* @param array $sortFieldsAndOrder ['fieldName' => 'ASC|DESC', ...]
89+
* @param array<string, 'ASC'|'DESC'> $sortFieldsAndOrder ['fieldName' => 'ASC|DESC', ...]
9090
*/
9191
public function setDefaultSort(array $sortFieldsAndOrder): self
9292
{

src/Config/Menu/MenuItemTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public function setPermission(string|Expression $permission): self
3333
return $this;
3434
}
3535

36+
/**
37+
* @param array<string, mixed> $parameters
38+
*/
3639
public function setTranslationParameters(array $parameters): self
3740
{
3841
$this->dto->setTranslationParameters($parameters);

src/Contracts/Field/FieldTraitAwareInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public function setEmptyData(mixed $emptyData = null): self;
2929

3030
public function setFormType(string $formTypeFqcn): self;
3131

32+
/**
33+
* @param array<string, mixed> $options
34+
*/
3235
public function setFormTypeOptions(array $options): self;
3336

3437
/**
@@ -56,6 +59,9 @@ public function addCssClass(string $cssClass): self;
5659

5760
public function setCssClass(string $cssClass): self;
5861

62+
/**
63+
* @param array<string, mixed> $parameters
64+
*/
5965
public function setTranslationParameters(array $parameters): self;
6066

6167
public function setTemplateName(string $name): self;
@@ -76,6 +82,9 @@ public function addHtmlContentsToBody(string ...$contents): self;
7682

7783
public function setCustomOption(string $optionName, mixed $optionValue): self;
7884

85+
/**
86+
* @param array<string, mixed> $options
87+
*/
7988
public function setCustomOptions(array $options): self;
8089

8190
public function hideOnDetail(): self;

src/Dto/ActionDto.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ final class ActionDto
1818
private string $cssClass = '';
1919
private string $addedCssClass = '';
2020
private ?string $htmlElement = null;
21+
/** @var array<string, string> */
2122
private array $htmlAttributes = [];
2223
private ?string $linkUrl = null;
2324
private ?string $templatePath = null;
2425
private ?string $crudActionName = null;
2526
private ?string $routeName = null;
26-
/** @var array|callable */
27+
/** @var array<string, mixed>|callable */
2728
private $routeParameters = [];
2829
/** @var callable|string|null */
2930
private $url;
31+
/** @var array<string, mixed> */
3032
private array $translationParameters = [];
3133
/** @var callable|null */
3234
private $displayCallable;
@@ -124,16 +126,25 @@ public function setHtmlElement(string $htmlElement): void
124126
$this->htmlElement = $htmlElement;
125127
}
126128

129+
/**
130+
* @return array<string, string>
131+
*/
127132
public function getHtmlAttributes(): array
128133
{
129134
return $this->htmlAttributes;
130135
}
131136

137+
/**
138+
* @param array<string, string> $htmlAttributes
139+
*/
132140
public function addHtmlAttributes(array $htmlAttributes): void
133141
{
134142
$this->htmlAttributes = array_merge($this->htmlAttributes, $htmlAttributes);
135143
}
136144

145+
/**
146+
* @param array<string, string> $htmlAttributes
147+
*/
137148
public function setHtmlAttributes(array $htmlAttributes): void
138149
{
139150
$this->htmlAttributes = $htmlAttributes;
@@ -185,15 +196,15 @@ public function setRouteName(string $routeName): void
185196
}
186197

187198
/**
188-
* @return array|callable
199+
* @return array<string, mixed>|callable
189200
*/
190201
public function getRouteParameters()/* : array|callable */
191202
{
192203
return $this->routeParameters;
193204
}
194205

195206
/**
196-
* @param array|callable $routeParameters
207+
* @param array<string, mixed>|callable $routeParameters
197208
*/
198209
public function setRouteParameters($routeParameters): void
199210
{
@@ -240,11 +251,17 @@ public function setUrl($url): void
240251
$this->url = $url;
241252
}
242253

254+
/**
255+
* @return array<string, mixed>
256+
*/
243257
public function getTranslationParameters(): array
244258
{
245259
return $this->translationParameters;
246260
}
247261

262+
/**
263+
* @param array<string, mixed> $translationParameters
264+
*/
248265
public function setTranslationParameters(array $translationParameters): void
249266
{
250267
$this->translationParameters = $translationParameters;

src/Dto/CrudDto.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,24 @@ final class CrudDto
4747
];
4848
private ?string $datePattern = 'medium';
4949
private ?string $timePattern = 'medium';
50+
/** @var array{string, string} */
5051
private array $dateTimePattern = ['medium', 'medium'];
5152
private string $dateIntervalFormat = '%%y Year(s) %%m Month(s) %%d Day(s)';
5253
private ?string $timezone = null;
5354
private ?string $numberFormat = null;
5455
private ?string $thousandsSeparator = null;
5556
private ?string $decimalSeparator = null;
57+
/** @var array<string, 'ASC'|'DESC'> */
5658
private array $defaultSort = [];
59+
/** @var array<string>|null */
5760
private ?array $searchFields = [];
5861
private string $searchMode = SearchMode::ALL_TERMS;
5962
private bool $autofocusSearch = false;
6063
private bool $showEntityActionsAsDropdown = true;
6164
private ?PaginatorDto $paginatorDto = null;
65+
/** @var array<string, string> */
6266
private array $overriddenTemplates;
67+
/** @var array<string> */
6368
private array $formThemes = ['@EasyAdmin/crud/form_theme.html.twig'];
6469
private KeyValueStore $newFormOptions;
6570
private KeyValueStore $editFormOptions;
@@ -283,6 +288,9 @@ public function setTimePattern(?string $format): void
283288
$this->timePattern = $format;
284289
}
285290

291+
/**
292+
* @return array{string, string}
293+
*/
286294
public function getDateTimePattern(): array
287295
{
288296
return $this->dateTimePattern;
@@ -343,11 +351,17 @@ public function setDecimalSeparator(string $separator): void
343351
$this->decimalSeparator = $separator;
344352
}
345353

354+
/**
355+
* @return array<string, 'ASC'|'DESC'>
356+
*/
346357
public function getDefaultSort(): array
347358
{
348359
return $this->defaultSort;
349360
}
350361

362+
/**
363+
* @param array<string, 'ASC'|'DESC'> $defaultSort
364+
*/
351365
public function setDefaultSort(array $defaultSort): void
352366
{
353367
$this->defaultSort = $defaultSort;
@@ -363,11 +377,17 @@ public function setSearchMode(string $searchMode): void
363377
$this->searchMode = $searchMode;
364378
}
365379

380+
/**
381+
* @return array<string>|null
382+
*/
366383
public function getSearchFields(): ?array
367384
{
368385
return $this->searchFields;
369386
}
370387

388+
/**
389+
* @param array<string>|null $searchFields
390+
*/
371391
public function setSearchFields(?array $searchFields): void
372392
{
373393
$this->searchFields = $searchFields;
@@ -408,6 +428,9 @@ public function setPaginator(PaginatorDto $paginatorDto): void
408428
$this->paginatorDto = $paginatorDto;
409429
}
410430

431+
/**
432+
* @return array<string, string>
433+
*/
411434
public function getOverriddenTemplates(): array
412435
{
413436
return $this->overriddenTemplates;
@@ -418,6 +441,9 @@ public function overrideTemplate(string $templateName, string $templatePath): vo
418441
$this->overriddenTemplates[$templateName] = $templatePath;
419442
}
420443

444+
/**
445+
* @return array<string>
446+
*/
421447
public function getFormThemes(): array
422448
{
423449
return $this->formThemes;
@@ -429,6 +455,9 @@ public function addFormTheme(string $formThemePath): void
429455
$this->formThemes = array_merge($this->formThemes, [$formThemePath]);
430456
}
431457

458+
/**
459+
* @param array<string> $formThemes
460+
*/
432461
public function setFormThemes(array $formThemes): void
433462
{
434463
$this->formThemes = $formThemes;

0 commit comments

Comments
 (0)