Skip to content

Commit

Permalink
Merge 1313bde into b7b899a
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored Mar 15, 2023
2 parents b7b899a + 1313bde commit cd3f0ba
Show file tree
Hide file tree
Showing 72 changed files with 451 additions and 285 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,28 @@ jobs:
- php-version: '7.2'
coverage: false
dependency-versions: 'lowest'
tools: 'composer:v1'
env:
SYMFONY_DEPRECATIONS_HELPER: disabled

- php-version: '7.4'
coverage: true
coverage: false
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: weak

- php-version: '8.0'
coverage: false
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: weak

- php-version: '8.1'
coverage: true
dependency-versions: 'highest'
env:
SYMFONY_DEPRECATIONS_HELPER: weak

- php-version: '8.2'
coverage: false
dependency-versions: 'highest'
env:
Expand All @@ -67,7 +70,7 @@ jobs:
php-version: ${{ matrix.php-version }}
extensions: ctype, iconv, mysql
coverage: pcov
tools: ${{ matrix.tools }}
tools: 'composer:v2'

- name: Install composer dependencies
uses: ramsey/composer-install@v2
Expand Down
2 changes: 1 addition & 1 deletion Content/Domain/Model/ContentRichEntityInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
interface ContentRichEntityInterface
{
/**
* @return mixed
* @return int|string
*/
public function getId();

Expand Down
17 changes: 10 additions & 7 deletions Content/Domain/Model/DimensionContentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@
use Doctrine\Common\Collections\Criteria;

/**
* @implements \IteratorAggregate<DimensionContentInterface>
* @template T of DimensionContentInterface
*
* @implements \IteratorAggregate<T>
* @implements DimensionContentCollectionInterface<T>
*/
class DimensionContentCollection implements \IteratorAggregate, DimensionContentCollectionInterface
{
/**
* @var ArrayCollection<int, DimensionContentInterface>
* @var ArrayCollection<int, T>
*/
private $dimensionContents;

/**
* @var DimensionContentInterface|null
* @var T|null
*/
private $unlocalizedDimensionContent;

/**
* @var DimensionContentInterface|null
* @var T|null
*/
private $localizedDimensionContent;

Expand All @@ -42,7 +45,7 @@ class DimensionContentCollection implements \IteratorAggregate, DimensionContent
private $dimensionAttributes;

/**
* @var class-string<DimensionContentInterface>
* @var class-string<T>
*/
private $dimensionContentClass;

Expand All @@ -54,9 +57,9 @@ class DimensionContentCollection implements \IteratorAggregate, DimensionContent
/**
* DimensionContentCollection constructor.
*
* @param DimensionContentInterface[] $dimensionContents
* @param T[] $dimensionContents
* @param mixed[] $dimensionAttributes
* @param class-string<DimensionContentInterface> $dimensionContentClass
* @param class-string<T> $dimensionContentClass
*/
public function __construct(
array $dimensionContents,
Expand Down
8 changes: 6 additions & 2 deletions Content/Domain/Model/DimensionContentCollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@
namespace Sulu\Bundle\ContentBundle\Content\Domain\Model;

/**
* @extends \Traversable<DimensionContentInterface>
* @template-covariant T of DimensionContentInterface
*
* @extends \Traversable<T>
*/
interface DimensionContentCollectionInterface extends \Traversable, \Countable
{
/**
* @param mixed[] $dimensionAttributes
*
* @return T|null
*/
public function getDimensionContent(array $dimensionAttributes): ?DimensionContentInterface;

/**
* @return class-string<DimensionContentInterface>
* @return class-string<T>
*/
public function getDimensionContentClass(): string;

Expand Down
8 changes: 4 additions & 4 deletions Content/Domain/Model/ExcerptInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@ public function getExcerptTagNames(): array;
public function setExcerptTags(array $excerptTags): void;

/**
* @return mixed[]|null
* @return array{id: int}|null
*/
public function getExcerptImage(): ?array;

/**
* @param mixed[]|null $excerptImage
* @param array{id: int}|null $excerptImage
*/
public function setExcerptImage(?array $excerptImage): void;

/**
* @return mixed[]|null
* @return array{id: int}|null
*/
public function getExcerptIcon(): ?array;

/**
* @param mixed[]|null $excerptIcon
* @param array{id: int}|null $excerptIcon
*/
public function setExcerptIcon(?array $excerptIcon): void;
}
8 changes: 4 additions & 4 deletions Content/Domain/Model/ExcerptTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function setExcerptTags(array $excerptTags): void
}

/**
* @return mixed[]|null
* @return array{id: int}|null
*/
public function getExcerptImage(): ?array
{
Expand All @@ -173,15 +173,15 @@ public function getExcerptImage(): ?array
}

/**
* @param mixed[]|null $excerptImage
* @param array{id: int}|null $excerptImage
*/
public function setExcerptImage(?array $excerptImage): void
{
$this->excerptImageId = $excerptImage['id'] ?? null;
}

/**
* @return mixed[]|null
* @return array{id: int}|null
*/
public function getExcerptIcon(): ?array
{
Expand All @@ -195,7 +195,7 @@ public function getExcerptIcon(): ?array
}

/**
* @param mixed[]|null $excerptIcon
* @param array{id: int}|null $excerptIcon
*/
public function setExcerptIcon(?array $excerptIcon): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ public function findByFilters($filters, $page, $pageSize, $limit, $locale, $opti
return \array_filter(
\array_map(
function(ContentRichEntityInterface $contentRichEntity) use ($locale, $showUnpublished) {
$stage = $showUnpublished
? DimensionContentInterface::STAGE_DRAFT
: DimensionContentInterface::STAGE_LIVE;
$stage = $showUnpublished ? DimensionContentInterface::STAGE_DRAFT : DimensionContentInterface::STAGE_LIVE;

$resolvedDimensionContent = $this->contentManager->resolve(
$contentRichEntity,
Expand Down
13 changes: 8 additions & 5 deletions Content/Infrastructure/Sulu/Structure/ContentStructureBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ContentStructureBridge implements StructureInterface, RoutableStructureInt
protected $content;

/**
* @var string
* @var string|int
*/
protected $id;

Expand All @@ -58,11 +58,14 @@ class ContentStructureBridge implements StructureInterface, RoutableStructureInt
*/
private $loadedProperties = [];

/**
* @param string|int $id
*/
public function __construct(
StructureMetadata $structure,
LegacyPropertyFactory $propertyFactory,
TemplateInterface $content,
string $id,
$id,
string $locale
) {
$this->structure = $structure;
Expand Down Expand Up @@ -108,11 +111,11 @@ public function getWebspaceKey(): ?string
}

/**
* @return mixed
* @return string
*/
public function getUuid()
{
return $this->id;
return (string) $this->id;
}

public function setUuid($uuid): void
Expand Down Expand Up @@ -432,7 +435,7 @@ public function getOriginTemplate(): ?string
}

/**
* @param mixed $name
* @param string $name
*
* @return mixed
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(StructureMetadataFactoryInterface $structureMetadata
}

/**
* @param mixed $id
* @param string|int $id
*/
public function getBridge(TemplateInterface $object, $id, string $locale): ContentStructureBridge
{
Expand Down
19 changes: 10 additions & 9 deletions Content/Infrastructure/Sulu/Teaser/ContentTeaserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function __construct(
}

/**
* @param mixed[] $ids
* @param array<int|string> $ids
* @param string $locale
*
* @return Teaser[]
Expand Down Expand Up @@ -115,7 +115,7 @@ function(ContentRichEntityInterface $contentRichEntity) use ($locale): ?Teaser {
}

/**
* @param mixed[] $data
* @param array<string, mixed> $data
*/
protected function createTeaser(DimensionContentInterface $dimensionContent, array $data, string $locale): ?Teaser
{
Expand All @@ -129,10 +129,10 @@ protected function createTeaser(DimensionContentInterface $dimensionContent, arr
$title = $this->getTitle($dimensionContent, $data);

/** @var string $description */
$description = $this->getDescription($dimensionContent, $data);
$description = $this->getDescription($dimensionContent, $data); // @phpstan-ignore-line

/** @var string $moreText */
$moreText = $this->getMoreText($dimensionContent, $data);
$moreText = $this->getMoreText($dimensionContent, $data); // @phpstan-ignore-line

/** @var int $mediaId */
$mediaId = $this->getMediaId($dimensionContent, $data);
Expand Down Expand Up @@ -195,7 +195,7 @@ protected function getUrl(DimensionContentInterface $dimensionContent, array $da

foreach ($metadata->getProperties() as $property) {
if ('route' === $property->getType()) {
return $dimensionContent->getTemplateData()[$property->getName()] ?? null;
return $dimensionContent->getTemplateData()[$property->getName()] ?? null; // @phpstan-ignore-line
}
}

Expand All @@ -217,7 +217,7 @@ protected function getTitle(DimensionContentInterface $dimensionContent, array $
}

/**
* @param mixed[] $data
* @param array{description?: string|null} $data
*/
protected function getDescription(DimensionContentInterface $dimensionContent, array $data): ?string
{
Expand All @@ -231,7 +231,7 @@ protected function getDescription(DimensionContentInterface $dimensionContent, a
}

/**
* @param mixed[] $data
* @param array{more?: string|null, moreText?: string|null} $data
*/
protected function getMoreText(DimensionContentInterface $dimensionContent, array $data): ?string
{
Expand All @@ -252,7 +252,7 @@ protected function getMediaId(DimensionContentInterface $dimensionContent, array
if ($dimensionContent instanceof ExcerptInterface) {
if ($excerptImage = $dimensionContent->getExcerptImage()) {
// TODO FIXME create unit test for this
return $excerptImage['id'] ?? null; // @codeCoverageIgnore
return $excerptImage['id']; // @codeCoverageIgnore
}
}

Expand All @@ -270,7 +270,7 @@ protected function getAttributes(DimensionContentInterface $dimensionContent, ar
}

/**
* @param mixed[] $ids
* @param array<int|string> $ids
*
* @return ContentRichEntityInterface[]
*/
Expand All @@ -279,6 +279,7 @@ protected function findEntitiesByIds(array $ids): array
$entityIdField = $this->getEntityIdField();
$classMetadata = $this->entityManager->getClassMetadata($this->contentRichEntityClass);

/** @var ContentRichEntityInterface[] $entities */
$entities = $this->entityManager->createQueryBuilder()
->select(self::CONTENT_RICH_ENTITY_ALIAS)
->from($this->contentRichEntityClass, self::CONTENT_RICH_ENTITY_ALIAS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function prepend(ContainerBuilder $container): void
if ($container->hasExtension('sulu_search')) {
$suluSearchConfigs = $container->getExtensionConfig('sulu_search');

/** @var array{website?: array{ indexes?: array<string, string> }} $suluSearchConfig */
foreach ($suluSearchConfigs as $suluSearchConfig) {
if (isset($suluSearchConfig['website']['indexes'])) {
$container->prependExtensionConfig(
Expand Down
4 changes: 2 additions & 2 deletions Tests/Application/ExampleTestBundle/Entity/Example.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class Example implements ContentRichEntityInterface
public const TEMPLATE_TYPE = 'example';

/**
* @var mixed
* @var int|string
*/
public $id;

/**
* @return mixed
* @return int|string
*/
public function getId()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getTemplateData(): array

public function setTemplateData(array $templateData): void
{
$this->setTitle($templateData['title']);
$this->setTitle($templateData['title']); // @phpstan-ignore-line
unset($templateData['title']);
$this->parentSetTemplateData($templateData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public function getConfiguration(): TeaserConfiguration
);
}

/**
* @param array{
* article?: string|null,
* description?: string|null,
* } $data
*/
protected function getDescription(DimensionContentInterface $dimensionContent, array $data): ?string
{
$article = \strip_tags($data['article'] ?? '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ private function createContentRichEntity(): Example
}

/**
* @param mixed[] $dimensionAttributes
* @param array{
* stage?: string,
* locale?: string,
* } $dimensionAttributes
*/
private function createContentDimension(Example $example, array $dimensionAttributes = []): ExampleDimensionContent
{
Expand Down
Loading

0 comments on commit cd3f0ba

Please sign in to comment.