[TOOLS] Continue raising PHPStan to level 6

This commit is contained in:
2022-10-19 22:39:17 +01:00
parent e6bb418fe6
commit c31f3d4997
25 changed files with 233 additions and 58 deletions

View File

@@ -52,7 +52,7 @@ class AttachmentCollections extends Plugin
use MetaCollectionTrait;
protected const SLUG = 'collection';
protected const PLURAL_SLUG = 'collections';
protected function createCollection(Actor $owner, array $vars, string $name)
protected function createCollection(Actor $owner, array $vars, string $name): void
{
$col = AttachmentCollection::create([
'name' => $name,
@@ -65,7 +65,7 @@ class AttachmentCollections extends Plugin
'attachment_collection_id' => $col->getId(),
]));
}
protected function removeItem(Actor $owner, array $vars, array $items, array $collections)
protected function removeItem(Actor $owner, array $vars, array $items, array $collections): bool
{
return DB::dql(<<<'EOF'
DELETE FROM \Plugin\AttachmentCollections\Entity\AttachmentCollectionEntry AS entry
@@ -83,7 +83,7 @@ class AttachmentCollections extends Plugin
]);
}
protected function addItem(Actor $owner, array $vars, array $items, array $collections)
protected function addItem(Actor $owner, array $vars, array $items, array $collections): void
{
foreach ($items as $id) {
// prevent user from putting something in a collection (s)he doesn't own:
@@ -102,6 +102,10 @@ class AttachmentCollections extends Plugin
return $vars['path'] === 'note_attachment_show';
}
/**
* @param array<string, mixed> $vars
* @return int[]
*/
protected function getCollectionsBy(Actor $owner, ?array $vars = null, bool $ids_only = false): array
{
if (\is_null($vars)) {

View File

@@ -30,13 +30,14 @@ use Plugin\AttachmentCollections\Entity\AttachmentCollection;
class AttachmentCollections extends MetaCollectionController
{
public function createCollection(int $owner_id, string $name)
public function createCollection(int $owner_id, string $name): bool
{
DB::persist(AttachmentCollection::create([
'name' => $name,
'actor_id' => $owner_id,
]));
}
public function getCollectionUrl(int $owner_id, ?string $owner_nickname, int $collection_id): string
{
if (\is_null($owner_nickname)) {