Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update phpstan to new version #217

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: '7.2'
- php-version: '7.3'
coverage: false
dependency-versions: 'lowest'
env:
Expand All @@ -39,6 +39,12 @@ jobs:
env:
SYMFONY_DEPRECATIONS_HELPER: weak

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

services:
mysql:
image: mysql:5.7
Expand Down
20 changes: 16 additions & 4 deletions Content/Application/ContentCopier/ContentCopierInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@
interface ContentCopierInterface
{
/**
* @param mixed[] $sourceDimensionAttributes
* @param mixed[] $targetDimensionAttributes
* @param array{
* locale: string,
* stage?: string|null,
* } $sourceDimensionAttributes
* @param array{
* locale: string,
* stage?: string|null,
* } $targetDimensionAttributes
*/
public function copy(
ContentRichEntityInterface $sourceContentRichEntity,
Expand All @@ -31,7 +37,10 @@ public function copy(
): DimensionContentInterface;

/**
* @param mixed[] $targetDimensionAttributes
* @param array{
* locale: string,
* stage?: string|null,
* } $targetDimensionAttributes
*/
public function copyFromDimensionContentCollection(
DimensionContentCollectionInterface $dimensionContentCollection,
Expand All @@ -40,7 +49,10 @@ public function copyFromDimensionContentCollection(
): DimensionContentInterface;

/**
* @param mixed[] $targetDimensionAttributes
* @param array{
* locale: string,
* stage?: string|null,
* } $targetDimensionAttributes
*/
public function copyFromDimensionContent(
DimensionContentInterface $dimensionContent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ interface ContentDataMapperInterface
{
/**
* @param array<string, mixed> $data
* @param mixed[] $dimensionAttributes
* @param array{
* locale: string,
* stage?: string|null,
* } $dimensionAttributes
*/
public function map(
DimensionContentCollectionInterface $dimensionContentCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,20 @@ class RoutableDataMapper implements DataMapperInterface
private $conflictResolver;

/**
* @var array<string, array<mixed>>
* @var array<string, array{
* resource_key: string,
* entityClass: string|null,
* options: mixed[]|null,
* }>
*/
private $routeMappings;

/**
* @param array<string, array<mixed>> $routeMappings
* @param array<string, array{
* resource_key: string,
* entityClass: string|null,
* options: mixed[]|null,
* }> $routeMappings
*/
public function __construct(
StructureMetadataFactoryInterface $factory,
Expand Down Expand Up @@ -130,10 +138,10 @@ public function map(
throw new \RuntimeException(\sprintf('No route mapping found for "%s".', $resourceKey));
}

/** @var string|null $routePath */
$routePath = $data[$name] ?? null;

if (!$routePath) {
/** @var mixed $routeGenerationData */
$routeGenerationData = \array_merge(
$data,
[
Expand All @@ -153,15 +161,16 @@ public function map(
}

if (DimensionContentInterface::STAGE_LIVE === $localizedDimensionContent->getStage()) {
if (!$localizedDimensionContent->getResourceId()) {
$resourceId = $localizedDimensionContent->getResourceId();
if (!$resourceId) {
// TODO route bundle should work to update the entity later with a resourceId over UPDATE SQL statement
throw new \RuntimeException('Expected a LocalizedDimensionContent with a resourceId.');
}

// route should only be updated in live dimension
$route = $this->routeManager->createOrUpdateByAttributes(
$entityClass,
(string) $localizedDimensionContent->getResourceId(),
(string) $resourceId,
$locale,
$routePath,
false
Expand Down
33 changes: 18 additions & 15 deletions Content/Application/ContentDataMapper/DataMapper/SeoDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@

class SeoDataMapper implements DataMapperInterface
{
/**
* @param array{
* seoTitle?: string|null,
* seoDescription?: string|null,
* seoKeywords?: string|null,
* seoCanonicalUrl?: string|null,
* seoHideInSitemap?: bool,
* seoNoFollow?: bool,
* seoNoIndex?: bool,
* } $data
*/
public function map(
DimensionContentInterface $unlocalizedDimensionContent,
DimensionContentInterface $localizedDimensionContent,
Expand All @@ -27,20 +38,12 @@ public function map(
return;
}

$this->setSeoData($localizedDimensionContent, $data);
}

/**
* @param mixed[] $data
*/
private function setSeoData(SeoInterface $dimensionContent, array $data): void
{
$dimensionContent->setSeoTitle($data['seoTitle'] ?? null);
$dimensionContent->setSeoDescription($data['seoDescription'] ?? null);
$dimensionContent->setSeoKeywords($data['seoKeywords'] ?? null);
$dimensionContent->setSeoCanonicalUrl($data['seoCanonicalUrl'] ?? null);
$dimensionContent->setSeoHideInSitemap($data['seoHideInSitemap'] ?? false);
$dimensionContent->setSeoNoFollow($data['seoNoFollow'] ?? false);
$dimensionContent->setSeoNoIndex($data['seoNoIndex'] ?? false);
$localizedDimensionContent->setSeoTitle($data['seoTitle'] ?? null);
$localizedDimensionContent->setSeoDescription($data['seoDescription'] ?? null);
$localizedDimensionContent->setSeoKeywords($data['seoKeywords'] ?? null);
$localizedDimensionContent->setSeoCanonicalUrl($data['seoCanonicalUrl'] ?? null);
$localizedDimensionContent->setSeoHideInSitemap($data['seoHideInSitemap'] ?? false);
$localizedDimensionContent->setSeoNoFollow($data['seoNoFollow'] ?? false);
$localizedDimensionContent->setSeoNoIndex($data['seoNoIndex'] ?? false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@

class WorkflowDataMapper implements DataMapperInterface
{
/**
* @param array{
* published?: string|null,
* } $data
*/
public function map(
DimensionContentInterface $unlocalizedDimensionContent,
DimensionContentInterface $localizedDimensionContent,
Expand Down Expand Up @@ -73,6 +78,7 @@ private function setPublishedToLiveDimension(WorkflowInterface $object, array $d
return;
}

/** @var string|null $published */
$published = $data['published'] ?? null;

if (!$published) {
Expand Down
5 changes: 4 additions & 1 deletion Content/Application/ContentIndexer/ContentIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ public function deindexDimensionContent(DimensionContentInterface $dimensionCont
}

/**
* @param mixed[] $dimensionAttributes
* @param array{
* locale?: string|null,
* stage?: string|null,
* } $dimensionAttributes
*/
private function loadDimensionContent(
ContentRichEntityInterface $contentRichEntity,
Expand Down
12 changes: 9 additions & 3 deletions Content/Application/ContentIndexer/ContentIndexerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@
interface ContentIndexerInterface
{
/**
* @param mixed[] $dimensionAttributes
* @param array{
* locale?: string,
* stage?: string|null,
* } $dimensionAttributes
*/
public function index(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes): DimensionContentInterface;

public function indexDimensionContent(DimensionContentInterface $dimensionContent): void;

/**
* @param mixed $id
* @param mixed[] $dimensionAttributes
* @param int|string $id
* @param array{
* locale?: string,
* stage?: string|null,
* } $dimensionAttributes
*/
public function deindex(string $resourceKey, $id, array $dimensionAttributes = []): void;

Expand Down
37 changes: 29 additions & 8 deletions Content/Application/ContentManager/ContentManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@
interface ContentManagerInterface
{
/**
* @param mixed[] $dimensionAttributes
* @param array{
* locale: string,
* stage?: string|null,
* } $dimensionAttributes
*/
public function resolve(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes): DimensionContentInterface;

/**
* @param mixed[] $data
* @param mixed[] $dimensionAttributes
* @param array{
* locale: string,
* stage?: string|null,
* } $dimensionAttributes
*/
public function persist(ContentRichEntityInterface $contentRichEntity, array $data, array $dimensionAttributes): DimensionContentInterface;

Expand All @@ -35,8 +41,14 @@ public function persist(ContentRichEntityInterface $contentRichEntity, array $da
public function normalize(DimensionContentInterface $dimensionContent): array;

/**
* @param mixed[] $sourceDimensionAttributes
* @param mixed[] $targetDimensionAttributes
* @param array{
* locale: string,
* stage?: string|null,
* } $sourceDimensionAttributes
* @param array{
* locale: string,
* stage?: string|null,
* } $targetDimensionAttributes
*/
public function copy(
ContentRichEntityInterface $sourceContentRichEntity,
Expand All @@ -46,7 +58,10 @@ public function copy(
): DimensionContentInterface;

/**
* @param mixed[] $dimensionAttributes
* @param array{
* locale: string,
* stage?: string|null,
* } $dimensionAttributes
*/
public function applyTransition(
ContentRichEntityInterface $contentRichEntity,
Expand All @@ -55,13 +70,19 @@ public function applyTransition(
): DimensionContentInterface;

/**
* @param mixed[] $dimensionAttributes
* @param array{
* locale?: string,
* stage?: string|null,
* } $dimensionAttributes
*/
public function index(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes): DimensionContentInterface;

/**
* @param mixed $id
* @param mixed[] $dimensionAttributes
* @param int|string $id
* @param array{
* locale?: string,
* stage?: string|null,
* } $dimensionAttributes
*/
public function deindex(string $resourceKey, $id, array $dimensionAttributes = []): void;
}
8 changes: 2 additions & 6 deletions Content/Application/ContentMerger/Merger/ExcerptMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,11 @@ public function merge(object $targetObject, object $sourceObject): void
}

if ($excerptTags = $sourceObject->getExcerptTags()) {
if (!empty($excerptTags)) {
$targetObject->setExcerptTags($excerptTags);
}
$targetObject->setExcerptTags($excerptTags);
}

if ($excerptCategories = $sourceObject->getExcerptCategories()) {
if (!empty($excerptCategories)) {
$targetObject->setExcerptCategories($excerptCategories);
}
$targetObject->setExcerptCategories($excerptCategories);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\EntityManagerInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface;

class ContentMetadataInspector implements ContentMetadataInspectorInterface
{
Expand All @@ -33,6 +34,12 @@ public function getDimensionContentClass(string $contentRichEntityClass): string
$contentRichEntityClass = ClassUtils::getRealClass($contentRichEntityClass);

$classMetadata = $this->entityManager->getClassMetadata($contentRichEntityClass);

/**
* @var array{
* targetEntity: class-string<DimensionContentInterface>
* } $associationMapping
*/
$associationMapping = $classMetadata->getAssociationMapping('dimensionContents');

return $associationMapping['targetEntity'];
Expand All @@ -43,6 +50,12 @@ public function getDimensionContentPropertyName(string $contentRichEntityClass):
$contentRichEntityClass = ClassUtils::getRealClass($contentRichEntityClass);

$classMetadata = $this->entityManager->getClassMetadata($contentRichEntityClass);

/**
* @var array{
* mappedBy: string
* } $associationMapping
*/
$associationMapping = $classMetadata->getAssociationMapping('dimensionContents');

return $associationMapping['mappedBy'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

class TemplateNormalizer implements NormalizerInterface
{
/**
* @param array{
* templateKey: string,
* templateData: mixed[],
* } $normalizedData
*/
public function enhance(object $object, array $normalizedData): array
{
if (!$object instanceof TemplateInterface) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ interface ContentPersisterInterface
{
/**
* @param mixed[] $data
* @param mixed[] $dimensionAttributes
* @param array{
* locale: string,
* stage?: string|null,
* } $dimensionAttributes
*/
public function persist(ContentRichEntityInterface $contentRichEntity, array $data, array $dimensionAttributes): DimensionContentInterface;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
interface ContentResolverInterface
{
/**
* @param mixed[] $dimensionAttributes
* @param array{
* locale?: string|null,
* stage?: string|null,
* } $dimensionAttributes
*/
public function resolve(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes): DimensionContentInterface;
}