Skip to content

Commit

Permalink
fixes for latest PHPStan strict rules
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Jul 1, 2023
1 parent d7735d5 commit e8397bd
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/Mapper/Dbal/RelationshipMapperManyHasMany.php
Expand Up @@ -123,7 +123,6 @@ protected function execute(DbalCollection $collection, IEntity $parent): MultiEn
$builder = $collection->getQueryBuilder();

$cacheKey = $this->calculateCacheKey($builder, $values);
/** @var MultiEntityIterator|null $data */
$data = &$this->cacheEntityIterators[$cacheKey];

if ($data !== null) {
Expand Down Expand Up @@ -217,13 +216,13 @@ protected function executeCounts(DbalCollection $collection, IEntity $parent): a
$builder = $collection->getQueryBuilder();

$cacheKey = $this->calculateCacheKey($builder, $values);
/** @var array<int>|null $data */
$data = &$this->cacheCounts[$cacheKey];

if ($data !== null) {
return $data;
}

/** @noinspection PhpUnnecessaryLocalVariableInspection */
$data = $this->fetchCounts($builder, $values);
return $data;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mapper/Dbal/RelationshipMapperManyHasOne.php
Expand Up @@ -76,13 +76,13 @@ protected function execute(DbalCollection $collection, IEntity $parent): MultiEn
$builder = $collection->getQueryBuilder();

$cacheKey = $this->calculateCacheKey($builder, $values);
/** @var MultiEntityIterator|null $data */
$data = &$this->cacheEntityIterators[$cacheKey];

if ($data !== null) {
return $data;
}

/** @noinspection PhpUnnecessaryLocalVariableInspection */
$data = $this->fetch(clone $builder, $values);
return $data;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Mapper/Dbal/RelationshipMapperOneHasMany.php
Expand Up @@ -104,7 +104,6 @@ protected function execute(DbalCollection $collection, IEntity $parent): MultiEn
$builder = $collection->getQueryBuilder();

$cacheKey = $this->calculateCacheKey($builder, $values);
/** @var MultiEntityIterator|null $data */
$data = &$this->cacheEntityIterators[$cacheKey];

if ($data !== null) {
Expand Down Expand Up @@ -236,13 +235,13 @@ protected function executeCounts(DbalCollection $collection, IEntity $parent): a
$builder = $collection->getQueryBuilder();

$cacheKey = $this->calculateCacheKey($builder, $values);
/** @var array<int|string, int>|null $data */
$data = &$this->cacheCounts[$cacheKey];

if ($data !== null) {
return $data;
}

/** @noinspection PhpUnnecessaryLocalVariableInspection */
$data = $this->fetchCounts($builder, $values);
return $data;
}
Expand Down
Expand Up @@ -54,9 +54,8 @@ class DbalPersistAutoupdateMapperTest extends DataTestCase
Assert::same('Test Collection 11', $bookCollection->name);
Assert::type(DateTimeImmutable::class, $bookCollection->updatedAt);
$new = $bookCollection->updatedAt;
Assert::notEqual($old->format(DateTime::ISO8601), $new->format(DateTime::ISO8601));
Assert::notEqual($old->format(DateTime::ATOM), $new->format(DateTime::ATOM));

/** @var IConnection $connection */
$connection = $this->container->getByType(Connection::class);
$connection->query('DELETE FROM book_collections WHERE id = %i', $bookCollection->id);

Expand Down
Expand Up @@ -48,7 +48,6 @@ class RelationshipManyHasManyTest extends DataTestCase
$book->tags->add(3);
$this->orm->books->persistAndFlush($book);

/** @var Book[] $books */
$books = $this->orm->books->findAll()->orderBy('id');

$tags = [];
Expand All @@ -71,7 +70,6 @@ class RelationshipManyHasManyTest extends DataTestCase

public function testEmptyPreloadContainer(): void
{
/** @var Book[] $books */
$books = $this->orm->books->findAll()->orderBy('id');
$tags = [];

Expand Down
Expand Up @@ -22,7 +22,6 @@ class RelationshipManyHasOneTest extends DataTestCase

public function testBasics(): void
{
/** @var Book[] $books */
$books = $this->orm->books->findAll()->orderBy('id');
$authors = [];

Expand Down Expand Up @@ -63,7 +62,6 @@ class RelationshipManyHasOneTest extends DataTestCase

public function testEmptyEntityPreloadContainer(): void
{
/** @var Book[] $books */
$books = $this->orm->books->findAll()->orderBy('id');
$authors = [];

Expand Down
Expand Up @@ -37,7 +37,6 @@ class RelationshipOneHasManyCompositePkTest extends DataTestCase
$this->orm->tagFollowers->persistAndFlush($tagFollower);

$tagFollowers = [];
/** @var Author[] $authors */
$authors = $this->orm->authors->findAll()->orderBy('id');

foreach ($authors as $author) {
Expand Down
Expand Up @@ -185,7 +185,6 @@ class RelationshipOneHasManyTest extends DataTestCase
$book->publisher = 1;
$this->orm->books->persistAndFlush($book);

/** @var Author[] $authors */
$authors = $this->orm->authors->findAll()->orderBy('id');

$books = [];
Expand All @@ -211,7 +210,6 @@ class RelationshipOneHasManyTest extends DataTestCase
{
$books = [];

/** @var Author[] $authors */
$authors = $this->orm->authors->findAll()->orderBy('id');
foreach ($authors as $author) {
$author->setPreloadContainer(null);
Expand Down
2 changes: 0 additions & 2 deletions tests/cases/unit/Entity/AbstractEntity.repository.phpt
Expand Up @@ -28,7 +28,6 @@ class AbstractEntityRepositoryTest extends TestCase
$repository = Mockery::mock(IRepository::class);
$metadata = Mockery::mock(EntityMetadata::class);

/** @var IEntity $entity */
$entity = Mockery::mock(AbstractEntity::class)->makePartial();
$entity->onAttach($repository, $metadata);

Expand All @@ -41,7 +40,6 @@ class AbstractEntityRepositoryTest extends TestCase
$repository = Mockery::mock(IRepository::class);
$metadata = Mockery::mock(EntityMetadata::class);

/** @var IEntity $entity */
$entity = Mockery::mock(AbstractEntity::class)->makePartial();
$entity->onAttach($repository, $metadata);
Assert::same($repository, $entity->getRepository());
Expand Down
2 changes: 0 additions & 2 deletions tests/cases/unit/Mapper/Dbal/DbalMapperTest.phpt
Expand Up @@ -44,7 +44,6 @@ class DbalMapperTest extends TestCase
$repository->shouldReceive('hydrateEntity')->once()->with(['id' => 2])->andReturn($b = new Author());
$repository->shouldReceive('hydrateEntity')->once()->with(['id' => 3])->andReturn($c = new Author());

/** @var ArrayCollection<Author> $collection */
$collection = $mapper->toCollection([
['id' => 1],
['id' => 2],
Expand Down Expand Up @@ -93,7 +92,6 @@ class DbalMapperTest extends TestCase
$result->shouldReceive('next')->times(3);
$result->shouldReceive('valid')->once()->andReturn(false);

/** @var ArrayCollection<Author> $collection */
$collection = $mapper->toCollection($result);

Assert::type(ArrayCollection::class, $collection);
Expand Down

0 comments on commit e8397bd

Please sign in to comment.