Skip to content

Commit 5df42c1

Browse files
committed
Fix PHPStan issues
1 parent c7d55e1 commit 5df42c1

17 files changed

Lines changed: 51 additions & 36 deletions

bundle/Command/BaseMultiprocessCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ protected function dispatch(int $processCount, int $limit): void
221221
{
222222
$generator = $this->internalGetItemGenerator($limit);
223223

224-
/** @var \Symfony\Component\Process\Process[]|null[] $processes */
225224
$processes = array_fill(0, $processCount, null);
226225
$processDepthMap = [];
227226
$itemList = null;

bundle/Command/DumpDatabaseCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5050
$fs->mkdir($targetDirectory);
5151
}
5252

53+
/** @var array{ user: string, host: string, dbname: string, password: string } $params */
5354
$params = $this->connection->getParams();
5455

5556
// https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_opt

bundle/Command/GenerateImageVariationsCommand.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function (Repository $repository) use ($query): int {
8989
$fields = $this->parseCommaDelimited($input->getOption('fields'));
9090

9191
do {
92-
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit[] $searchHits */
92+
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit<\Ibexa\Contracts\Core\Repository\Values\Content\Content>[] $searchHits */
9393
$searchHits = $this->repository->sudo(
9494
function (Repository $repository) use ($query): iterable {
9595
$languages = $this->configResolver->getParameter('languages');
@@ -98,7 +98,6 @@ function (Repository $repository) use ($query): iterable {
9898
},
9999
);
100100

101-
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Content[] $contentItems */
102101
$contentItems = array_map(
103102
static fn (SearchHit $searchHit): ValueObject => $searchHit->valueObject,
104103
$searchHits,
@@ -132,7 +131,7 @@ private function clearVariationCache(Content $content): void
132131
private function generateVariations(Content $content, array $variations, array $fields): void
133132
{
134133
foreach ($content->getFields() as $field) {
135-
if ($field->fieldTypeIdentifier !== 'ezimage') {
134+
if ($field->fieldTypeIdentifier !== 'ibexa_image') {
136135
continue;
137136
}
138137

@@ -201,6 +200,15 @@ private function parseCommaDelimited(?string $value): array
201200
return [];
202201
}
203202

204-
return array_values(array_unique(array_filter(array_map('trim', explode(',', $value)))));
203+
$values = array_map('mb_trim', explode(',', $value));
204+
205+
return array_values(
206+
array_unique(
207+
array_filter(
208+
$values,
209+
static fn (string $value): bool => $value !== '',
210+
)
211+
)
212+
);
205213
}
206214
}

bundle/Command/GenerateShowcaseCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ private function findParameterDefinition(
523523
}
524524

525525
foreach ($parameterDefinitionCollection->parameterDefinitions as $innerParameterDefinition) {
526-
if (!$innerParameterDefinition instanceof ParameterDefinitionCollectionInterface) {
526+
if (!$innerParameterDefinition->isCompound) {
527527
continue;
528528
}
529529

bundle/Command/MoveContentTypeCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
final class MoveContentTypeCommand extends Command
2424
{
25-
protected static $defaultDescription = 'Assigns content type(s) to a single content type group';
26-
2725
private SymfonyStyle $style;
2826

2927
public function __construct(
@@ -37,6 +35,7 @@ public function __construct(
3735
protected function configure(): void
3836
{
3937
$this
38+
->setDescription('Assigns content type(s) to a single content type group')
4039
->addArgument(
4140
'types',
4241
InputArgument::REQUIRED,
@@ -65,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6564
}
6665

6766
$types = $input->getArgument('types');
68-
$contentTypeIdentifiersOrIds = array_map('trim', explode(',', $types));
67+
$contentTypeIdentifiersOrIds = array_map('mb_trim', explode(',', $types));
6968
$contentTypeGroupIdentifierOrId = (string) $input->getArgument('group');
7069

7170
$newContentTypeGroup = $this->loadContentTypeGroup($contentTypeGroupIdentifierOrId);

bundle/Command/TagContentByTypesCommand.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ private function parseCommaDelimited(string $value): array
177177
return [];
178178
}
179179

180-
return array_values(array_unique(array_filter(array_map('trim', explode(',', $value)))));
180+
$values = array_map('mb_trim', explode(',', $value));
181+
182+
return array_values(
183+
array_unique(
184+
array_filter(
185+
$values,
186+
static fn (string $value): bool => $value !== '',
187+
)
188+
)
189+
);
181190
}
182191
}

bundle/Command/UpdateContentAlwaysAvailableCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
final class UpdateContentAlwaysAvailableCommand extends Command
1919
{
20-
protected static $defaultDescription = 'Update always-available state for the given Content item(s)';
21-
2220
private SymfonyStyle $style;
2321

2422
public function __construct(
@@ -31,6 +29,7 @@ public function __construct(
3129
protected function configure(): void
3230
{
3331
$this
32+
->setDescription('Update always-available state for the given Content item(s)')
3433
->addArgument(
3534
'content-ids',
3635
InputArgument::REQUIRED,
@@ -60,7 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6059
}
6160

6261
$types = $input->getArgument('content-ids');
63-
$contentIds = array_map('intval', array_map('trim', explode(',', $types)));
62+
$contentIds = array_map('intval', array_map('mb_trim', explode(',', $types)));
6463
$alwaysAvailableState = $this->resolveAlwaysAvailableState($input->getArgument('always-available'));
6564

6665
foreach ($contentIds as $contentId) {

bundle/ContentForms/FieldType/Mapper/BinaryFileFormMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct(
2323

2424
public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data): void
2525
{
26-
$fieldDefinition = $data->fieldDefinition;
26+
$fieldDefinition = $data->getFieldDefinition();
2727
$formConfig = $fieldForm->getConfig();
2828
$fieldType = $this->fieldTypeService->getFieldType($fieldDefinition->fieldTypeIdentifier);
2929
$value = $data->value ?? $fieldType->getEmptyValue();

bundle/Controller/Download.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function __invoke(Request $request, int|string $contentId, int|string $fi
8585

8686
if ($binaryFieldValue instanceof BinaryBaseValue) {
8787
$ioService = $this->ioFileService;
88-
$binaryFile = $this->ioFileService->loadBinaryFile($binaryFieldValue->id);
88+
$binaryFile = $this->ioFileService->loadBinaryFile((string) $binaryFieldValue->id);
8989
} elseif ($binaryFieldValue instanceof ImageValue) {
9090
$ioService = $this->ioImageService;
9191
$binaryFile = $this->ioImageService->loadBinaryFile($binaryFieldValue->id);

bundle/Core/EventListener/CreateUserListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public static function getSubscribedEvents(): array
2121

2222
public function onCreateUser(CreateUserEvent $event): void
2323
{
24-
if ($event->user->enabled) {
25-
$this->ngUserSettingRepository->activateUser($event->user->id);
24+
if ($event->getUser()->enabled) {
25+
$this->ngUserSettingRepository->activateUser($event->getUser()->id);
2626
}
2727
}
2828
}

0 commit comments

Comments
 (0)