Skip to content

Commit

Permalink
Fix phpstan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Nov 12, 2019
1 parent cb36d7e commit d87468f
Show file tree
Hide file tree
Showing 26 changed files with 111 additions and 112 deletions.
6 changes: 3 additions & 3 deletions Content/Application/Message/CreateContentMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class CreateContentMessage
private $data;

/**
* @var array<string, string|int|float|bool|null>
* @var mixed[]
*/
private $dimensionAttributes;

/**
* @param mixed[] $data
* @param array<string, string|int|float|bool|null> $dimensionAttributes
* @param mixed[] $dimensionAttributes
*/
public function __construct(ContentInterface $content, array $data, array $dimensionAttributes)
{
Expand All @@ -57,7 +57,7 @@ public function getData(): array
}

/**
* @return array<string, string|int|float|bool|null>
* @return mixed[]
*/
public function getDimensionAttributes(): array
{
Expand Down
6 changes: 3 additions & 3 deletions Content/Application/Message/LoadContentMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class LoadContentMessage
private $content;

/**
* @var array<string, string|int|float|bool|null>
* @var mixed[]
*/
private $dimensionAttributes;

/**
* @param array<string, string|int|float|bool|null> $dimensionAttributes
* @param mixed[] $dimensionAttributes
*/
public function __construct(ContentInterface $content, array $dimensionAttributes)
{
Expand All @@ -42,7 +42,7 @@ public function getContent(): ContentInterface
}

/**
* @return array<string, string|int|float|bool|null>
* @return mixed[]
*/
public function getDimensionAttributes(): array
{
Expand Down
6 changes: 3 additions & 3 deletions Content/Application/Message/ModifyContentMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class ModifyContentMessage
private $data;

/**
* @var array<string, string|int|float|bool|null>
* @var mixed[]
*/
private $dimensionAttributes;

/**
* @param mixed[] $data
* @param array<string, string|int|float|bool|null> $dimensionAttributes
* @param mixed[] $dimensionAttributes
*/
public function __construct(ContentInterface $content, array $data, array $dimensionAttributes)
{
Expand All @@ -57,7 +57,7 @@ public function getData(): array
}

/**
* @return array<string, string|int|float|bool|null>
* @return mixed[]
*/
public function getDimensionAttributes(): array
{
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 array<string, int|string|null>|null
* @return mixed[]|null
*/
public function getExcerptImage(): ?array;

/**
* @param array<string, int|string|null>|null $excerptImage
* @param mixed[]|null $excerptImage
*/
public function setExcerptImage(?array $excerptImage): void;

/**
* @return array<string, int|string|null>|null
* @return mixed[]|null
*/
public function getExcerptIcon(): ?array;

/**
* @param array<string, int|string|null>|null $excerptIcon
* @param mixed[]|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 array{id: int}|null
* @return mixed[]|null
*/
public function getExcerptImage(): ?array
{
Expand All @@ -173,15 +173,15 @@ public function getExcerptImage(): ?array
}

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

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

/**
* @param array{id: int}|null $excerptIcon
* @param mixed[]|null $excerptIcon
*/
public function setExcerptIcon(?array $excerptIcon): void
{
Expand Down
2 changes: 1 addition & 1 deletion Dimension/Domain/Factory/DimensionCollectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(DimensionRepositoryInterface $dimensionRepository)
}

/**
* @param array<string, string|int|float|bool|null> $dimensionAttributes
* @param mixed[] $dimensionAttributes
*/
public function create(array $dimensionAttributes): DimensionCollectionInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
interface DimensionCollectionFactoryInterface
{
/**
* @param array<string, string|int|float|bool|null> $dimensionAttributes
* @param mixed[] $dimensionAttributes
*/
public function create(array $dimensionAttributes): DimensionCollectionInterface;
}
18 changes: 9 additions & 9 deletions Dimension/Domain/Model/DimensionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
class DimensionCollection implements \IteratorAggregate, DimensionCollectionInterface
{
/**
* @var array<string, string|int|float|bool,null>
* @var mixed[]
*/
private $attributes;

/**
* @var array<string, string|int|float|bool,null>|null
* @var mixed[]|null
*/
private $localizedAttributes;

/**
* @var array<string, string|int|float|bool,null>
* @var mixed[]
*/
private $unlocalizedAttributes;

Expand All @@ -49,7 +49,7 @@ class DimensionCollection implements \IteratorAggregate, DimensionCollectionInte
private $unlocalizedDimension;

/**
* @param array<string, string|int|float|bool,null> $attributes
* @param mixed[] $attributes
* @param DimensionInterface[] $dimensions
*/
public function __construct(array $attributes, array $dimensions)
Expand All @@ -67,38 +67,38 @@ public function __construct(array $attributes, array $dimensions)

$criteria = Criteria::create();
foreach ($this->unlocalizedAttributes as $key => $value) {
$criteria->andWhere($criteria->expr()->eq($key, $value));
$criteria->andWhere($criteria->expr()->eq((string) $key, $value));
}

$this->unlocalizedDimension = $this->dimensions->matching($criteria)->first() ?: null;

if ($this->localizedAttributes) {
$criteria = Criteria::create();
foreach ($this->localizedAttributes as $key => $value) {
$criteria->andWhere($criteria->expr()->eq($key, $value));
$criteria->andWhere($criteria->expr()->eq((string) $key, $value));
}
$this->localizedDimension = $this->dimensions->matching($criteria)->first() ?: null;
}
}

/**
* @return array<string, string|int|float|bool,null>
* @return mixed[]
*/
public function getAttributes(): array
{
return $this->attributes;
}

/**
* @return array<string, string|int|float|bool,null>
* @return mixed[]
*/
public function getUnlocalizedAttributes(): array
{
return $this->unlocalizedAttributes;
}

/**
* @return array<string, string|int|float|bool,null>
* @return mixed[]
*/
public function getLocalizedAttributes(): ?array
{
Expand Down
6 changes: 3 additions & 3 deletions Dimension/Domain/Model/DimensionCollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
interface DimensionCollectionInterface extends \Traversable, \Countable
{
/**
* @return array<string, string|int|float|bool,null>|null
* @return mixed[]|null
*/
public function getLocalizedAttributes(): ?array;

/**
* @return array<string, string|int|float|bool,null>
* @return mixed[]
*/
public function getUnlocalizedAttributes(): array;

/**
* @return array<string, string|int|float|bool,null>
* @return mixed[]
*/
public function getAttributes(): array;

Expand Down
2 changes: 1 addition & 1 deletion Dimension/Domain/Model/DimensionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getLocale(): ?string;
public function getWorkflowStage(): string;

/**
* @return array<string, string|int|float|bool|null>
* @return mixed[]
*/
public function getAttributes(): array;

Expand Down
4 changes: 2 additions & 2 deletions Dimension/Domain/Repository/DimensionRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
interface DimensionRepositoryInterface
{
/**
* @param array<string, string|int|float|bool|null> $attributes
* @param mixed[] $attributes
*/
public function create(
?string $id = null,
Expand All @@ -31,7 +31,7 @@ public function add(DimensionInterface $directory): void;
public function remove(DimensionInterface $directory): void;

/**
* @param array<string, string|int|float|bool|null> $attributes
* @param mixed[] $attributes
*/
public function findByAttributes(array $attributes): DimensionCollectionInterface;

Expand Down
12 changes: 6 additions & 6 deletions Dimension/Infrastructure/Doctrine/DimensionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class DimensionRepository implements DimensionRepositoryInterface
{
/**
* @var class-string<DimensionInterface>
* @var string
*/
private $className;

Expand Down Expand Up @@ -98,17 +98,17 @@ public function findBy(array $criteria): iterable
/**
* Less specific should be returned first to merge correctly.
*
* @param array<string, string|int|float|bool|null> $attributes
* @param mixed[] $attributes
*/
private function addSortBy(QueryBuilder $queryBuilder, $attributes): void
private function addSortBy(QueryBuilder $queryBuilder, array $attributes): void
{
foreach ($attributes as $key => $value) {
$queryBuilder->addOrderBy('dimension.' . $key);
}
}

/**
* @param array<string, string|int|float|bool|null> $attributes
* @param mixed[] $attributes
*/
private function getAttributesCriteria(string $dimensionAlias, array $attributes): Criteria
{
Expand All @@ -130,9 +130,9 @@ private function getAttributesCriteria(string $dimensionAlias, array $attributes
}

/**
* @param array<string, string|int|float|bool|null> $attributes
* @param mixed[] $attributes
*
* @return array<string, string|int|float|bool|null>
* @return mixed[]
*/
private function getNormalizedAttributes(array $attributes): array
{
Expand Down
2 changes: 2 additions & 0 deletions TestCases/Content/ExcerptTestCaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function testGetSetExcerptImageId(): void
$model = $this->getExcerptInstance();
$this->assertNull($model->getExcerptImage());
$model->setExcerptImage(['id' => 1]);
$this->assertNotNull($model->getExcerptImage());
$this->assertSame(['id' => 1], $model->getExcerptImage());
}

Expand All @@ -63,6 +64,7 @@ public function testGetSetExcerptIconId(): void
$model = $this->getExcerptInstance();
$this->assertNull($model->getExcerptIcon());
$model->setExcerptIcon(['id' => 2]);
$this->assertNotNull($model->getExcerptIcon());
$this->assertSame(['id' => 2], $model->getExcerptIcon());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* with this source code in the file LICENSE.
*/

namespace Sulu\Bundle\ContentBundle\Tests\Content\Infrastructure\Doctrine;
namespace Sulu\Bundle\ContentBundle\Tests\Functional\Content\Infrastructure\Doctrine;

use Sulu\Bundle\CategoryBundle\Entity\CategoryInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Factory\CategoryFactoryInterface;
Expand All @@ -32,8 +32,10 @@ public function createCategoryFactory(): CategoryFactoryInterface

/**
* @dataProvider dataProvider
*
* @param int[] $categoryIds
*/
public function testCreate($categoryIds): void
public function testCreate(array $categoryIds): void
{
$categoryFactory = $this->createCategoryFactory();

Expand All @@ -48,7 +50,7 @@ function (CategoryInterface $category) {
);
}

public function dataProvider()
public function dataProvider(): \Generator
{
yield [
[
Expand Down
Loading

0 comments on commit d87468f

Please sign in to comment.