Skip to content

Commit

Permalink
Merge branch 'sulu:0.x' into feature/versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
redjanym authored May 16, 2024
2 parents 2de29d9 + 0b31497 commit e7ffcc4
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 39 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ jobs:
env:
SYMFONY_DEPRECATIONS_HELPER: weak

- php-version: '8.3'
coverage: false
dependency-versions: 'highest'
env:
SYMFONY_DEPRECATIONS_HELPER: weak

services:
mysql:
image: mysql:5.7
Expand Down Expand Up @@ -113,7 +119,7 @@ jobs:
- name: Install and configure PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.3
extensions: ctype, iconv, mysql

- name: Install composer dependencies
Expand Down
11 changes: 11 additions & 0 deletions Content/Application/ContentMerger/ContentMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentCollectionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface;
use Symfony\Component\PropertyAccess\PropertyAccessor;
use Webmozart\Assert\Assert;

class ContentMerger implements ContentMergerInterface
{
Expand All @@ -41,6 +42,13 @@ public function __construct(
$this->propertyAccessor = $propertyAccessor;
}

/**
* @template T of DimensionContentInterface
*
* @param DimensionContentCollectionInterface<T> $dimensionContentCollection
*
* @return T
*/
public function merge(DimensionContentCollectionInterface $dimensionContentCollection): DimensionContentInterface
{
if (!$dimensionContentCollection->count()) {
Expand All @@ -52,6 +60,7 @@ public function merge(DimensionContentCollectionInterface $dimensionContentColle
foreach ($dimensionContentCollection as $dimensionContent) {
if (!$mergedDimensionContent) {
$contentRichEntity = $dimensionContent->getResource();
/** @var T $mergedDimensionContent */
$mergedDimensionContent = $contentRichEntity->createDimensionContent();
$mergedDimensionContent->markAsMerged();
}
Expand All @@ -69,6 +78,8 @@ public function merge(DimensionContentCollectionInterface $dimensionContentColle
}
}

Assert::notNull($mergedDimensionContent);

return $mergedDimensionContent;
}
}
4 changes: 2 additions & 2 deletions Content/Domain/Model/TemplateInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public function getTemplateKey(): ?string;
public function setTemplateKey(string $templateKey): void;

/**
* @return mixed[]
* @return array<string, mixed>
*/
public function getTemplateData(): array;

/**
* @param mixed[] $templateData
* @param array<string, mixed> $templateData
*/
public function setTemplateData(array $templateData): void;
}
5 changes: 4 additions & 1 deletion Content/Domain/Model/TemplateTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait TemplateTrait
private $templateKey;

/**
* @var mixed[]
* @var array<string, mixed>
*/
private $templateData = [];

Expand All @@ -43,6 +43,9 @@ public function getTemplateData(): array
return $this->templateData;
}

/**
* @param array<string, mixed> $templateData
*/
public function setTemplateData(array $templateData): void
{
$this->templateData = $templateData;
Expand Down
4 changes: 3 additions & 1 deletion Content/Infrastructure/Sulu/Link/ContentLinkProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ public function preload(array $hrefs, $locale, $published = true): array
*/
protected function getTitle(DimensionContentInterface $dimensionContent, array $data): ?string
{
return $data['title'] ?? $data['name'] ?? null;
$title = $data['title'] ?? $data['name'] ?? null;

return \is_string($title) ? $title : null;
}

protected function getEntityIdField(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function getMaxPage($scheme, $host): int
{
$queryBuilder = $this->createRoutesQueryBuilder();
try {
$amount = $queryBuilder
$amount = (int) $queryBuilder
->select('COUNT(' . self::ROUTE_ALIAS . ')')
->getQuery()
->getSingleScalarResult();
Expand Down
6 changes: 4 additions & 2 deletions Content/Infrastructure/Sulu/Teaser/ContentTeaserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected function createTeaser(DimensionContentInterface $dimensionContent, arr

/**
* @param B $dimensionContent
* @param mixed[] $data
* @param array<string, mixed> $data
*/
protected function getTitle(DimensionContentInterface $dimensionContent, array $data): ?string
{
Expand All @@ -172,7 +172,9 @@ protected function getTitle(DimensionContentInterface $dimensionContent, array $
}
}

return $data['title'] ?? $data['name'] ?? null;
$title = $data['title'] ?? $data['name'] ?? null;

return \is_string($title) ? $title : null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,13 @@ public function getTitle(): ?string
return $this->title;
}

/**
* @param array<string, mixed> $templateData
*/
public function setTemplateData(array $templateData): void
{
if (\array_key_exists('title', $templateData)) {
$this->title = $templateData['title'];
$this->title = \is_string($templateData['title']) ? $templateData['title'] : null;
}

$this->parentSetTemplateData($templateData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function countBy(array $filters = []): int

$queryBuilder->select('COUNT(DISTINCT example.id)');

return (int) $queryBuilder->getQuery()->getSingleScalarResult(); // @phpstan-ignore-line
return (int) $queryBuilder->getQuery()->getSingleScalarResult();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function registerBundles(): iterable
return $bundles;
}

public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
parent::registerContainerConfiguration($loader);
$loader->load(__DIR__ . '/config/config_' . $this->getContext() . '.yml');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function testGetAlias(): void
/**
* @param SitemapUrl[] $sitemapEntries
*
* @return array<string, mixed>
* @return array<mixed>
*/
private function mapSitemapEntries(array $sitemapEntries): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public function testResolveDataItems(): void
/** @var int $expectedCount */
/** @var bool $expectedHasNextPage */
$dataProviderResult = $this->contentDataProvider->resolveDataItems(
$filters,
$filters, // @phpstan-ignore-line
[],
[
'locale' => $locale,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function testMapDefaultWebspace(): void

$webspace = new Webspace();
$webspace->setKey('default-webspace');
$this->webspaceCollection->setWebspaces([$webspace]);
$this->webspaceCollection->setWebspaces(['default-webspace' => $webspace]);

$authorMapper = $this->createWebspaceDataMapperInstance();
$authorMapper->map($unlocalizedDimensionContent, $localizedDimensionContent, $data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public function testGetValues(): void
$webspaceB->setKey('webspace-b');
$webspaceB->setName('Webspace B');
$webspaceCollection = new WebspaceCollection([
$webspaceA,
$webspaceB,
'webspace-a' => $webspaceA,
'webspace-b' => $webspaceB,
]);

$this->webspaceManager->getWebspaceCollection()
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"doctrine/inflector": "^1.4.1 || ^2.0.1",
"doctrine/collections": "^1.0",
"doctrine/orm": "^2.5.3",
"doctrine/persistence": "^1.3 || ^2.0",
"doctrine/persistence": "^1.3 || ^2.0 || ^3.0",
"doctrine/doctrine-bundle": "^1.10 || ^2.0",
"friendsofsymfony/rest-bundle": "^2.6 || ^3.0",
"massive/search-bundle": "^2.4",
Expand Down
22 changes: 0 additions & 22 deletions phpstan-baseline.neon

This file was deleted.

0 comments on commit e7ffcc4

Please sign in to comment.