[TOOLS] Continue raising PHPStan level to 6
This commit is contained in:
@@ -49,9 +49,14 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class AttachmentCollections extends Plugin
|
||||
{
|
||||
/** @phpstan-use MetaCollectionTrait<AttachmentCollection> */
|
||||
use MetaCollectionTrait;
|
||||
protected const SLUG = 'collection';
|
||||
protected const PLURAL_SLUG = 'collections';
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
*/
|
||||
protected function createCollection(Actor $owner, array $vars, string $name): void
|
||||
{
|
||||
$col = AttachmentCollection::create([
|
||||
@@ -65,6 +70,12 @@ class AttachmentCollections extends Plugin
|
||||
'attachment_collection_id' => $col->getId(),
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
* @param int[] $items
|
||||
* @param array<string, mixed> $collections
|
||||
*/
|
||||
protected function removeItem(Actor $owner, array $vars, array $items, array $collections): bool
|
||||
{
|
||||
return DB::dql(<<<'EOF'
|
||||
@@ -83,6 +94,11 @@ class AttachmentCollections extends Plugin
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
* @param int[] $items
|
||||
* @param array<string, mixed> $collections
|
||||
*/
|
||||
protected function addItem(Actor $owner, array $vars, array $items, array $collections): void
|
||||
{
|
||||
foreach ($items as $id) {
|
||||
@@ -97,14 +113,18 @@ class AttachmentCollections extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
protected function shouldAddToRightPanel(Actor $user, $vars, Request $request): bool
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
*/
|
||||
protected function shouldAddToRightPanel(Actor $user, array $vars, Request $request): bool
|
||||
{
|
||||
return $vars['path'] === 'note_attachment_show';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $vars
|
||||
* @return int[]
|
||||
*
|
||||
* @return ($ids_only is true ? int[] : AttachmentCollection[])
|
||||
*/
|
||||
protected function getCollectionsBy(Actor $owner, ?array $vars = null, bool $ids_only = false): array
|
||||
{
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user