[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

@@ -45,6 +45,9 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\Request;
/**
* @template T
* */
trait MetaCollectionTrait
{
//protected const SLUG = 'collection';
@@ -53,40 +56,42 @@ trait MetaCollectionTrait
/**
* create a collection owned by Actor $owner.
*
* @param Actor $owner The collection's owner
* @param array $vars Page vars sent by AppendRightPanelBlock event
* @param string $name Collection's name
* @param Actor $owner The collection's owner
* @param array<string, mixed> $vars Page vars sent by AppendRightPanelBlock event
* @param string $name Collection's name
*/
abstract protected function createCollection(Actor $owner, array $vars, string $name);
abstract protected function createCollection(Actor $owner, array $vars, string $name): void;
/**
* remove item from collections.
*
* @param Actor $owner Current user
* @param array $vars Page vars sent by AppendRightPanelBlock event
* @param array $items Array of collections's ids to remove the current item from
* @param array $collections List of ids of collections owned by $owner
* @param Actor $owner Current user
* @param array<string, mixed> $vars Page vars sent by AppendRightPanelBlock event
* @param int[] $items Array of collections's ids to remove the current item from
* @param int[] $collections List of ids of collections owned by $owner
*/
abstract protected function removeItem(Actor $owner, array $vars, array $items, array $collections);
abstract protected function removeItem(Actor $owner, array $vars, array $items, array $collections): bool;
/**
* add item to collections.
*
* @param Actor $owner Current user
* @param array $vars Page vars sent by AppendRightPanelBlock event
* @param array $items Array of collections's ids to add the current item to
* @param array $collections List of ids of collections owned by $owner
* @param Actor $owner Current user
* @param array<string, mixed> $vars Page vars sent by AppendRightPanelBlock event
* @param int[] $items Array of collections's ids to add the current item to
* @param int[] $collections List of ids of collections owned by $owner
*/
abstract protected function addItem(Actor $owner, array $vars, array $items, array $collections);
abstract protected function addItem(Actor $owner, array $vars, array $items, array $collections): void;
/**
* Check the route to determine whether the widget should be added
* @param array<string, mixed> $vars
*/
abstract protected function shouldAddToRightPanel(Actor $user, $vars, Request $request): bool;
abstract protected function shouldAddToRightPanel(Actor $user, array $vars, Request $request): bool;
/**
* Get array of collections's owned by $actor
*
* @param Actor $owner Collection's owner
* @param ?array $vars Page vars sent by AppendRightPanelBlock event
* @param bool $ids_only if true, the function must return only the primary key or each collections
* @param Actor $owner Collection's owner
* @param null|array<string, mixed> $vars Page vars sent by AppendRightPanelBlock event
* @param bool $ids_only if true, the function must return only the primary key or each collections
* @return T[]|int[]
*/
abstract protected function getCollectionsBy(Actor $owner, ?array $vars = null, bool $ids_only = false): array;
@@ -94,8 +99,11 @@ trait MetaCollectionTrait
* Append Collections widget to the right panel.
* It's compose of two forms: one to select collections to add
* the current item to, and another to create a new collection.
*
* @param array<string, mixed> $vars
* @param string[] $res
*/
public function onAppendRightPanelBlock(Request $request, $vars, &$res): EventResult
public function onAppendRightPanelBlock(Request $request, array $vars, array &$res): EventResult
{
$user = Common::actor();
if (\is_null($user)) {
@@ -187,6 +195,9 @@ trait MetaCollectionTrait
return Event::next;
}
/**
* @param string[]
*/
public function onEndShowStyles(array &$styles, string $route): EventResult
{
$styles[] = 'components/Collection/assets/css/widget.css';