[TOOLS] Continue raising PHPStan level to 6

This commit is contained in:
2022-10-19 22:39:17 +01:00
parent c31f3d4997
commit 2fd46ca886
89 changed files with 646 additions and 278 deletions

View File

@@ -28,6 +28,9 @@ use App\Core\Router;
use Component\Collection\Util\Controller\MetaCollectionController;
use Plugin\AttachmentCollections\Entity\AttachmentCollection;
/**
* @extends MetaCollectionController<AttachmentCollection>
*/
class AttachmentCollections extends MetaCollectionController
{
public function createCollection(int $owner_id, string $name): bool
@@ -36,6 +39,8 @@ class AttachmentCollections extends MetaCollectionController
'name' => $name,
'actor_id' => $owner_id,
]));
return true;
}
public function getCollectionUrl(int $owner_id, ?string $owner_nickname, int $collection_id): string
@@ -51,7 +56,12 @@ class AttachmentCollections extends MetaCollectionController
['nickname' => $owner_nickname, 'cid' => $collection_id],
);
}
public function getCollectionItems(int $owner_id, $collection_id): array
/**
* FIXME return value not consistent with base class
*/
// @phpstan-disable-next-line
public function getCollectionItems(int $owner_id, int $collection_id): array
{
[$attachs, $notes] = DB::dql(
<<<'EOF'
@@ -64,28 +74,30 @@ class AttachmentCollections extends MetaCollectionController
EOF,
['cid' => $collection_id],
);
return [
'_template' => 'AttachmentCollections/collection_entry_view.html.twig',
'attachments' => array_values($attachs),
'bare_notes' => array_values($notes),
];
return ['_template' => 'AttachmentCollections/collection_entry_view.html.twig', 'attachments' => array_values($attachs), 'bare_notes' => array_values($notes)];
}
/**
* @return AttachmentCollection[]
*/
public function getCollectionsByActorId(int $owner_id): array
{
return DB::findBy(AttachmentCollection::class, ['actor_id' => $owner_id], order_by: ['id' => 'desc']);
}
public function getCollectionBy(int $owner_id, int $collection_id): AttachmentCollection
{
return DB::findOneBy(AttachmentCollection::class, ['id' => $collection_id]);
}
public function setCollectionName(int $actor_id, string $actor_nickname, AttachmentCollection $collection, string $name)
public function setCollectionName(int $actor_id, string $actor_nickname, AttachmentCollection $collection, string $name): void
{
$collection->setName($name);
DB::persist($collection);
}
public function removeCollection(int $actor_id, string $actor_nickname, AttachmentCollection $collection)
public function removeCollection(int $actor_id, string $actor_nickname, AttachmentCollection $collection): void
{
DB::remove($collection);
}