Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/backend-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
steps:
- uses: actions/checkout@v7

- uses: ibexa/gh-workflows/actions/setup-composer-root-version@main

- uses: ibexa/gh-workflows/actions/composer-install@main
with:
php-version: ${{ matrix.php }}
Expand All @@ -44,6 +46,7 @@ jobs:
- '8.4'
steps:
- uses: actions/checkout@v7
- uses: ibexa/gh-workflows/actions/setup-composer-root-version@main
- name: Install Composer dependencies
uses: ibexa/gh-workflows/actions/composer-install@main
with:
Expand All @@ -69,6 +72,8 @@ jobs:
steps:
- uses: actions/checkout@v7

- uses: ibexa/gh-workflows/actions/setup-composer-root-version@main

- uses: ibexa/gh-workflows/actions/composer-install@main
with:
php-version: ${{ matrix.php }}
Expand Down Expand Up @@ -121,6 +126,8 @@ jobs:
steps:
- uses: actions/checkout@v7

- uses: ibexa/gh-workflows/actions/setup-composer-root-version@main

- uses: ibexa/gh-workflows/actions/composer-install@main
with:
php-version: ${{ matrix.php }}
Expand Down Expand Up @@ -173,6 +180,8 @@ jobs:
steps:
- uses: actions/checkout@v7

- uses: ibexa/gh-workflows/actions/setup-composer-root-version@main

- uses: ibexa/gh-workflows/actions/composer-install@main
with:
php-version: ${{ matrix.php }}
Expand Down Expand Up @@ -229,6 +238,8 @@ jobs:
php-version: ${{ matrix.php }}
coverage: none

- uses: ibexa/gh-workflows/actions/setup-composer-root-version@main

- name: Add solr dependency
run: |
VERSION=$(jq -r '.extra | ."branch-alias" | ."dev-main"' < composer.json)
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"deptrac/deptrac": "^4.7",
"friends-of-behat/mink-extension": "^2.7.5 || ^3.0",
"ibexa/code-style": "~2.1.0",
"ibexa/phpstan": "~6.0.x-dev",
"ibexa/rector": "~6.0.x-dev",
"ibexa/test-core": "~6.0.x-dev",
"jenner/simple_fork": "^1.2",
Expand Down
18 changes: 0 additions & 18 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15018,12 +15018,6 @@ parameters:
count: 1
path: src/lib/Persistence/TransformationProcessor/PcreCompiler.php

-
message: '#^Parameter \#1 \$charCode of method Ibexa\\Core\\Persistence\\Utf8Converter\:\:toUTF8Character\(\) expects int, float\|int given\.$#'
identifier: argument.type
count: 2
path: src/lib/Persistence/TransformationProcessor/PcreCompiler.php

-
message: '#^Parameter \#1 \$codepoint of function chr expects int, float\|int given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -25776,12 +25770,6 @@ parameters:
count: 1
path: tests/integration/Core/Repository/FieldType/UserIntegrationTest.php

-
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\FieldType'' and Ibexa\\Contracts\\Core\\Repository\\FieldType will always evaluate to true\.$#'
identifier: method.alreadyNarrowedType
count: 1
path: tests/integration/Core/Repository/FieldTypeServiceTest.php

-
message: '#^Cannot access property \$pathString on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#'
identifier: property.nonObject
Expand Down Expand Up @@ -31530,12 +31518,6 @@ parameters:
count: 1
path: tests/lib/MVC/Symfony/Templating/RenderLocationStrategyTest.php

-
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Symfony\\\\Component\\\\HttpKernel\\\\Controller\\\\ControllerReference'' and Symfony\\Component\\HttpKernel\\Controller\\ControllerReference will always evaluate to true\.$#'
identifier: method.alreadyNarrowedType
count: 1
path: tests/lib/MVC/Symfony/Templating/RenderLocationStrategyTest.php

-
message: '#^Argument of an invalid type string supplied for foreach, only iterables are supported\.$#'
identifier: foreach.nonIterable
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/ibexa/phpstan/extension.neon
- phpstan-baseline.neon.php
- phpstan-baseline.neon
- phpstan-baseline.pagerfanta.neon
Expand Down
15 changes: 8 additions & 7 deletions src/bundle/Core/Command/RegenerateUrlAliasesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Exception;
use Ibexa\Contracts\Core\Repository\Repository;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Contracts\Core\Repository\Values\Content\Language;
use Ibexa\Contracts\Core\Repository\Values\Content\Location;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -186,9 +187,9 @@ protected function getProgressBar($maxSteps, OutputInterface $output)
private function processLocations(array $locations, ProgressBar $progressBar): void
{
$contentList = $this->repository->sudo(
static function (Repository $repository) use ($locations) {
static function (Repository $repository) use ($locations): iterable {
$contentInfoList = array_map(
static function (Location $location) {
static function (Location $location): ContentInfo {
return $location->contentInfo;
},
$locations
Expand All @@ -211,7 +212,7 @@ static function (Location $location) {
}

$this->repository->sudo(
static function (Repository $repository) use ($location) {
static function (Repository $repository) use ($location): void {
$repository->getURLAliasService()->refreshSystemUrlAliasesForLocation(
$location
);
Expand Down Expand Up @@ -247,7 +248,7 @@ static function (Repository $repository) use ($location) {
private function loadAllLocations(int $offset, int $iterationCount): array
{
return $this->repository->sudo(
static function (Repository $repository) use ($offset, $iterationCount) {
static function (Repository $repository) use ($offset, $iterationCount): array {
return $repository->getLocationService()->loadAllLocations($offset, $iterationCount);
}
);
Expand All @@ -267,7 +268,7 @@ private function loadSpecificLocations(array $locationIds, int $offset, int $ite
$locationIds = array_slice($locationIds, $offset, $iterationCount);

return $this->repository->sudo(
static function (Repository $repository) use ($locationIds) {
static function (Repository $repository) use ($locationIds): iterable {
return $repository->getLocationService()->loadLocationList($locationIds);
}
);
Expand All @@ -283,15 +284,15 @@ static function (Repository $repository) use ($locationIds) {
private function getFilteredLocationList(array $locationIds): array
{
$locations = $this->repository->sudo(
static function (Repository $repository) use ($locationIds) {
static function (Repository $repository) use ($locationIds): iterable {
$locationService = $repository->getLocationService();

return $locationService->loadLocationList($locationIds);
}
);

return array_map(
static function (Location $location) {
static function (Location $location): int {
return $location->id;
},
$locations
Expand Down
8 changes: 4 additions & 4 deletions src/bundle/Core/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function addRepositoriesSection(ArrayNodeDefinition $rootNode): void
->beforeNormalization()
->always(
// Handling deprecated structure by mapping it to new one
static function ($v) {
static function ($v): mixed {
if (isset($v['storage'])) {
return $v;
}
Expand All @@ -116,7 +116,7 @@ static function ($v) {
->beforeNormalization()
->always(
// Setting default values
static function ($v) {
static function ($v): mixed {
if ($v === null) {
$v = [];
}
Expand Down Expand Up @@ -202,7 +202,7 @@ public function addSiteAccessSection(ArrayNodeDefinition $rootNode): void
->useAttributeAsKey('key')
->beforeNormalization()
->always(
static function ($v) {
static function ($v): mixed {
// Value passed to the matcher should always be an array.
// If value is not an array, we transform it to a hash, with 'value' as key.
if (!is_array($v)) {
Expand Down Expand Up @@ -230,7 +230,7 @@ static function ($v) {
->end()
->end()
->beforeNormalization()
->always()->then(function ($v) {
->always()->then(function ($v): mixed {
if (isset($this->siteAccessConfigurationFilters)) {
foreach ($this->siteAccessConfigurationFilters as $filter) {
$v = $filter->filter($v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static function ($v): bool {
}
)
->then(
static function ($v) {
static function ($v): mixed {
// If we have the "params" key, just use the value.
return $v['params'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ protected function configureOptions(OptionsResolver $resolver)

$resolver->setDefault(
self::OPT_CONTENT_ID,
static function (Options $options) {
static function (Options $options): int {
return $options[self::OPT_CONTENT]->id;
}
);

$resolver->setDefault(
self::OPT_DOWNLOAD_NAME,
function (Options $options) {
function (Options $options): mixed {
$field = $this->translationHelper->getTranslatedField(
$options[self::OPT_CONTENT],
$options[self::OPT_FIELD_IDENTIFIER],
Expand Down
8 changes: 4 additions & 4 deletions src/bundle/Core/Features/Context/ContentContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function createContentItem($contentTypeIdentifier, array $fields)
$draft = $this->createDraft($contentTypeIdentifier, $fields);

$this->currentContent = $this->repository->sudo(
function () use ($draft) {
function () use ($draft): Content {
return $this->repository->getContentService()->publishVersion($draft->versionInfo);
}
);
Expand All @@ -79,7 +79,7 @@ function () use ($draft) {
public function createDraftForContent(Content $content)
{
$this->currentDraft = $this->repository->sudo(
function () use ($content) {
function () use ($content): Content {
return $this->repository->getContentService()->createContentDraft($content->contentInfo);
}
);
Expand All @@ -105,7 +105,7 @@ public function updateDraft($fields)
$updateStruct->setField($fieldDefIdentifier, $fieldValueUpdate);
}

$updatedDraft = $this->repository->sudo(function () use ($updateStruct) {
$updatedDraft = $this->repository->sudo(function () use ($updateStruct): Content {
return $this->repository->getContentService()->updateContent(
$this->currentDraft->versionInfo,
$updateStruct
Expand Down Expand Up @@ -140,7 +140,7 @@ public function createDraft($contentTypeIdentifier, array $fields)
$locationCreateStruct = $this->repository->getLocationService()->newLocationCreateStruct(2);

$this->currentDraft = $this->repository->sudo(
function () use ($createStruct, $locationCreateStruct) {
function () use ($createStruct, $locationCreateStruct): Content {
return $this->repository->getContentService()->createContent(
$createStruct,
[$locationCreateStruct]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private function executeCommand(OutputInterface $output, $cmd, $timeout = 300)
$timeout
);

$process->run(static function ($type, $buffer) use ($output) { $output->write($buffer, false); });
$process->run(static function ($type, $buffer) use ($output): void { $output->write($buffer, false); });
$exitCode = $process->getExitCode() ?? 0;
if ($exitCode !== self::SUCCESS) {
throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd)));
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/Limitation/Target/Builder/VersionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function changeStatusTo(int $status): self
public function updateFieldsTo(?string $initialLanguageCode, array $fields): self
{
$languageCodes = array_map(
static function (Field $field) {
static function (Field $field): mixed {
return $field->languageCode;
},
$fields
Expand Down
4 changes: 2 additions & 2 deletions src/lib/FieldType/Author/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function fromHash($hash)
{
return new Value(
array_map(
static function ($author) {
static function ($author): Author {
return new Author($author);
},
$hash
Expand All @@ -156,7 +156,7 @@ static function ($author) {
public function toHash(SPIValue $value): array
{
return array_map(
static function ($author) {
static function ($author): array {
return (array)$author;
},
$value->authors->getArrayCopy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public function getReferencedFiles(array $fieldIds, $versionNo)
$statement = $selectQuery->executeQuery();

return array_map(
function ($row) {
function ($row): string {
return $this->prependMimeToPath($row['filename'], $row['mime_type']);
},
$statement->fetchAllAssociative()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function getPropertyMap(): array
],
'password_updated_at' => [
'name' => 'passwordUpdatedAt',
'cast' => static function ($timestamp) {
'cast' => static function ($timestamp): ?int {
return $timestamp ? (int)$timestamp : null;
},
],
Expand Down
13 changes: 7 additions & 6 deletions src/lib/FieldType/Validator/FileExtensionBlackListValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ class FileExtensionBlackListValidator extends Validator
],
];

/**
* @param \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface $configResolver
*/
private ConfigResolverInterface $configResolver;

public function __construct(ConfigResolverInterface $configResolver)
{
$this->constraints['extensionsBlackList'] = $configResolver->getParameter(
'io.file_storage.file_type_blacklist'
);
$this->configResolver = $configResolver;
}

/**
Expand All @@ -58,6 +55,10 @@ public function validate(BaseValue $value, ?FieldDefinition $fieldDefinition = n

public function validateFileExtension(string $fileName): void
{
$this->constraints['extensionsBlackList'] = $this->configResolver->getParameter(
'io.file_storage.file_type_blacklist'
);

if (
pathinfo($fileName, PATHINFO_BASENAME) !== $fileName
|| in_array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Exception;
use Ibexa\Contracts\Core\Repository\Repository;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Contracts\Core\Repository\Values\Content\Location;
use Ibexa\Core\Base\Exceptions\NotFoundException;
use Ibexa\Core\Helper\ContentInfoLocationLoader;

Expand All @@ -34,7 +35,7 @@ public function loadLocation(ContentInfo $contentInfo)

try {
return $this->repository->sudo(
static function (Repository $repository) use ($contentInfo) {
static function (Repository $repository) use ($contentInfo): Location {
return $repository->getLocationService()->loadLocation($contentInfo->mainLocationId);
}
);
Expand Down
Loading
Loading