Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-8470: Upgraded codebase to Symfony 6 #50

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
23 changes: 11 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@
},
"require": {
"php": " >=8.3",
"ibexa/core": "~5.0.x-dev",
"pagerfanta/pagerfanta": "^2.1",
"symfony/config": "^5.0",
"symfony/dependency-injection": "^5.0",
"symfony/event-dispatcher": "^5.0",
"symfony/form": "^5.0",
"symfony/http-foundation": "^5.0",
"symfony/http-kernel": "^5.0",
"symfony/serializer": "^5.4"
"ibexa/core": "dev-ibx-8470-symfony-6 as 5.0.x-dev",
"pagerfanta/pagerfanta": "^3.6.2",
"symfony/config": "^6.4",
"symfony/dependency-injection": "^6.4",
"symfony/event-dispatcher": "^6.4",
"symfony/form": "^6.4",
"symfony/http-foundation": "^6.4",
"symfony/http-kernel": "^6.4",
"symfony/serializer": "^6.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"ibexa/code-style": "^1.0",
"ibexa/doctrine-schema": "~5.0.x-dev",
"ibexa/code-style": "~2.0.0",
"ibexa/doctrine-schema": "dev-ibx-8470-symfony-6 as 5.0.x-dev",
"matthiasnoback/symfony-dependency-injection-test": "^4.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
Expand Down
50 changes: 0 additions & 50 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
parameters:
ignoreErrors:
-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\DependencyInjection\\\\Configuration\\\\Parser\\\\Search\\:\\:addSemanticConfig\\(\\) has no return type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/Configuration/Parser/Search.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\DependencyInjection\\\\Configuration\\\\Parser\\\\Search\\:\\:mapConfig\\(\\) has parameter \\$scopeSettings with no value type specified in iterable type array\\.$#"
count: 1
path: src/bundle/DependencyInjection/Configuration/Parser/Search.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\DependencyInjection\\\\IbexaSearchExtension\\:\\:load\\(\\) has no return type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/IbexaSearchExtension.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\Form\\\\ChoiceLoader\\\\ConfiguredLanguagesChoiceLoader\\:\\:getChoiceList\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/bundle/Form/ChoiceLoader/ConfiguredLanguagesChoiceLoader.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\Form\\\\ChoiceLoader\\\\ContentTypeChoiceLoader\\:\\:getChoiceList\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/bundle/Form/ChoiceLoader/ContentTypeChoiceLoader.php

-
message: "#^Parameter \\#1 \\$array of function usort expects TArray of array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\ContentType\\>, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\ContentType\\> given\\.$#"
count: 1
Expand Down Expand Up @@ -180,11 +160,6 @@ parameters:
count: 1
path: src/bundle/Form/DataTransformer/UsersTransformer.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\Form\\\\Type\\\\ContentTypeChoiceType\\:\\:configureOptions\\(\\) has no return type specified\\.$#"
count: 1
path: src/bundle/Form/Type/ContentTypeChoiceType.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\Form\\\\Type\\\\DateIntervalType\\:\\:buildForm\\(\\) has no return type specified\\.$#"
count: 1
Expand All @@ -200,41 +175,16 @@ parameters:
count: 1
path: src/bundle/Form/Type/SearchType.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\Form\\\\Type\\\\SearchType\\:\\:configureOptions\\(\\) has no return type specified\\.$#"
count: 1
path: src/bundle/Form/Type/SearchType.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\Form\\\\Type\\\\SearchUsersType\\:\\:buildForm\\(\\) has no return type specified\\.$#"
count: 1
path: src/bundle/Form/Type/SearchUsersType.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\Form\\\\Type\\\\SearchUsersType\\:\\:configureOptions\\(\\) has no return type specified\\.$#"
count: 1
path: src/bundle/Form/Type/SearchUsersType.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\Form\\\\Type\\\\SectionChoiceType\\:\\:configureOptions\\(\\) has no return type specified\\.$#"
count: 1
path: src/bundle/Form/Type/SectionChoiceType.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\Form\\\\Type\\\\UserType\\:\\:buildForm\\(\\) has no return type specified\\.$#"
count: 1
path: src/bundle/Form/Type/UserType.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Search\\\\IbexaSearchBundle\\:\\:build\\(\\) has no return type specified\\.$#"
count: 1
path: src/bundle/IbexaSearchBundle.php

-
message: "#^Cannot access offset int on iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\ContentType\\>\\.$#"
count: 1
path: src/lib/Mapper/PagerSearchContentToDataMapper.php

-
message: "#^Method Ibexa\\\\Search\\\\Mapper\\\\PagerSearchContentToDataMapper\\:\\:map\\(\\) has parameter \\$pager with generic class Pagerfanta\\\\Pagerfanta but does not specify its types\\: T$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@

class Search extends AbstractParser
{
/**
* Adds semantic configuration definition.
*
* @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system.<siteaccess>
*/
public function addSemanticConfig(NodeBuilder $nodeBuilder)
public function addSemanticConfig(NodeBuilder $nodeBuilder): void
{
$nodeBuilder
->arrayNode('search')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

class SearchView extends View
{
public const NODE_KEY = 'search_view';
public const INFO = 'Template for displaying main search form and results';
public const string NODE_KEY = 'search_view';
public const string INFO = 'Template for displaying main search form and results';
}
10 changes: 4 additions & 6 deletions src/bundle/DependencyInjection/IbexaSearchExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,23 @@

class IbexaSearchExtension extends Extension implements PrependExtensionInterface
{
public function load(array $configs, ContainerBuilder $container)
/**
* @throws \Exception
*/
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yaml');
}

/**
* Allow an extension to prepend the extension configurations.
*
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function prepend(ContainerBuilder $container): void
{
$this->prependJMSTranslation($container);
}

/**
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function prependJMSTranslation(ContainerBuilder $container): void
{
$container->prependExtensionConfig('jms_translation', [
Expand Down
30 changes: 8 additions & 22 deletions src/bundle/Form/ChoiceLoader/ConfiguredLanguagesChoiceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,37 @@
use Ibexa\Contracts\Core\Repository\LanguageService;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;

class ConfiguredLanguagesChoiceLoader implements ChoiceLoaderInterface
{
/** @var \Ibexa\Contracts\Core\Repository\LanguageService */
private $languageService;
private LanguageService $languageService;

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

/**
* @param \Ibexa\Contracts\Core\Repository\LanguageService $languageService
* @param \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface $configResolver
*/
public function __construct(LanguageService $languageService, ConfigResolverInterface $configResolver)
{
$this->languageService = $languageService;
$this->configResolver = $configResolver;
}

/**
* {@inheritdoc}
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Language[]
*/
public function getChoiceList(): array
{
return $this->getPriorityOrderedLanguages();
}

/**
* {@inheritdoc}
*/
public function loadChoiceList(callable $value = null)
public function loadChoiceList(callable $value = null): ChoiceListInterface
{
$choices = $this->getChoiceList();

return new ArrayChoiceList($choices, $value);
}

/**
* {@inheritdoc}
*/
public function loadChoicesForValues(array $values, callable $value = null)
public function loadChoicesForValues(array $values, callable $value = null): array
{
// Optimize
$values = array_filter($values);
Expand All @@ -63,10 +52,7 @@ public function loadChoicesForValues(array $values, callable $value = null)
return $this->loadChoiceList($value)->getChoicesForValues($values);
}

/**
* {@inheritdoc}
*/
public function loadValuesForChoices(array $choices, callable $value = null)
public function loadValuesForChoices(array $choices, callable $value = null): array
{
// Optimize
$choices = array_filter($choices);
Expand All @@ -78,7 +64,7 @@ public function loadValuesForChoices(array $choices, callable $value = null)
}

/**
* Sort languages based on siteaccess languages order.
* Sort languages based on SiteAccess languages order.
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Language[]
*/
Expand Down
36 changes: 9 additions & 27 deletions src/bundle/Form/ChoiceLoader/ContentTypeChoiceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,19 @@
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
use Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;

class ContentTypeChoiceLoader implements ChoiceLoaderInterface
{
/** @var \Ibexa\Contracts\Core\Repository\ContentTypeService */
protected $contentTypeService;

/** @var \Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface */
private $userLanguagePreferenceProvider;

/**
* @param \Ibexa\Contracts\Core\Repository\ContentTypeService $contentTypeService
* @param \Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider
*/
public function __construct(ContentTypeService $contentTypeService, UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider)
{
$this->contentTypeService = $contentTypeService;
$this->userLanguagePreferenceProvider = $userLanguagePreferenceProvider;
public function __construct(
protected ContentTypeService $contentTypeService,
private readonly UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider
) {
}

/**
* {@inheritdoc}
* @return array<string, iterable<\Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType>>
*/
public function getChoiceList(): array
{
Expand All @@ -52,20 +43,14 @@ public function getChoiceList(): array
return $contentTypesList;
}

/**
* {@inheritdoc}
*/
public function loadChoiceList(callable $value = null)
public function loadChoiceList(callable $value = null): ChoiceListInterface
{
$choices = $this->getChoiceList();

return new ArrayChoiceList($choices, $value);
}

/**
* {@inheritdoc}
*/
public function loadChoicesForValues(array $values, callable $value = null)
public function loadChoicesForValues(array $values, callable $value = null): array
{
// Optimize
$values = array_filter($values);
Expand All @@ -76,10 +61,7 @@ public function loadChoicesForValues(array $values, callable $value = null)
return $this->loadChoiceList($value)->getChoicesForValues($values);
}

/**
* {@inheritdoc}
*/
public function loadValuesForChoices(array $choices, callable $value = null)
public function loadValuesForChoices(array $choices, callable $value = null): array
{
// Optimize
$choices = array_filter($choices);
Expand Down
3 changes: 2 additions & 1 deletion src/bundle/IbexaSearchBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Bundle\Search;

Expand All @@ -15,7 +16,7 @@

class IbexaSearchBundle extends Bundle
{
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
/** @var \Ibexa\Bundle\Core\DependencyInjection\IbexaCoreExtension $core */
$core = $container->getExtension('ibexa');
Expand Down
4 changes: 2 additions & 2 deletions src/bundle/Twig/Extension/SearchFacetsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getFilters(): array
return [
new TwigFilter(
'ibexa_choices_as_facets',
[$this, 'getChoicesAsFacets']
$this->getChoicesAsFacets(...)
),
];
}
Expand All @@ -46,7 +46,7 @@ public function getChoicesAsFacets(

if ($comparator === null) {
$comparator = static function (ChoiceView $choice, TermAggregationResultEntry $term): bool {
return $choice->data == $term->getKey();
return $choice->data === $term->getKey();
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function testOnContentSuggestionWithException(): void
$event = new BuildSuggestionCollectionEvent($query);

$this->loggerMock
->expects($this->once())
->expects(self::once())
->method('error');

$subscriber->onBuildSuggestionCollectionEvent($event);
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/QueryType/SearchQueryTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testGetQuery(
->method('supports')
->willReturnMap($returnMap);

$this->assertEquals($expectedQuery, $this->queryType->getQuery($parameters));
self::assertEquals($expectedQuery, $this->queryType->getQuery($parameters));
}

/**
Expand Down
Loading
Loading