Skip to content

Commit

Permalink
fix phpstan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Jan 6, 2025
1 parent 617289b commit 4473414
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 43 deletions.
7 changes: 0 additions & 7 deletions src/Controller/SearchFrontendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,6 @@ protected function renderFrontendSearch(Request $request, string $outputChannelN
$blocks = [];
if ($outputChannelResult instanceof MultiOutputChannelResultInterface) {
foreach ($outputChannelResult->getResults() as $resultBlockIdentifier => $resultBlock) {
if (!$resultBlock instanceof OutputChannelResultInterface) {
return $this->renderTemplate($viewName, [
'has_error' => true,
'error_message' => sprintf('output channel "%s" for context "%s" should return OutputChannelResultInterface.', $outputChannelName, $contextName)
]);
}

$blocks[$resultBlockIdentifier] = $this->prepareQueryVars($resultBlock);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,13 @@ private function buildContextOutputChannelsNode(): NodeDefinition
->end()
->beforeNormalization()
->ifTrue(function ($values) {
return isset($values['multiple'], $values['runtime_options_builder']) && $values['multiple'] === true && $values['runtime_options_builder'] !== null;
return isset($values['multiple'], $values['runtime_options_builder']) && $values['multiple'] === true;
})
->thenInvalid('Unrecognized multi search option "runtime_options_builder"')
->end()
->beforeNormalization()
->ifTrue(function ($values) {
return isset($values['use_frontend_controller'], $values['view_name']) && $values['use_frontend_controller'] !== true && $values['view_name'] !== null;
return isset($values['use_frontend_controller'], $values['view_name']) && $values['use_frontend_controller'] !== true;
})
->thenInvalid('Unrecognized option "view_name" in a non frontend controller based output channel')
->end()
Expand All @@ -223,7 +223,7 @@ private function buildContextOutputChannelsNode(): NodeDefinition
return $values;
}

if (isset($values['view_name']) && $values['view_name'] !== null) {
if (isset($values['view_name'])) {
return $values;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Document/Definition/DocumentDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function addOptionFieldDefinition(array $definition): static

public function getOptionFieldDefinitions(): array
{
return !is_array($this->optionFieldDefinitions) ? [] : $this->optionFieldDefinitions;
return $this->optionFieldDefinitions;
}

public function addSimpleDocumentFieldDefinition(array $definition): static
Expand Down
4 changes: 2 additions & 2 deletions src/Document/IndexDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function addIndexField(IndexFieldContainerInterface $fieldContainer): voi

public function hasIndexFields(): bool
{
return is_array($this->indexFields) && count($this->indexFields) > 0;
return count($this->indexFields) > 0;
}

/**
Expand All @@ -57,7 +57,7 @@ public function getIndexFields(): array

public function hasOptionFields(): bool
{
return is_array($this->optionFields) && count($this->optionFields) > 0;
return count($this->optionFields) > 0;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/PimcoreElementListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function onObjectPostUpdate(DataObjectEvent $event): void
return;
}

/** @var DataObject\Concrete $object */
/** @var ElementInterface $object */
$object = $event->getObject();

// @deprecated since 5.0: published/unpublished must be handled by project-specific resource validation
Expand Down
4 changes: 2 additions & 2 deletions src/Filter/Definition/FilterDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class FilterDefinition implements FilterDefinitionInterface
{
protected array $filterDefinitions;
protected array $filterDefinitions = [];

public function addFilterDefinition(array $definition): static
{
Expand Down Expand Up @@ -36,6 +36,6 @@ public function addFilterDefinition(array $definition): static

public function getFilterDefinitions(): array
{
return !is_array($this->filterDefinitions) ? [] : $this->filterDefinitions;
return $this->filterDefinitions;
}
}
4 changes: 0 additions & 4 deletions src/Manager/OutputChannelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ public function getOutputChannel(ContextDefinitionInterface $contextDefinition,
return null;
}

if (!is_string($outputChannelServiceName)) {
throw new ProviderException(sprintf('Invalid requested index output channel service "%s"', $outputChannelName));
}

if (!$this->outputChannelRegistry->hasOutputChannelService($outputChannelServiceName)) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Paginator/Adapter/DynamicSearchAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DynamicSearchAdapter implements AdapterInterface
{
protected ContextDefinitionInterface $contextDefinition;
protected string $outputChannelName;
protected DocumentNormalizerInterface $documentNormalizer;
protected ?DocumentNormalizerInterface $documentNormalizer = null;
protected RawResultInterface $rawResult;
protected int $itemCountPerPage;
protected int $currentPageNumber;
Expand Down
2 changes: 1 addition & 1 deletion src/Processor/OutputChannelProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected function buildMulti(
$subOutputChannelIdentifier = $searchContainer->getIdentifier();

$filter = $filters[$subOutputChannelIdentifier];
/** @var SubOutputChannelContextInterface $subOutputChannelContext */
/** @var OutputChannelContext $subOutputChannelContext */
$subOutputChannelContext = $subContexts[$subOutputChannelIdentifier];

if (!array_key_exists($subOutputChannelIdentifier, $outputChannelBlocks)) {
Expand Down
10 changes: 0 additions & 10 deletions src/Processor/ResourceDeletionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ public function process(ContextDefinitionInterface $contextDefinition, $resource
}

foreach ($normalizedResourceStack as $normalizedResource) {
if (!$normalizedResource instanceof NormalizedDataResourceInterface) {
$this->logger->error(
sprintf('Normalized resource needs to be instance of %s. Skipping...', NormalizedDataResourceInterface::class),
$contextDefinition->getDataProviderName(),
$contextDefinition->getName()
);

continue;
}

$resourceMeta = $normalizedResource->getResourceMeta();
if (empty($resourceMeta->getDocumentId())) {
$this->logger->error(
Expand Down
10 changes: 0 additions & 10 deletions src/Processor/ResourceModificationProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@ public function process(ContextDefinitionInterface $contextDefinition, $resource
}

foreach ($normalizedResourceStack as $normalizedResource) {
if (!$normalizedResource instanceof NormalizedDataResourceInterface) {
$this->logger->error(
sprintf('Normalized resource needs to be instance of %s. Skipping...', NormalizedDataResourceInterface::class),
$contextDefinition->getDataProviderName(),
$contextDefinition->getName()
);

continue;
}

$resourceMeta = $normalizedResource->getResourceMeta();
if (empty($resourceMeta->getDocumentId())) {
$this->logger->error(
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Extension/ProviderBundleLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected function findBundlesInPaths(array $paths): array

protected function processBundleClass(?string $bundle, array &$result): void
{
if (empty($bundle) || !is_string($bundle)) {
if (empty($bundle)) {
return;
}

Expand Down

0 comments on commit 4473414

Please sign in to comment.