diff --git a/composer.json b/composer.json index 1a4bec0..459cd5a 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1158007..46255f1 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -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\\, iterable\\ given\\.$#" count: 1 @@ -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 @@ -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\\\\.$#" - 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 diff --git a/src/bundle/DependencyInjection/Configuration/Parser/Search.php b/src/bundle/DependencyInjection/Configuration/Parser/Search.php index b24f63d..583769b 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/Search.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/Search.php @@ -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. - */ - public function addSemanticConfig(NodeBuilder $nodeBuilder) + public function addSemanticConfig(NodeBuilder $nodeBuilder): void { $nodeBuilder ->arrayNode('search') diff --git a/src/bundle/DependencyInjection/Configuration/Parser/SearchView.php b/src/bundle/DependencyInjection/Configuration/Parser/SearchView.php index f45b90e..06ecc77 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/SearchView.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/SearchView.php @@ -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'; } diff --git a/src/bundle/DependencyInjection/IbexaSearchExtension.php b/src/bundle/DependencyInjection/IbexaSearchExtension.php index c5035d5..2242d56 100644 --- a/src/bundle/DependencyInjection/IbexaSearchExtension.php +++ b/src/bundle/DependencyInjection/IbexaSearchExtension.php @@ -16,7 +16,10 @@ 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'); @@ -24,17 +27,12 @@ public function load(array $configs, ContainerBuilder $container) /** * 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', [ diff --git a/src/bundle/Form/ChoiceLoader/ConfiguredLanguagesChoiceLoader.php b/src/bundle/Form/ChoiceLoader/ConfiguredLanguagesChoiceLoader.php index aff0213..98c6683 100644 --- a/src/bundle/Form/ChoiceLoader/ConfiguredLanguagesChoiceLoader.php +++ b/src/bundle/Form/ChoiceLoader/ConfiguredLanguagesChoiceLoader.php @@ -11,20 +11,15 @@ 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; @@ -32,27 +27,21 @@ public function __construct(LanguageService $languageService, ConfigResolverInte } /** - * {@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); @@ -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); @@ -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[] */ diff --git a/src/bundle/Form/ChoiceLoader/ContentTypeChoiceLoader.php b/src/bundle/Form/ChoiceLoader/ContentTypeChoiceLoader.php index 2d7e4f9..aebc4e4 100644 --- a/src/bundle/Form/ChoiceLoader/ContentTypeChoiceLoader.php +++ b/src/bundle/Form/ChoiceLoader/ContentTypeChoiceLoader.php @@ -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> */ public function getChoiceList(): array { @@ -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); @@ -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); diff --git a/src/bundle/IbexaSearchBundle.php b/src/bundle/IbexaSearchBundle.php index b2b8a76..0e207d2 100644 --- a/src/bundle/IbexaSearchBundle.php +++ b/src/bundle/IbexaSearchBundle.php @@ -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; @@ -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'); diff --git a/src/bundle/Twig/Extension/SearchFacetsExtension.php b/src/bundle/Twig/Extension/SearchFacetsExtension.php index bced76c..17d5426 100644 --- a/src/bundle/Twig/Extension/SearchFacetsExtension.php +++ b/src/bundle/Twig/Extension/SearchFacetsExtension.php @@ -24,7 +24,7 @@ public function getFilters(): array return [ new TwigFilter( 'ibexa_choices_as_facets', - [$this, 'getChoicesAsFacets'] + $this->getChoicesAsFacets(...) ), ]; } @@ -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(); }; } diff --git a/tests/lib/EventDispatcher/EventListener/ContentSuggestionSubscriberTest.php b/tests/lib/EventDispatcher/EventListener/ContentSuggestionSubscriberTest.php index aa00398..35da31b 100644 --- a/tests/lib/EventDispatcher/EventListener/ContentSuggestionSubscriberTest.php +++ b/tests/lib/EventDispatcher/EventListener/ContentSuggestionSubscriberTest.php @@ -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); diff --git a/tests/lib/QueryType/SearchQueryTypeTest.php b/tests/lib/QueryType/SearchQueryTypeTest.php index 0353635..e049e75 100644 --- a/tests/lib/QueryType/SearchQueryTypeTest.php +++ b/tests/lib/QueryType/SearchQueryTypeTest.php @@ -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)); } /** diff --git a/tests/lib/Service/Event/SuggestionServiceTest.php b/tests/lib/Service/Event/SuggestionServiceTest.php index 78ceb7d..7d88492 100644 --- a/tests/lib/Service/Event/SuggestionServiceTest.php +++ b/tests/lib/Service/Event/SuggestionServiceTest.php @@ -57,7 +57,7 @@ static function (Event $event) use (&$callCount, $query, $suggestionCollection): ); $this->innerServiceMock - ->expects($this->once()) + ->expects(self::once()) ->method('suggest') ->with($query) ->willReturn($suggestionCollection); @@ -75,18 +75,18 @@ public function testSuggestWithPropagationStop(): void $beforeEvent->stopPropagation(); $this->eventDispatcherMock - ->expects($this->once()) + ->expects(self::once()) ->method('dispatch') ->willReturn($beforeEvent); $this->innerServiceMock - ->expects($this->never()) + ->expects(self::never()) ->method('suggest'); $service = new SuggestionService($this->innerServiceMock, $this->eventDispatcherMock); - self::expectException(LogicException::class); - self::expectExceptionMessage('The suggestion collection must be set when the propagation is stopped.'); + $this->expectException(LogicException::class); + $this->expectExceptionMessage('The suggestion collection must be set when the propagation is stopped.'); $service->suggest($query); } } diff --git a/tests/lib/SortingDefinition/Provider/NameSortingDefinitionProviderTest.php b/tests/lib/SortingDefinition/Provider/NameSortingDefinitionProviderTest.php index 47b0433..3b1f19c 100644 --- a/tests/lib/SortingDefinition/Provider/NameSortingDefinitionProviderTest.php +++ b/tests/lib/SortingDefinition/Provider/NameSortingDefinitionProviderTest.php @@ -44,7 +44,7 @@ public function testGetSortingDefinitionsForLSE(): void { $this->setSearchEngine('legacy'); - $this->assertEquals( + self::assertEquals( [ new SortingDefinition( 'name_asc', @@ -71,7 +71,7 @@ public function testGetSortingDefinitionsForNonLSE(): void { $this->setSearchEngine('solr'); - $this->assertEquals( + self::assertEquals( [ new SortingDefinition( 'name_asc',