From 5acf1139532d1fb1b07958de56df31f88594c331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20K=C3=A4hm?= Date: Thu, 19 Jan 2023 17:22:37 +0100 Subject: [PATCH] [TASK:T12] Fix TYPO3 12+ coding standards for 0.7.1+ This change contains: * Reenable "modernize_strpos" rule and applies it * The PSR12 rule for import type blocks for PhpcsFixer The ordered_imports.imports_order is now class, function, const * the coding standards fixes for TYPO3 12+. Fixes: #3460 --- .php-cs-fixer.php | 9 ++++++++- Classes/Access/Rootline.php | 2 +- Classes/Access/RootlineElement.php | 8 ++++---- Classes/ConnectionManager.php | 3 ++- Classes/ContentObject/Classification.php | 2 +- Classes/ContentObject/Content.php | 2 +- Classes/ContentObject/Multivalue.php | 2 +- Classes/ContentObject/Relation.php | 8 ++++---- Classes/Controller/SearchController.php | 2 +- .../LastSearches/LastSearchesRepository.php | 1 + .../Search/Query/AbstractQueryBuilder.php | 2 +- .../Query/ParameterBuilder/Faceting.php | 2 +- .../Search/Query/ParameterBuilder/Filters.php | 1 + .../Query/ParameterBuilder/Operator.php | 4 ++-- .../Query/ParameterBuilder/ReturnFields.php | 2 +- .../Search/Query/ParameterBuilder/Slops.php | 2 +- .../Search/Query/ParameterBuilder/Sorting.php | 4 ++-- .../Search/ResultSet/Facets/AbstractFacet.php | 2 +- .../OptionBased/Hierarchy/HierarchyFacet.php | 2 +- .../Hierarchy/HierarchyFacetParser.php | 2 +- .../Hierarchy/HierarchyUrlDecoder.php | 2 +- .../OptionBased/Options/OptionsFacet.php | 2 +- .../Options/OptionsFacetParser.php | 2 +- .../QueryGroup/QueryGroupFacet.php | 2 +- .../RangeBased/DateRange/DateRangeFacet.php | 2 +- .../DateRange/DateRangeUrlDecoder.php | 2 +- .../NumericRange/NumericRangeFacet.php | 2 +- .../NumericRange/NumericRangeUrlDecoder.php | 2 +- .../ResultSet/Facets/SortingExpression.php | 2 +- .../ResultSet/Facets/UrlFacetContainer.php | 4 ++-- .../ResultSet/SearchResultSetService.php | 3 ++- .../Search/ResultSet/Sorting/Sorting.php | 4 ++-- Classes/Domain/Search/SearchRequest.php | 2 +- .../Domain/Search/Uri/SearchUriBuilder.php | 3 +-- Classes/IndexQueue/AbstractIndexer.php | 2 +- .../FrontendHelper/AuthorizationService.php | 2 +- Classes/IndexQueue/Item.php | 8 ++++---- Classes/IndexQueue/PageIndexerRequest.php | 2 +- Classes/Query/Modifier/Faceting.php | 2 +- .../AccessFilterPluginInstalledStatus.php | 4 ++-- Classes/Report/SchemaStatus.php | 2 +- Classes/Report/SiteHandlingStatus.php | 4 ++-- Classes/Report/SolrConfigStatus.php | 2 +- Classes/Report/SolrVersionStatus.php | 2 +- .../SolrFacetMaskAndCombineEnhancer.php | 2 +- Classes/Routing/RoutingService.php | 6 +++--- Classes/System/DateTime/FormatService.php | 2 +- Classes/System/Logging/SolrLogManager.php | 8 ++++---- .../Service/ModuleDataStorageService.php | 6 +++--- .../System/Service/ConfigurationService.php | 4 ++-- .../System/Solr/Service/SolrAdminService.php | 19 ++++++++++--------- .../System/Solr/Service/SolrWriteService.php | 2 +- Classes/System/TCA/TCAService.php | 2 +- Classes/System/Url/UrlHelper.php | 4 ++-- .../UserFunctions/FlexFormUserFunctions.php | 3 ++- Classes/Task/EventQueueWorkerTask.php | 2 +- Classes/Task/IndexQueueWorkerTask.php | 4 ++-- Classes/Typo3PageContentExtractor.php | 3 ++- .../IfHasAccessToModuleViewHelper.php | 4 ++-- Tests/Integration/ConnectionManagerTest.php | 1 + .../Controller/SearchControllerTest.php | 2 +- Tests/Integration/IntegrationTest.php | 5 +++-- .../Search/ApacheSolrDocument/BuilderTest.php | 2 +- .../FrequentSearchesServiceTest.php | 2 +- .../Domain/Search/Query/QueryBuilderTest.php | 1 + .../Search/Suggest/SuggestServiceTest.php | 2 +- Tests/Unit/IndexQueue/AbstractIndexerTest.php | 2 +- .../Middleware/SolrRoutingMiddlewareTest.php | 2 +- Tests/Unit/Query/Modifier/FacetingTest.php | 5 +++-- composer.json | 2 +- 70 files changed, 120 insertions(+), 103 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index f1d908105e..cf5fd2b461 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -4,7 +4,14 @@ $config = \TYPO3\CodingStandards\CsFixerConfig::create(); $config - ->addRules(['modernize_strpos' => false]) + ->addRules( + [ + 'ordered_imports' => [ + 'imports_order' => ['class', 'function', 'const'], + 'sort_algorithm' => 'alpha' + ] + ], + ) ->getFinder() ->exclude([ '.Build' diff --git a/Classes/Access/Rootline.php b/Classes/Access/Rootline.php index 7d68c7c8a8..4b49a83b83 100644 --- a/Classes/Access/Rootline.php +++ b/Classes/Access/Rootline.php @@ -63,7 +63,7 @@ class Rootline * * @var string */ - const ELEMENT_DELIMITER = '/'; + public const ELEMENT_DELIMITER = '/'; /** * Storage for access rootline elements diff --git a/Classes/Access/RootlineElement.php b/Classes/Access/RootlineElement.php index bad18558da..3fc0c43e6f 100644 --- a/Classes/Access/RootlineElement.php +++ b/Classes/Access/RootlineElement.php @@ -30,28 +30,28 @@ class RootlineElement * * @var int */ - const ELEMENT_TYPE_PAGE = 1; + public const ELEMENT_TYPE_PAGE = 1; /** * Content access rootline element. * * @var int */ - const ELEMENT_TYPE_CONTENT = 2; + public const ELEMENT_TYPE_CONTENT = 2; /** * Record access rootline element. * * @var int */ - const ELEMENT_TYPE_RECORD = 3; + public const ELEMENT_TYPE_RECORD = 3; /** * Delimiter between the page ID and the groups set for a page. * * @var string */ - const PAGE_ID_GROUP_DELIMITER = ':'; + public const PAGE_ID_GROUP_DELIMITER = ':'; /** * Access type, either page (default) or content. Depending on the type, diff --git a/Classes/ConnectionManager.php b/Classes/ConnectionManager.php index 264bc3761e..b070f3d8ec 100644 --- a/Classes/ConnectionManager.php +++ b/Classes/ConnectionManager.php @@ -26,12 +26,13 @@ use ApacheSolrForTypo3\Solr\System\Util\SiteUtility; use Doctrine\DBAL\Driver\Exception as DBALDriverException; use InvalidArgumentException; -use function json_encode; use Throwable; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Site\Entity\Site as Typo3Site; use TYPO3\CMS\Core\Utility\GeneralUtility; +use function json_encode; + /** * ConnectionManager is responsible to create SolrConnection objects. * diff --git a/Classes/ContentObject/Classification.php b/Classes/ContentObject/Classification.php index 853ba186f5..c5c91bc976 100644 --- a/Classes/ContentObject/Classification.php +++ b/Classes/ContentObject/Classification.php @@ -39,7 +39,7 @@ */ class Classification extends AbstractContentObject { - const CONTENT_OBJECT_NAME = 'SOLR_CLASSIFICATION'; + public const CONTENT_OBJECT_NAME = 'SOLR_CLASSIFICATION'; /** * Executes the SOLR_CLASSIFICATION content object. diff --git a/Classes/ContentObject/Content.php b/Classes/ContentObject/Content.php index a06a8125e1..2f224d1d0b 100644 --- a/Classes/ContentObject/Content.php +++ b/Classes/ContentObject/Content.php @@ -28,7 +28,7 @@ */ class Content extends AbstractContentObject { - const CONTENT_OBJECT_NAME = 'SOLR_CONTENT'; + public const CONTENT_OBJECT_NAME = 'SOLR_CONTENT'; /** * Executes the SOLR_CONTENT content object. diff --git a/Classes/ContentObject/Multivalue.php b/Classes/ContentObject/Multivalue.php index 6d78a07e4d..7ef6eae5c7 100644 --- a/Classes/ContentObject/Multivalue.php +++ b/Classes/ContentObject/Multivalue.php @@ -36,7 +36,7 @@ */ class Multivalue extends AbstractContentObject { - const CONTENT_OBJECT_NAME = 'SOLR_MULTIVALUE'; + public const CONTENT_OBJECT_NAME = 'SOLR_MULTIVALUE'; /** * Executes the SOLR_MULTIVALUE content object. diff --git a/Classes/ContentObject/Relation.php b/Classes/ContentObject/Relation.php index e0f86d0e75..ba7df50427 100644 --- a/Classes/ContentObject/Relation.php +++ b/Classes/ContentObject/Relation.php @@ -178,7 +178,7 @@ protected function getRelatedItemsFromMMTable(string $localTableName, int $local $mmTableName = $localFieldTca['config']['MM']; // Remove the first option of foreignLabelField for recursion - if (strpos($this->configuration['foreignLabelField'] ?? '', '.') !== false) { + if (str_contains($this->configuration['foreignLabelField'] ?? '', '.')) { $foreignTableLabelFieldArr = explode('.', $this->configuration['foreignLabelField']); unset($foreignTableLabelFieldArr[0]); $this->configuration['foreignLabelField'] = implode('.', $foreignTableLabelFieldArr); @@ -200,7 +200,7 @@ protected function getRelatedItemsFromMMTable(string $localTableName, int $local && !empty($this->configuration['enableRecursiveValueResolution']) ) { $this->configuration['localField'] = $foreignTableLabelField; - if (strpos($this->configuration['foreignLabelField'], '.') !== false) { + if (str_contains($this->configuration['foreignLabelField'], '.')) { $foreignTableLabelFieldArr = explode('.', $this->configuration['foreignLabelField']); unset($foreignTableLabelFieldArr[0]); $this->configuration['foreignLabelField'] = implode('.', $foreignTableLabelFieldArr); @@ -238,7 +238,7 @@ protected function resolveForeignTableLabelField(array $foreignTableTca): ?strin return $foreignTableLabelField; } - if (strpos($this->configuration['foreignLabelField'] ?? '', '.') !== false) { + if (str_contains($this->configuration['foreignLabelField'] ?? '', '.')) { list($foreignTableLabelField) = explode('.', $this->configuration['foreignLabelField'], 2); } else { $foreignTableLabelField = $this->configuration['foreignLabelField']; @@ -352,7 +352,7 @@ protected function resolveRelatedValue( // adjust configuration for next level $this->configuration['localField'] = $foreignTableLabelField; $parentContentObject->data = $relatedRecord; - if (strpos($this->configuration['foreignLabelField'], '.') !== false) { + if (str_contains($this->configuration['foreignLabelField'], '.')) { list(, $this->configuration['foreignLabelField']) = explode( '.', $this->configuration['foreignLabelField'], diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php index b619bce680..284e763055 100644 --- a/Classes/Controller/SearchController.php +++ b/Classes/Controller/SearchController.php @@ -74,7 +74,7 @@ public function initializeView($view) return; } - if (strpos($customTemplate, 'EXT:') !== false) { + if (str_contains($customTemplate, 'EXT:')) { $view->setTemplatePathAndFilename($customTemplate); } else { $view->setTemplate($customTemplate); diff --git a/Classes/Domain/Search/LastSearches/LastSearchesRepository.php b/Classes/Domain/Search/LastSearches/LastSearchesRepository.php index d6c07e8d33..f2c3342de1 100644 --- a/Classes/Domain/Search/LastSearches/LastSearchesRepository.php +++ b/Classes/Domain/Search/LastSearches/LastSearchesRepository.php @@ -19,6 +19,7 @@ use Doctrine\DBAL\Driver\Exception as DBALDriverException; use Doctrine\DBAL\Exception as DBALException; use InvalidArgumentException; + use function json_encode; class LastSearchesRepository extends AbstractRepository diff --git a/Classes/Domain/Search/Query/AbstractQueryBuilder.php b/Classes/Domain/Search/Query/AbstractQueryBuilder.php index 15d3c31460..91547a127c 100644 --- a/Classes/Domain/Search/Query/AbstractQueryBuilder.php +++ b/Classes/Domain/Search/Query/AbstractQueryBuilder.php @@ -143,7 +143,7 @@ public function removeAllSortings(): AbstractQueryBuilder */ public function useSorting(Sorting $sorting): AbstractQueryBuilder { - if (strpos($sorting->getFieldName(), 'relevance') !== false) { + if (str_contains($sorting->getFieldName(), 'relevance')) { $this->removeAllSortings(); return $this; } diff --git a/Classes/Domain/Search/Query/ParameterBuilder/Faceting.php b/Classes/Domain/Search/Query/ParameterBuilder/Faceting.php index 55c91bd9b6..c90da58854 100644 --- a/Classes/Domain/Search/Query/ParameterBuilder/Faceting.php +++ b/Classes/Domain/Search/Query/ParameterBuilder/Faceting.php @@ -262,7 +262,7 @@ public function build(AbstractQueryBuilder $parentBuilder): AbstractQueryBuilder $params = $query->getParams(); foreach ($params as $key => $value) { - if (strpos($key, 'f.') !== false) { + if (str_contains($key, 'f.')) { $query->addParam($key, null); } } diff --git a/Classes/Domain/Search/Query/ParameterBuilder/Filters.php b/Classes/Domain/Search/Query/ParameterBuilder/Filters.php index 542d123f11..3f936c21e5 100644 --- a/Classes/Domain/Search/Query/ParameterBuilder/Filters.php +++ b/Classes/Domain/Search/Query/ParameterBuilder/Filters.php @@ -16,6 +16,7 @@ namespace ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder; use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration; + use function str_starts_with; /** diff --git a/Classes/Domain/Search/Query/ParameterBuilder/Operator.php b/Classes/Domain/Search/Query/ParameterBuilder/Operator.php index e05f84d1a7..05dc717746 100644 --- a/Classes/Domain/Search/Query/ParameterBuilder/Operator.php +++ b/Classes/Domain/Search/Query/ParameterBuilder/Operator.php @@ -23,8 +23,8 @@ */ class Operator extends AbstractDeactivatable { - const OPERATOR_AND = 'AND'; - const OPERATOR_OR = 'OR'; + public const OPERATOR_AND = 'AND'; + public const OPERATOR_OR = 'OR'; /** * @var string diff --git a/Classes/Domain/Search/Query/ParameterBuilder/ReturnFields.php b/Classes/Domain/Search/Query/ParameterBuilder/ReturnFields.php index 26fb717921..1032fa7972 100644 --- a/Classes/Domain/Search/Query/ParameterBuilder/ReturnFields.php +++ b/Classes/Domain/Search/Query/ParameterBuilder/ReturnFields.php @@ -47,7 +47,7 @@ public function __construct(array $fieldList = []) */ public function add(string $fieldName) { - if (strpos($fieldName, '[') === false && strpos($fieldName, ']') === false && in_array('*', $this->fieldList)) { + if (!str_contains($fieldName, '[') && !str_contains($fieldName, ']') && in_array('*', $this->fieldList)) { $this->fieldList = array_diff($this->fieldList, ['*']); } diff --git a/Classes/Domain/Search/Query/ParameterBuilder/Slops.php b/Classes/Domain/Search/Query/ParameterBuilder/Slops.php index 17fe0e4b5b..5d09f3fd79 100644 --- a/Classes/Domain/Search/Query/ParameterBuilder/Slops.php +++ b/Classes/Domain/Search/Query/ParameterBuilder/Slops.php @@ -26,7 +26,7 @@ */ class Slops implements ParameterBuilderInterface { - const NO_SLOP = null; + public const NO_SLOP = null; /** * The qs parameter diff --git a/Classes/Domain/Search/Query/ParameterBuilder/Sorting.php b/Classes/Domain/Search/Query/ParameterBuilder/Sorting.php index b98885f793..91ed9b3451 100644 --- a/Classes/Domain/Search/Query/ParameterBuilder/Sorting.php +++ b/Classes/Domain/Search/Query/ParameterBuilder/Sorting.php @@ -23,8 +23,8 @@ */ class Sorting extends AbstractDeactivatable { - const SORT_ASC = 'ASC'; - const SORT_DESC = 'DESC'; + public const SORT_ASC = 'ASC'; + public const SORT_DESC = 'DESC'; /** * @var string diff --git a/Classes/Domain/Search/ResultSet/Facets/AbstractFacet.php b/Classes/Domain/Search/ResultSet/Facets/AbstractFacet.php index 4927837912..196a2846ee 100644 --- a/Classes/Domain/Search/ResultSet/Facets/AbstractFacet.php +++ b/Classes/Domain/Search/ResultSet/Facets/AbstractFacet.php @@ -28,7 +28,7 @@ */ abstract class AbstractFacet { - const TYPE_ABSTRACT = 'abstract'; + public const TYPE_ABSTRACT = 'abstract'; /** * String diff --git a/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyFacet.php b/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyFacet.php index d49785772a..d72cee63f6 100644 --- a/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyFacet.php +++ b/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyFacet.php @@ -29,7 +29,7 @@ */ class HierarchyFacet extends AbstractFacet { - const TYPE_HIERARCHY = 'hierarchy'; + public const TYPE_HIERARCHY = 'hierarchy'; /** * String diff --git a/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyFacetParser.php b/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyFacetParser.php index bf50fd0b6a..09ab970877 100644 --- a/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyFacetParser.php +++ b/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyFacetParser.php @@ -150,7 +150,7 @@ protected function getActiveFacetValuesFromRequest(SearchResultSet $resultSet, s foreach (is_array($values) ? $values : [] as $valueFromRequest) { // Attach the 'depth' param again to the value - if (strpos($valueFromRequest, '-') === false) { + if (!str_contains($valueFromRequest, '-')) { $valueFromRequest = HierarchyTool::substituteSlashes($valueFromRequest); $valueFromRequest = trim($valueFromRequest, '/'); $valueFromRequest = (count(explode('/', $valueFromRequest)) - 1) . '-' . $valueFromRequest . '/'; diff --git a/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyUrlDecoder.php b/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyUrlDecoder.php index 3a7c89c1be..a51bb237df 100644 --- a/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyUrlDecoder.php +++ b/Classes/Domain/Search/ResultSet/Facets/OptionBased/Hierarchy/HierarchyUrlDecoder.php @@ -31,7 +31,7 @@ class HierarchyUrlDecoder implements FacetUrlDecoderInterface * * @var string */ - const DELIMITER = '/'; + public const DELIMITER = '/'; /** * Parses the given hierarchy filter and returns a Solr filter query. diff --git a/Classes/Domain/Search/ResultSet/Facets/OptionBased/Options/OptionsFacet.php b/Classes/Domain/Search/ResultSet/Facets/OptionBased/Options/OptionsFacet.php index bb72279e41..2c68ff9955 100644 --- a/Classes/Domain/Search/ResultSet/Facets/OptionBased/Options/OptionsFacet.php +++ b/Classes/Domain/Search/ResultSet/Facets/OptionBased/Options/OptionsFacet.php @@ -27,7 +27,7 @@ */ class OptionsFacet extends AbstractOptionsFacet { - const TYPE_OPTIONS = 'options'; + public const TYPE_OPTIONS = 'options'; /** * String diff --git a/Classes/Domain/Search/ResultSet/Facets/OptionBased/Options/OptionsFacetParser.php b/Classes/Domain/Search/ResultSet/Facets/OptionBased/Options/OptionsFacetParser.php index c6486e82e6..7c74c2a6eb 100644 --- a/Classes/Domain/Search/ResultSet/Facets/OptionBased/Options/OptionsFacetParser.php +++ b/Classes/Domain/Search/ResultSet/Facets/OptionBased/Options/OptionsFacetParser.php @@ -155,7 +155,7 @@ protected function getMetricsFromSolrResponse(string $facetName, ResponseAdapter foreach ($response->facets->{$facetName}->buckets as $bucket) { $bucketVariables = get_object_vars($bucket); foreach ($bucketVariables as $key => $value) { - if (strpos($key, 'metrics_') === 0) { + if (str_starts_with($key, 'metrics_')) { $metricsKey = str_replace('metrics_', '', $key); $metricsFromSolrResponse[$bucket->val][$metricsKey] = $value; } diff --git a/Classes/Domain/Search/ResultSet/Facets/OptionBased/QueryGroup/QueryGroupFacet.php b/Classes/Domain/Search/ResultSet/Facets/OptionBased/QueryGroup/QueryGroupFacet.php index be01142142..ea54fb963d 100644 --- a/Classes/Domain/Search/ResultSet/Facets/OptionBased/QueryGroup/QueryGroupFacet.php +++ b/Classes/Domain/Search/ResultSet/Facets/OptionBased/QueryGroup/QueryGroupFacet.php @@ -27,7 +27,7 @@ */ class QueryGroupFacet extends AbstractOptionsFacet { - const TYPE_QUERY_GROUP = 'queryGroup'; + public const TYPE_QUERY_GROUP = 'queryGroup'; /** * String diff --git a/Classes/Domain/Search/ResultSet/Facets/RangeBased/DateRange/DateRangeFacet.php b/Classes/Domain/Search/ResultSet/Facets/RangeBased/DateRange/DateRangeFacet.php index 75aed993f5..39dbe8579b 100644 --- a/Classes/Domain/Search/ResultSet/Facets/RangeBased/DateRange/DateRangeFacet.php +++ b/Classes/Domain/Search/ResultSet/Facets/RangeBased/DateRange/DateRangeFacet.php @@ -30,7 +30,7 @@ */ class DateRangeFacet extends AbstractFacet { - const TYPE_DATE_RANGE = 'dateRange'; + public const TYPE_DATE_RANGE = 'dateRange'; /** * String diff --git a/Classes/Domain/Search/ResultSet/Facets/RangeBased/DateRange/DateRangeUrlDecoder.php b/Classes/Domain/Search/ResultSet/Facets/RangeBased/DateRange/DateRangeUrlDecoder.php index b325405899..b4c6316581 100644 --- a/Classes/Domain/Search/ResultSet/Facets/RangeBased/DateRange/DateRangeUrlDecoder.php +++ b/Classes/Domain/Search/ResultSet/Facets/RangeBased/DateRange/DateRangeUrlDecoder.php @@ -35,7 +35,7 @@ class DateRangeUrlDecoder implements FacetUrlDecoderInterface * * @var string */ - const DELIMITER = '-'; + public const DELIMITER = '-'; /** * Parses the given date range from a GET parameter and returns a Solr diff --git a/Classes/Domain/Search/ResultSet/Facets/RangeBased/NumericRange/NumericRangeFacet.php b/Classes/Domain/Search/ResultSet/Facets/RangeBased/NumericRange/NumericRangeFacet.php index 95b1296930..3a7c4c17c6 100644 --- a/Classes/Domain/Search/ResultSet/Facets/RangeBased/NumericRange/NumericRangeFacet.php +++ b/Classes/Domain/Search/ResultSet/Facets/RangeBased/NumericRange/NumericRangeFacet.php @@ -30,7 +30,7 @@ */ class NumericRangeFacet extends AbstractFacet { - const TYPE_NUMERIC_RANGE = 'numericRange'; + public const TYPE_NUMERIC_RANGE = 'numericRange'; /** * String diff --git a/Classes/Domain/Search/ResultSet/Facets/RangeBased/NumericRange/NumericRangeUrlDecoder.php b/Classes/Domain/Search/ResultSet/Facets/RangeBased/NumericRange/NumericRangeUrlDecoder.php index 79706bcfb1..7b375e67a2 100644 --- a/Classes/Domain/Search/ResultSet/Facets/RangeBased/NumericRange/NumericRangeUrlDecoder.php +++ b/Classes/Domain/Search/ResultSet/Facets/RangeBased/NumericRange/NumericRangeUrlDecoder.php @@ -34,7 +34,7 @@ class NumericRangeUrlDecoder implements FacetUrlDecoderInterface * * @var string */ - const DELIMITER = '-'; + public const DELIMITER = '-'; /** * Parses the given range from a GET parameter and returns a Solr range diff --git a/Classes/Domain/Search/ResultSet/Facets/SortingExpression.php b/Classes/Domain/Search/ResultSet/Facets/SortingExpression.php index 91a18666cf..cb39c2632d 100644 --- a/Classes/Domain/Search/ResultSet/Facets/SortingExpression.php +++ b/Classes/Domain/Search/ResultSet/Facets/SortingExpression.php @@ -53,7 +53,7 @@ public function getForFacet($sorting): string */ public function getForJsonFacet(string $sorting, string $direction): string { - $isMetricSorting = strpos($sorting, 'metrics_') === 0; + $isMetricSorting = str_starts_with($sorting, 'metrics_'); $expression = $isMetricSorting ? $sorting : $this->getForFacet($sorting); $direction = strtolower($direction ?? ''); if (!empty($direction) && in_array($direction, ['asc', 'desc'])) { diff --git a/Classes/Domain/Search/ResultSet/Facets/UrlFacetContainer.php b/Classes/Domain/Search/ResultSet/Facets/UrlFacetContainer.php index ffee00b369..669cdd168a 100644 --- a/Classes/Domain/Search/ResultSet/Facets/UrlFacetContainer.php +++ b/Classes/Domain/Search/ResultSet/Facets/UrlFacetContainer.php @@ -30,12 +30,12 @@ class UrlFacetContainer implements \Countable /** * Parameters array has a numeric index */ - const PARAMETER_STYLE_INDEX = 'index'; + public const PARAMETER_STYLE_INDEX = 'index'; /** * Parameters array uses combination of key and value as index */ - const PARAMETER_STYLE_ASSOC = 'assoc'; + public const PARAMETER_STYLE_ASSOC = 'assoc'; /** * Used parameter style diff --git a/Classes/Domain/Search/ResultSet/SearchResultSetService.php b/Classes/Domain/Search/ResultSet/SearchResultSetService.php index 56766b243c..ea4c04bcac 100644 --- a/Classes/Domain/Search/ResultSet/SearchResultSetService.php +++ b/Classes/Domain/Search/ResultSet/SearchResultSetService.php @@ -38,12 +38,13 @@ use ApacheSolrForTypo3\Solr\System\Solr\ResponseAdapter; use ApacheSolrForTypo3\Solr\System\Solr\SolrIncompleteResponseException; use Exception; -use function get_class; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; use UnexpectedValueException; +use function get_class; + /** * The SearchResultSetService is responsible to build a SearchResultSet from a SearchRequest. * It encapsulates the logic to trigger a search in order to be able to reuse it in multiple places. diff --git a/Classes/Domain/Search/ResultSet/Sorting/Sorting.php b/Classes/Domain/Search/ResultSet/Sorting/Sorting.php index 27e750f0d8..a0ac1ffc29 100644 --- a/Classes/Domain/Search/ResultSet/Sorting/Sorting.php +++ b/Classes/Domain/Search/ResultSet/Sorting/Sorting.php @@ -25,9 +25,9 @@ */ class Sorting { - const DIRECTION_DESC = 'desc'; + public const DIRECTION_DESC = 'desc'; - const DIRECTION_ASC = 'asc'; + public const DIRECTION_ASC = 'asc'; /** * @var array diff --git a/Classes/Domain/Search/SearchRequest.php b/Classes/Domain/Search/SearchRequest.php index f40ebcdb16..b72bc1e8e6 100644 --- a/Classes/Domain/Search/SearchRequest.php +++ b/Classes/Domain/Search/SearchRequest.php @@ -35,7 +35,7 @@ class SearchRequest * * @var string */ - const DEFAULT_PLUGIN_NAMESPACE = 'tx_solr'; + public const DEFAULT_PLUGIN_NAMESPACE = 'tx_solr'; /** * @var string diff --git a/Classes/Domain/Search/Uri/SearchUriBuilder.php b/Classes/Domain/Search/Uri/SearchUriBuilder.php index f87462448d..5bfd4a9934 100644 --- a/Classes/Domain/Search/Uri/SearchUriBuilder.php +++ b/Classes/Domain/Search/Uri/SearchUriBuilder.php @@ -412,8 +412,7 @@ protected function buildLinkWithInMemoryCache(?int $pageUid, array $arguments): $values = $variableEvent->getVariableValues(); // Take care that everything is urlencoded! $keys = array_map(function ($value) { - // @TODO: With only PHP 8 support, replace this with str_contains() - if (strpos($value, '###') === false) { + if (!str_contains($value, '###')) { return $value; } return urlencode($value); diff --git a/Classes/IndexQueue/AbstractIndexer.php b/Classes/IndexQueue/AbstractIndexer.php index 129ee0035c..1e9ade0ebe 100644 --- a/Classes/IndexQueue/AbstractIndexer.php +++ b/Classes/IndexQueue/AbstractIndexer.php @@ -287,7 +287,7 @@ protected static function isSerializedResultFromRegisteredHook(array $indexingCo throw new UnexpectedValueException($message, 1404471741); } - $isSerialized = (boolean)$serializedValueDetector->isSerializedValue($indexingConfiguration, $solrFieldName); + $isSerialized = (bool)$serializedValueDetector->isSerializedValue($indexingConfiguration, $solrFieldName); if ($isSerialized) { return true; } diff --git a/Classes/IndexQueue/FrontendHelper/AuthorizationService.php b/Classes/IndexQueue/FrontendHelper/AuthorizationService.php index b1be05fdec..c8a5696c2b 100644 --- a/Classes/IndexQueue/FrontendHelper/AuthorizationService.php +++ b/Classes/IndexQueue/FrontendHelper/AuthorizationService.php @@ -37,7 +37,7 @@ class AuthorizationService extends AbstractAuthenticationService * * @var string */ - const SOLR_INDEXER_USERNAME = '__SolrIndexerUser__'; + public const SOLR_INDEXER_USERNAME = '__SolrIndexerUser__'; /** * Gets a fake frontend user record to allow access to protected pages. diff --git a/Classes/IndexQueue/Item.php b/Classes/IndexQueue/Item.php index 76420642f9..e9679b6e7a 100644 --- a/Classes/IndexQueue/Item.php +++ b/Classes/IndexQueue/Item.php @@ -37,11 +37,11 @@ */ class Item { - const STATE_BLOCKED = -1; + public const STATE_BLOCKED = -1; - const STATE_PENDING = 0; + public const STATE_PENDING = 0; - const STATE_INDEXED = 1; + public const STATE_INDEXED = 1; /** * The item's uid in the index queue (tx_solr_indexqueue_item.uid) @@ -168,7 +168,7 @@ public function __construct( $this->errors = (string)empty($itemMetaData['errors']) ? '' : $itemMetaData['errors']; $this->indexingConfigurationName = $itemMetaData['indexing_configuration'] ?? ''; - $this->hasIndexingProperties = (boolean)($itemMetaData['has_indexing_properties'] ?? false); + $this->hasIndexingProperties = (bool)($itemMetaData['has_indexing_properties'] ?? false); if (!empty($fullRecord)) { $this->record = $fullRecord; diff --git a/Classes/IndexQueue/PageIndexerRequest.php b/Classes/IndexQueue/PageIndexerRequest.php index dbe2ea0d85..4ebbced12d 100644 --- a/Classes/IndexQueue/PageIndexerRequest.php +++ b/Classes/IndexQueue/PageIndexerRequest.php @@ -35,7 +35,7 @@ */ class PageIndexerRequest { - const SOLR_INDEX_HEADER = 'X-Tx-Solr-Iq'; + public const SOLR_INDEX_HEADER = 'X-Tx-Solr-Iq'; /** * List of actions to perform during page rendering. diff --git a/Classes/Query/Modifier/Faceting.php b/Classes/Query/Modifier/Faceting.php index 8355484855..dd15b6be08 100644 --- a/Classes/Query/Modifier/Faceting.php +++ b/Classes/Query/Modifier/Faceting.php @@ -237,7 +237,7 @@ protected function getFiltersByFacetName(array $resultParameters, array $allFace $filters = array_keys($filters); } foreach ($filters as $filter) { - if (strpos($filter, ':') === false) { + if (!str_contains($filter, ':')) { continue; } // only split by the first colon to allow using colons in the filter value itself diff --git a/Classes/Report/AccessFilterPluginInstalledStatus.php b/Classes/Report/AccessFilterPluginInstalledStatus.php index 662f973c36..f8ea712f3d 100644 --- a/Classes/Report/AccessFilterPluginInstalledStatus.php +++ b/Classes/Report/AccessFilterPluginInstalledStatus.php @@ -40,14 +40,14 @@ class AccessFilterPluginInstalledStatus extends AbstractSolrStatus * * @var string */ - const RECOMMENDED_PLUGIN_VERSION = '3.0.0'; + public const RECOMMENDED_PLUGIN_VERSION = '3.0.0'; /** * The plugin's Java class name. * * @var string */ - const PLUGIN_CLASS_NAME = 'org.typo3.solr.search.AccessFilterQParserPlugin'; + public const PLUGIN_CLASS_NAME = 'org.typo3.solr.search.AccessFilterQParserPlugin'; /** * Compiles a collection of solrconfig.xml checks against each configured diff --git a/Classes/Report/SchemaStatus.php b/Classes/Report/SchemaStatus.php index eeb964ce63..f4679d8ef9 100644 --- a/Classes/Report/SchemaStatus.php +++ b/Classes/Report/SchemaStatus.php @@ -44,7 +44,7 @@ class SchemaStatus extends AbstractSolrStatus * * @var string */ - const RECOMMENDED_SCHEMA_VERSION = 'tx_solr-11-5-0--20211001'; + public const RECOMMENDED_SCHEMA_VERSION = 'tx_solr-11-5-0--20211001'; /** * Compiles a collection of schema version checks against each configured diff --git a/Classes/Report/SiteHandlingStatus.php b/Classes/Report/SiteHandlingStatus.php index 9a8c2c9c20..97f716c72f 100644 --- a/Classes/Report/SiteHandlingStatus.php +++ b/Classes/Report/SiteHandlingStatus.php @@ -38,12 +38,12 @@ */ class SiteHandlingStatus extends AbstractSolrStatus { - const TITLE_SITE_HANDLING_CONFIGURATION = 'Site handling configuration'; + public const TITLE_SITE_HANDLING_CONFIGURATION = 'Site handling configuration'; /** * @var string */ - const + public const CSS_STATUS_NOTICE = 'notice', CSS_STATUS_INFO = 'info', CSS_STATUS_OK = 'success', diff --git a/Classes/Report/SolrConfigStatus.php b/Classes/Report/SolrConfigStatus.php index 532744b762..24fb7130f0 100644 --- a/Classes/Report/SolrConfigStatus.php +++ b/Classes/Report/SolrConfigStatus.php @@ -43,7 +43,7 @@ class SolrConfigStatus extends AbstractSolrStatus * * @var string */ - const RECOMMENDED_SOLRCONFIG_VERSION = 'tx_solr-11-5-0--20211001'; + public const RECOMMENDED_SOLRCONFIG_VERSION = 'tx_solr-11-5-0--20211001'; /** * Compiles a collection of solrconfig version checks against each configured diff --git a/Classes/Report/SolrVersionStatus.php b/Classes/Report/SolrVersionStatus.php index 9d7ba7de3f..eb95904726 100644 --- a/Classes/Report/SolrVersionStatus.php +++ b/Classes/Report/SolrVersionStatus.php @@ -39,7 +39,7 @@ class SolrVersionStatus extends AbstractSolrStatus * * @var string */ - const REQUIRED_SOLR_VERSION = '8.11.1'; + public const REQUIRED_SOLR_VERSION = '8.11.1'; /** * Compiles a version check against each configured Solr server. diff --git a/Classes/Routing/Enhancer/SolrFacetMaskAndCombineEnhancer.php b/Classes/Routing/Enhancer/SolrFacetMaskAndCombineEnhancer.php index d5111f3480..fbfb8ed727 100644 --- a/Classes/Routing/Enhancer/SolrFacetMaskAndCombineEnhancer.php +++ b/Classes/Routing/Enhancer/SolrFacetMaskAndCombineEnhancer.php @@ -161,7 +161,7 @@ protected function combineArrayParameters(array $parameters = []): array $facetField = substr($facetField, 0, strlen($facetField) - 3); $facetValue = null; - if (strpos($facetField, '%3A') !== false) { + if (str_contains($facetField, '%3A')) { [$facetField, $facetValue] = explode('%3A', $facetField, 2); } diff --git a/Classes/Routing/RoutingService.php b/Classes/Routing/RoutingService.php index d5c1cac738..8947978de5 100644 --- a/Classes/Routing/RoutingService.php +++ b/Classes/Routing/RoutingService.php @@ -47,7 +47,7 @@ class RoutingService implements LoggerAwareInterface /** * Default plugin namespace */ - const PLUGIN_NAMESPACE = 'tx_solr'; + public const PLUGIN_NAMESPACE = 'tx_solr'; /** * Settings from routing configuration @@ -1110,14 +1110,14 @@ protected function processUriPathArgument( $queryKey = (string)$queryKey; $tmpQueryKey = $queryKey; - if (strpos($queryKey, '-') !== false) { + if (str_contains($queryKey, '-')) { [$tmpQueryKey, $filterName] = explode('-', $tmpQueryKey, 2); } if (!isset($queryParams[$tmpQueryKey])) { $queryParams[$tmpQueryKey] = []; } - if (strpos($queryKey, '-') !== false) { + if (str_contains($queryKey, '-')) { [$queryKey, $filterName] = explode('-', $queryKey, 2); // explode multiple values $values = $this->pathFacetStringToArray($parameters[$fieldName], false); diff --git a/Classes/System/DateTime/FormatService.php b/Classes/System/DateTime/FormatService.php index 590acfabec..fda39be807 100644 --- a/Classes/System/DateTime/FormatService.php +++ b/Classes/System/DateTime/FormatService.php @@ -27,7 +27,7 @@ */ class FormatService { - const SOLR_ISO_DATETIME_FORMAT = 'Y-m-d\TH:i:s\Z'; + public const SOLR_ISO_DATETIME_FORMAT = 'Y-m-d\TH:i:s\Z'; /** * @see http://php.net/manual/de/function.date.php for formatting options diff --git a/Classes/System/Logging/SolrLogManager.php b/Classes/System/Logging/SolrLogManager.php index e85900b5da..59594650db 100644 --- a/Classes/System/Logging/SolrLogManager.php +++ b/Classes/System/Logging/SolrLogManager.php @@ -27,10 +27,10 @@ */ class SolrLogManager { - const WARNING = LogLevel::WARNING; - const ERROR = LogLevel::ERROR; - const INFO = LogLevel::INFO; - const NOTICE = LogLevel::NOTICE; + public const WARNING = LogLevel::WARNING; + public const ERROR = LogLevel::ERROR; + public const INFO = LogLevel::INFO; + public const NOTICE = LogLevel::NOTICE; /** * @var Logger|null diff --git a/Classes/System/Mvc/Backend/Service/ModuleDataStorageService.php b/Classes/System/Mvc/Backend/Service/ModuleDataStorageService.php index e892139222..9b93943cff 100644 --- a/Classes/System/Mvc/Backend/Service/ModuleDataStorageService.php +++ b/Classes/System/Mvc/Backend/Service/ModuleDataStorageService.php @@ -29,7 +29,7 @@ class ModuleDataStorageService implements SingletonInterface /** * @var string */ - const KEY = 'tx_solr'; + public const KEY = 'tx_solr'; /** * Loads module data for user settings or returns a fresh object initially @@ -71,8 +71,8 @@ private function unsetModuleDataIfCanNotBeSerialized(string &$serializedModuleDa $serializedModuleData = ''; return; } - if (strpos($serializedModuleData, 'ApacheSolrForTypo3\\Solr\\Domain\\Model\\ModuleData') !== false - || strpos($serializedModuleData, 'Tx_Solr_Site') !== false) { + if (str_contains($serializedModuleData, 'ApacheSolrForTypo3\\Solr\\Domain\\Model\\ModuleData') + || str_contains($serializedModuleData, 'Tx_Solr_Site')) { $serializedModuleData = ''; } } diff --git a/Classes/System/Service/ConfigurationService.php b/Classes/System/Service/ConfigurationService.php index 1e1373b9de..31c7c10f1e 100644 --- a/Classes/System/Service/ConfigurationService.php +++ b/Classes/System/Service/ConfigurationService.php @@ -132,11 +132,11 @@ protected function getFilterFromFlexForm(array $flexFormConfiguration): array $fieldName = $filter['field']; $fieldValue = $filter['value']; - if (!is_numeric($fieldValue) && strpos($fieldValue, '?') === false && strpos($fieldValue, '*') === false) { + if (!is_numeric($fieldValue) && !str_contains($fieldValue, '?') && !str_contains($fieldValue, '*')) { $fieldValue = '"' . str_replace('"', '\"', $fieldValue) . '"'; } - $filterConfiguration[] = $fieldName . ':' . $fieldValue; + $filterConfiguration[] = $fieldName . ':' . $fieldValue; } return $filterConfiguration; } diff --git a/Classes/System/Solr/Service/SolrAdminService.php b/Classes/System/Solr/Service/SolrAdminService.php index 1354e77258..ca79d462d5 100644 --- a/Classes/System/Solr/Service/SolrAdminService.php +++ b/Classes/System/Solr/Service/SolrAdminService.php @@ -25,24 +25,25 @@ use ApacheSolrForTypo3\Solr\System\Solr\ResponseAdapter; use ApacheSolrForTypo3\Solr\System\Solr\Schema\Schema; use InvalidArgumentException; -use function simplexml_load_string; use Solarium\Client; use stdClass; use TYPO3\CMS\Core\Utility\GeneralUtility; +use function simplexml_load_string; + /** * Class SolrAdminService */ class SolrAdminService extends AbstractSolrService { - const PLUGINS_SERVLET = 'admin/plugins'; - const LUKE_SERVLET = 'admin/luke'; - const SYSTEM_SERVLET = 'admin/system'; - const CORES_SERVLET = '../admin/cores'; - const FILE_SERVLET = 'admin/file'; - const SCHEMA_SERVLET = 'schema'; - const SYNONYMS_SERVLET = 'schema/analysis/synonyms/'; - const STOPWORDS_SERVLET = 'schema/analysis/stopwords/'; + public const PLUGINS_SERVLET = 'admin/plugins'; + public const LUKE_SERVLET = 'admin/luke'; + public const SYSTEM_SERVLET = 'admin/system'; + public const CORES_SERVLET = '../admin/cores'; + public const FILE_SERVLET = 'admin/file'; + public const SCHEMA_SERVLET = 'schema'; + public const SYNONYMS_SERVLET = 'schema/analysis/synonyms/'; + public const STOPWORDS_SERVLET = 'schema/analysis/stopwords/'; /** * @var array diff --git a/Classes/System/Solr/Service/SolrWriteService.php b/Classes/System/Solr/Service/SolrWriteService.php index 295430d1a1..2adb4d0d1d 100644 --- a/Classes/System/Solr/Service/SolrWriteService.php +++ b/Classes/System/Solr/Service/SolrWriteService.php @@ -30,7 +30,7 @@ */ class SolrWriteService extends AbstractSolrService { - const EXTRACT_SERVLET = 'update/extract'; + public const EXTRACT_SERVLET = 'update/extract'; /** * Performs a content and meta data extraction request. diff --git a/Classes/System/TCA/TCAService.php b/Classes/System/TCA/TCAService.php index 7d1d21c76a..cff6787a81 100644 --- a/Classes/System/TCA/TCAService.php +++ b/Classes/System/TCA/TCAService.php @@ -171,7 +171,7 @@ public function isHidden(string $table, array $record): bool if (isset($this->tca[$table]['ctrl']['enablecolumns']['disabled'])) { $hiddenField = $this->tca[$table]['ctrl']['enablecolumns']['disabled']; - $hidden = (boolean)$record[$hiddenField]; + $hidden = (bool)$record[$hiddenField]; } return $hidden; diff --git a/Classes/System/Url/UrlHelper.php b/Classes/System/Url/UrlHelper.php index 1c090ea397..268b5aeda7 100644 --- a/Classes/System/Url/UrlHelper.php +++ b/Classes/System/Url/UrlHelper.php @@ -73,11 +73,11 @@ public function setScheme(string $scheme): UrlHelper */ public function setPath(string $path): UrlHelper { - if (strpos($path, '?') !== false) { + if (str_contains($path, '?')) { throw new InvalidArgumentException('Invalid path provided. Must not contain a query string.', 1436717330); } - if (strpos($path, '#') !== false) { + if (str_contains($path, '#')) { throw new InvalidArgumentException('Invalid path provided; must not contain a URI fragment', 1436717332); } $this->path = $this->sanitizePath($path); diff --git a/Classes/System/UserFunctions/FlexFormUserFunctions.php b/Classes/System/UserFunctions/FlexFormUserFunctions.php index 43b119a2b1..2fc194c0ca 100644 --- a/Classes/System/UserFunctions/FlexFormUserFunctions.php +++ b/Classes/System/UserFunctions/FlexFormUserFunctions.php @@ -23,11 +23,12 @@ use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration; use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection; use Doctrine\DBAL\Driver\Exception as DBALDriverException; -use function str_starts_with; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; +use function str_starts_with; + /** * This class contains all user functions for flexforms. * diff --git a/Classes/Task/EventQueueWorkerTask.php b/Classes/Task/EventQueueWorkerTask.php index b5e3fed656..59ea9dcb6f 100644 --- a/Classes/Task/EventQueueWorkerTask.php +++ b/Classes/Task/EventQueueWorkerTask.php @@ -37,7 +37,7 @@ */ final class EventQueueWorkerTask extends AbstractTask { - const DEFAULT_PROCESSING_LIMIT = 100; + public const DEFAULT_PROCESSING_LIMIT = 100; /** * Processing limit, the number of events to process diff --git a/Classes/Task/IndexQueueWorkerTask.php b/Classes/Task/IndexQueueWorkerTask.php index 4e855f4d59..cf9be69269 100644 --- a/Classes/Task/IndexQueueWorkerTask.php +++ b/Classes/Task/IndexQueueWorkerTask.php @@ -105,11 +105,11 @@ public function getWebRoot(): string */ protected function replaceWebRootMarkers(string $webRoot): string { - if (strpos($webRoot, '###PATH_typo3###') !== false) { + if (str_contains($webRoot, '###PATH_typo3###')) { $webRoot = str_replace('###PATH_typo3###', Environment::getPublicPath() . '/typo3/', $webRoot); } - if (strpos($webRoot, '###PATH_site###') !== false) { + if (str_contains($webRoot, '###PATH_site###')) { $webRoot = str_replace('###PATH_site###', Environment::getPublicPath() . '/', $webRoot); } diff --git a/Classes/Typo3PageContentExtractor.php b/Classes/Typo3PageContentExtractor.php index 8e1a7d0c96..d716bf9cc1 100644 --- a/Classes/Typo3PageContentExtractor.php +++ b/Classes/Typo3PageContentExtractor.php @@ -18,9 +18,10 @@ use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager; use DOMDocument; use DOMXPath; -use function libxml_use_internal_errors; use TYPO3\CMS\Core\Utility\GeneralUtility; +use function libxml_use_internal_errors; + /** * Content extraction class for TYPO3 pages. * diff --git a/Classes/ViewHelpers/Backend/Security/IfHasAccessToModuleViewHelper.php b/Classes/ViewHelpers/Backend/Security/IfHasAccessToModuleViewHelper.php index 3ec80a9d01..e0efc1bfac 100644 --- a/Classes/ViewHelpers/Backend/Security/IfHasAccessToModuleViewHelper.php +++ b/Classes/ViewHelpers/Backend/Security/IfHasAccessToModuleViewHelper.php @@ -34,13 +34,13 @@ class IfHasAccessToModuleViewHelper extends AbstractConditionViewHelper * Message for that case, if $arguments['signature'] was used and module does not exist * @var string */ - const ERROR_APPENDIX_FOR_WRONG_SIGNATURE_ARGUMENT = 'Please check spelling and style by setting signature="mainName_ExtKeySubmoduleName".'; + public const ERROR_APPENDIX_FOR_WRONG_SIGNATURE_ARGUMENT = 'Please check spelling and style by setting signature="mainName_ExtKeySubmoduleName".'; /** * Message for that case, if $arguments['extension'], $arguments['main'] and $arguments['sub'] are used and module couldn't be resolved * @var string */ - const ERROR_APPENDIX_FOR_SIGNATURE_RESOLUTION = 'It was generated by setting extension="%s", main="%s", sub="%s", please check spelling and style by setting this arguments.'; + public const ERROR_APPENDIX_FOR_SIGNATURE_RESOLUTION = 'It was generated by setting extension="%s", main="%s", sub="%s", please check spelling and style by setting this arguments.'; /** * Initializes following arguments: extension, main, sub, signature diff --git a/Tests/Integration/ConnectionManagerTest.php b/Tests/Integration/ConnectionManagerTest.php index 268e5e5bad..8b5cf00823 100644 --- a/Tests/Integration/ConnectionManagerTest.php +++ b/Tests/Integration/ConnectionManagerTest.php @@ -20,6 +20,7 @@ use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection; use ReflectionException; use TYPO3\CMS\Core\Utility\GeneralUtility; + use function vsprintf; /** diff --git a/Tests/Integration/Controller/SearchControllerTest.php b/Tests/Integration/Controller/SearchControllerTest.php index 44113308c2..5d42675a0f 100644 --- a/Tests/Integration/Controller/SearchControllerTest.php +++ b/Tests/Integration/Controller/SearchControllerTest.php @@ -1395,7 +1395,7 @@ public function canRenderAsUserObjectWithCustomEntryTemplateInTypoScript() */ protected function getIdContent($content, $id) { - if (strpos($content, $id) === false) { + if (!str_contains($content, $id)) { return ''; } diff --git a/Tests/Integration/IntegrationTest.php b/Tests/Integration/IntegrationTest.php index 91417ff3b5..f1496c5a52 100644 --- a/Tests/Integration/IntegrationTest.php +++ b/Tests/Integration/IntegrationTest.php @@ -23,7 +23,6 @@ use Doctrine\DBAL\Driver\Exception as DBALDriverException; use Doctrine\DBAL\Exception as DoctrineDBALException; use Doctrine\DBAL\Schema\SchemaException; -use function getenv; use InvalidArgumentException; use ReflectionClass; use ReflectionException; @@ -55,6 +54,8 @@ use TYPO3\TestingFramework\Core\Exception as TestingFrameworkCoreException; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; +use function getenv; + /** * Base class for all integration tests in the EXT:solr project * @@ -573,7 +574,7 @@ protected function failWhenSolrDeprecationIsCreated(): void { error_reporting(error_reporting() & ~E_USER_DEPRECATED); set_error_handler(function ($id, $msg) { - if ($id === E_USER_DEPRECATED && strpos($msg, 'solr:deprecation: ') === 0) { + if ($id === E_USER_DEPRECATED && str_starts_with($msg, 'solr:deprecation: ')) { $this->fail('Executed deprecated EXT:solr code: ' . $msg); } }); diff --git a/Tests/Unit/Domain/Search/ApacheSolrDocument/BuilderTest.php b/Tests/Unit/Domain/Search/ApacheSolrDocument/BuilderTest.php index 9c1206501b..eb86918e4f 100644 --- a/Tests/Unit/Domain/Search/ApacheSolrDocument/BuilderTest.php +++ b/Tests/Unit/Domain/Search/ApacheSolrDocument/BuilderTest.php @@ -31,7 +31,7 @@ */ class BuilderTest extends UnitTest { - const FAKE_PAGE_RECORD = [ + public const FAKE_PAGE_RECORD = [ 'pid' => 4710, 'crdate' => 1635537721, 'SYS_LASTCHANGED' => 1635537721, diff --git a/Tests/Unit/Domain/Search/FrequentSearches/FrequentSearchesServiceTest.php b/Tests/Unit/Domain/Search/FrequentSearches/FrequentSearchesServiceTest.php index 19f4a2539d..5bc4924c51 100644 --- a/Tests/Unit/Domain/Search/FrequentSearches/FrequentSearchesServiceTest.php +++ b/Tests/Unit/Domain/Search/FrequentSearches/FrequentSearchesServiceTest.php @@ -62,7 +62,7 @@ protected function setUp(): void $this->cacheMock = $this->getDumbMock(AbstractFrontend::class); $this->configurationMock = $this->getDumbMock(TypoScriptConfiguration::class); - $this->frequentSearchesService = new class($this->configurationMock, $this->cacheMock, $this->tsfeMock, $this->statisticsRepositoryMock) extends FrequentSearchesService { + $this->frequentSearchesService = new class ($this->configurationMock, $this->cacheMock, $this->tsfeMock, $this->statisticsRepositoryMock) extends FrequentSearchesService { // protected function getCacheIdentifier(array $frequentSearchConfiguration) : string { // $identifier = 'frequentSearchesTags'; // if (isset($frequentSearchConfiguration['select.']['checkRootPageId']) && $frequentSearchConfiguration['select.']['checkRootPageId']) { diff --git a/Tests/Unit/Domain/Search/Query/QueryBuilderTest.php b/Tests/Unit/Domain/Search/Query/QueryBuilderTest.php index 5f0bc4cfd7..4e34d4954f 100644 --- a/Tests/Unit/Domain/Search/Query/QueryBuilderTest.php +++ b/Tests/Unit/Domain/Search/Query/QueryBuilderTest.php @@ -39,6 +39,7 @@ use ApacheSolrForTypo3\Solr\Tests\Unit\UnitTest; use PHPUnit\Framework\MockObject\MockObject; use Solarium\QueryType\Select\RequestBuilder; + use function str_starts_with; /** diff --git a/Tests/Unit/Domain/Search/Suggest/SuggestServiceTest.php b/Tests/Unit/Domain/Search/Suggest/SuggestServiceTest.php index f9da2fadd8..513301509e 100644 --- a/Tests/Unit/Domain/Search/Suggest/SuggestServiceTest.php +++ b/Tests/Unit/Domain/Search/Suggest/SuggestServiceTest.php @@ -139,7 +139,7 @@ public function canHandleInvalidSyntaxInAdditionalFilters() $connectionManagerMock->expects(self::any())->method('getConnectionByPageId')->willReturn($solrConnectionMock); GeneralUtility::setSingletonInstance(ConnectionManager::class, $connectionManagerMock); - $searchStub = new class($this->getDumbMock(SolrConnection::class)) extends Search implements SingletonInterface { + $searchStub = new class ($this->getDumbMock(SolrConnection::class)) extends Search implements SingletonInterface { public static $suggestServiceTest; public function search(Query $query, $offset = 0, $limit = 10): ?ResponseAdapter { diff --git a/Tests/Unit/IndexQueue/AbstractIndexerTest.php b/Tests/Unit/IndexQueue/AbstractIndexerTest.php index ea60ae2e54..a2a8faecca 100644 --- a/Tests/Unit/IndexQueue/AbstractIndexerTest.php +++ b/Tests/Unit/IndexQueue/AbstractIndexerTest.php @@ -103,7 +103,7 @@ public function isSerializedValueCanHandleCustomValidSerializedValueDetector() */ public function resolveFieldValue(array $indexingConfiguration, string $solrFieldName, array $data, $expectedValue) { - $subject = new class() extends AbstractIndexer { + $subject = new class () extends AbstractIndexer { }; $tsfe = $this->getDumbMock(TypoScriptFrontendController::class); self::assertEquals( diff --git a/Tests/Unit/Middleware/SolrRoutingMiddlewareTest.php b/Tests/Unit/Middleware/SolrRoutingMiddlewareTest.php index 13d28f0ccf..51853de58f 100644 --- a/Tests/Unit/Middleware/SolrRoutingMiddlewareTest.php +++ b/Tests/Unit/Middleware/SolrRoutingMiddlewareTest.php @@ -58,7 +58,7 @@ protected function setUp(): void ->getMock(); /* @see \TYPO3\CMS\Frontend\Tests\Unit\Middleware\PageResolverTest::setUp */ - $this->responseOutputHandler = new class() implements RequestHandlerInterface { + $this->responseOutputHandler = new class () implements RequestHandlerInterface { /** * @var ServerRequestInterface */ diff --git a/Tests/Unit/Query/Modifier/FacetingTest.php b/Tests/Unit/Query/Modifier/FacetingTest.php index 8a7b92f49a..5a1cd792e8 100644 --- a/Tests/Unit/Query/Modifier/FacetingTest.php +++ b/Tests/Unit/Query/Modifier/FacetingTest.php @@ -30,12 +30,13 @@ use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration; use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager; use ApacheSolrForTypo3\Solr\Tests\Unit\UnitTest; -use function json_decode; use PHPUnit\Framework\MockObject\MockObject; use Solarium\QueryType\Select\RequestBuilder; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; +use function json_decode; + /** * Tests the ApacheSolrForTypo3\Solr\Query\Modifier\Faceting class * @@ -641,7 +642,7 @@ public function testCanAddQueryFiltersContainingPlusSign() */ public function getFiltersByFacetNameCanHandleAssocUrlParameterStyle() { - $facetingModifierStub = new class($this->getDumbMock(FacetRegistry::class)) extends Faceting { + $facetingModifierStub = new class ($this->getDumbMock(FacetRegistry::class)) extends Faceting { public function callGetFiltersByFacetName(array $resultParameters, array $allFacets): array { return parent::getFiltersByFacetName($resultParameters, $allFacets); diff --git a/composer.json b/composer.json index 53200187f7..827336da45 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "typo3/cms-tstemplate": "*" }, "require-dev": { - "typo3/coding-standards": "~0.6.1", + "typo3/coding-standards": "~0.7.1", "phpunit/phpunit": "^9.5", "phpspec/prophecy-phpunit":"*", "typo3/testing-framework": "dev-main",