mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Fixed phpstan generics
This commit is contained in:
parent
770bf15342
commit
e97fe9de86
|
|
@ -18,9 +18,8 @@ use Grav\Common\Flex\Traits\FlexGravTrait;
|
|||
* Class FlexCollection
|
||||
*
|
||||
* @package Grav\Common\Flex
|
||||
* @template TKey
|
||||
* @template T of \Grav\Framework\Flex\Interfaces\FlexObjectInterface
|
||||
* @extends \Grav\Framework\Flex\FlexCollection<TKey,T>
|
||||
* @extends \Grav\Framework\Flex\FlexCollection<T>
|
||||
*/
|
||||
abstract class FlexCollection extends \Grav\Framework\Flex\FlexCollection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,10 +18,9 @@ use Grav\Common\Flex\Traits\FlexIndexTrait;
|
|||
* Class FlexIndex
|
||||
*
|
||||
* @package Grav\Common\Flex
|
||||
* @template TKey
|
||||
* @template T of \Grav\Framework\Flex\Interfaces\FlexObjectInterface
|
||||
* @template C of \Grav\Framework\Flex\Interfaces\FlexCollectionInterface
|
||||
* @extends \Grav\Framework\Flex\FlexIndex<TKey,T,C>
|
||||
* @extends \Grav\Framework\Flex\FlexIndex<T,C>
|
||||
*/
|
||||
abstract class FlexIndex extends \Grav\Framework\Flex\FlexIndex
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use Grav\Common\Flex\FlexCollection;
|
|||
* Class GenericCollection
|
||||
* @package Grav\Common\Flex\Generic
|
||||
*
|
||||
* @extends FlexCollection<string,GenericObject>
|
||||
* @extends FlexCollection<GenericObject>
|
||||
*/
|
||||
class GenericCollection extends FlexCollection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use Grav\Common\Flex\FlexIndex;
|
|||
* Class GenericIndex
|
||||
* @package Grav\Common\Flex\Generic
|
||||
*
|
||||
* @extends FlexIndex<string,GenericObject,GenericCollection>
|
||||
* @extends FlexIndex<GenericObject,GenericCollection>
|
||||
*/
|
||||
class GenericIndex extends FlexIndex
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ use function is_string;
|
|||
* Class GravPageCollection
|
||||
* @package Grav\Plugin\FlexObjects\Types\GravPages
|
||||
*
|
||||
* @extends FlexPageCollection<string,PageObject>
|
||||
* @extends FlexPageCollection<PageObject>
|
||||
*
|
||||
* Incompatibilities with Grav\Common\Page\Collection:
|
||||
* $page = $collection->key() will not work at all
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ use function is_string;
|
|||
* Class GravPageObject
|
||||
* @package Grav\Plugin\FlexObjects\Types\GravPages
|
||||
*
|
||||
* @extends FlexPageIndex<string,PageObject,PageCollection>
|
||||
* @extends FlexPageIndex<PageObject,PageCollection>
|
||||
*
|
||||
* @method PageIndex withModules(bool $bool = true)
|
||||
* @method PageIndex withPages(bool $bool = true)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use Grav\Common\Flex\FlexCollection;
|
|||
* Class UserGroupCollection
|
||||
* @package Grav\Common\Flex\Types\UserGroups
|
||||
*
|
||||
* @extends FlexCollection<string,UserGroupObject>
|
||||
* @extends FlexCollection<UserGroupObject>
|
||||
*/
|
||||
class UserGroupCollection extends FlexCollection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use Grav\Common\Flex\FlexIndex;
|
|||
* Class GroupIndex
|
||||
* @package Grav\Common\User\FlexUser
|
||||
*
|
||||
* @extends FlexIndex<string,UserGroupObject,UserGroupCollection>
|
||||
* @extends FlexIndex<UserGroupObject,UserGroupCollection>
|
||||
*/
|
||||
class UserGroupIndex extends FlexIndex
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use function is_string;
|
|||
* Class UserCollection
|
||||
* @package Grav\Common\Flex\Types\Users
|
||||
*
|
||||
* @extends FlexCollection<string,UserObject>
|
||||
* @extends FlexCollection<UserObject>
|
||||
*/
|
||||
class UserCollection extends FlexCollection implements UserCollectionInterface
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,13 +21,12 @@ use Grav\Framework\Flex\Interfaces\FlexStorageInterface;
|
|||
use Monolog\Logger;
|
||||
use function count;
|
||||
use function is_string;
|
||||
use function method_exists;
|
||||
|
||||
/**
|
||||
* Class UserIndex
|
||||
* @package Grav\Common\Flex\Types\Users
|
||||
*
|
||||
* @extends FlexIndex<string,UserObject,UserCollection>
|
||||
* @extends FlexIndex<UserObject,UserCollection>
|
||||
*/
|
||||
class UserIndex extends FlexIndex implements UserCollectionInterface
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,10 +37,9 @@ use function is_scalar;
|
|||
/**
|
||||
* Class FlexCollection
|
||||
* @package Grav\Framework\Flex
|
||||
* @template TKey
|
||||
* @template T of FlexObjectInterface
|
||||
* @extends ObjectCollection<TKey,T>
|
||||
* @implements FlexCollectionInterface<TKey,T>
|
||||
* @extends ObjectCollection<string,T>
|
||||
* @implements FlexCollectionInterface<T>
|
||||
*/
|
||||
class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
||||
{
|
||||
|
|
@ -460,7 +459,6 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
/**
|
||||
* @param string $key
|
||||
* @return array
|
||||
* @phpstan-param TKey $key
|
||||
*/
|
||||
public function getMetaData(string $key): array
|
||||
{
|
||||
|
|
@ -491,7 +489,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
* @param string|null $scope
|
||||
* @param UserInterface|null $user
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function isAuthorized(string $action, string $scope = null, UserInterface $user = null)
|
||||
{
|
||||
|
|
@ -559,7 +557,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
* @param array $elements Elements.
|
||||
* @param string|null $keyField
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function createFrom(array $elements, $keyField = null)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ use function is_callable;
|
|||
* Class FlexDirectory
|
||||
* @package Grav\Framework\Flex
|
||||
* @template T
|
||||
* @template TKey
|
||||
*/
|
||||
class FlexDirectory implements FlexDirectoryInterface, FlexAuthorizeInterface
|
||||
{
|
||||
|
|
@ -309,7 +308,7 @@ class FlexDirectory implements FlexDirectoryInterface, FlexAuthorizeInterface
|
|||
* @param array|null $keys Array of keys.
|
||||
* @param string|null $keyField Field to be used as the key.
|
||||
* @return FlexCollectionInterface
|
||||
* @phpstan-return FlexCollectionInterface<TKey,T>
|
||||
* @phpstan-return FlexCollectionInterface<T>
|
||||
*/
|
||||
public function getCollection(array $keys = null, string $keyField = null): FlexCollectionInterface
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,11 +33,10 @@ use function in_array;
|
|||
/**
|
||||
* Class FlexIndex
|
||||
* @package Grav\Framework\Flex
|
||||
* @template TKey
|
||||
* @template T of FlexObjectInterface
|
||||
* @template C of FlexCollectionInterface
|
||||
* @extends ObjectIndex<TKey,T>
|
||||
* @implements FlexIndexInterface<TKey,T>
|
||||
* @extends ObjectIndex<string,T>
|
||||
* @implements FlexIndexInterface<T>
|
||||
* @mixin C
|
||||
*/
|
||||
class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexIndexInterface
|
||||
|
|
@ -54,7 +53,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
|||
/**
|
||||
* @param FlexDirectory $directory
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T,C>
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public static function createFromStorage(FlexDirectory $directory)
|
||||
{
|
||||
|
|
@ -343,7 +342,6 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
|||
/**
|
||||
* @param string $key
|
||||
* @return array
|
||||
* @phpstan-param TKey $key
|
||||
*/
|
||||
public function getMetaData($key): array
|
||||
{
|
||||
|
|
@ -370,7 +368,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
|||
/**
|
||||
* @param array $orderings
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T,C>
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function orderBy(array $orderings)
|
||||
{
|
||||
|
|
@ -538,7 +536,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
|||
* @param array $entries
|
||||
* @param string|null $keyField
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T,C>
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
protected function createFrom(array $entries, string $keyField = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,9 +22,8 @@ use InvalidArgumentException;
|
|||
*
|
||||
* @used-by \Grav\Framework\Flex\FlexCollection
|
||||
* @since 1.6
|
||||
* @template TKey
|
||||
* @template T
|
||||
* @extends ObjectCollectionInterface<TKey,T>
|
||||
* @extends ObjectCollectionInterface<string,T>
|
||||
*/
|
||||
interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionInterface, NestedObjectInterface
|
||||
{
|
||||
|
|
@ -58,7 +57,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
|||
* @param string|string[]|null $properties Properties to search for, defaults to configured properties.
|
||||
* @param array|null $options Search options, defaults to configured options.
|
||||
* @return FlexCollectionInterface Returns a Flex Collection with only matching objects.
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
* @api
|
||||
*/
|
||||
public function search(string $search, $properties = null, array $options = null);
|
||||
|
|
@ -69,7 +68,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
|||
* @param array $orderings Pair of [property => 'ASC'|'DESC', ...].
|
||||
*
|
||||
* @return FlexCollectionInterface Returns a sorted version from the collection.
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function sort(array $orderings);
|
||||
|
||||
|
|
@ -78,7 +77,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
|||
*
|
||||
* @param array $filters
|
||||
* @return FlexCollectionInterface
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function filterBy(array $filters);
|
||||
|
||||
|
|
@ -114,7 +113,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
|||
*
|
||||
* @param string|null $keyField Switch key field of the collection.
|
||||
* @return FlexCollectionInterface Returns a new Flex Collection with new key field.
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
* @api
|
||||
*/
|
||||
public function withKeyField(string $keyField = null);
|
||||
|
|
@ -123,7 +122,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
|||
* Get Flex Index from the Flex Collection.
|
||||
*
|
||||
* @return FlexIndexInterface Returns a Flex Index from the current collection.
|
||||
* @phpstan-return FlexIndexInterface<TKey,T>
|
||||
* @phpstan-return FlexIndexInterface<T>
|
||||
*/
|
||||
public function getIndex();
|
||||
|
||||
|
|
@ -131,7 +130,7 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
|||
* Load all the objects into memory,
|
||||
*
|
||||
* @return FlexCollectionInterface
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function getCollection();
|
||||
|
||||
|
|
@ -140,7 +139,6 @@ interface FlexCollectionInterface extends FlexCommonInterface, ObjectCollectionI
|
|||
*
|
||||
* @param string $key Key.
|
||||
* @return array
|
||||
* @phpstan-param TKey $key
|
||||
*/
|
||||
public function getMetaData(string $key): array;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,8 @@ use Grav\Framework\Flex\FlexDirectory;
|
|||
*
|
||||
* @used-by \Grav\Framework\Flex\FlexIndex
|
||||
* @since 1.6
|
||||
* @template TKey
|
||||
* @template T
|
||||
* @extends FlexCollectionInterface<TKey,T>
|
||||
* @extends FlexCollectionInterface<T>
|
||||
*/
|
||||
interface FlexIndexInterface extends FlexCollectionInterface
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,9 +20,8 @@ use function is_int;
|
|||
/**
|
||||
* Class FlexPageCollection
|
||||
* @package Grav\Plugin\FlexObjects\Types\FlexPages
|
||||
* @template TKey
|
||||
* @template T of \Grav\Framework\Flex\Interfaces\FlexObjectInterface
|
||||
* @extends FlexCollection<TKey,T>
|
||||
* @extends FlexCollection<T>
|
||||
*/
|
||||
class FlexPageCollection extends FlexCollection
|
||||
{
|
||||
|
|
@ -53,7 +52,7 @@ class FlexPageCollection extends FlexCollection
|
|||
/**
|
||||
* @param bool $bool
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function withPublished(bool $bool = true)
|
||||
{
|
||||
|
|
@ -65,7 +64,7 @@ class FlexPageCollection extends FlexCollection
|
|||
/**
|
||||
* @param bool $bool
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function withVisible(bool $bool = true)
|
||||
{
|
||||
|
|
@ -77,7 +76,7 @@ class FlexPageCollection extends FlexCollection
|
|||
/**
|
||||
* @param bool $bool
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T>
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function withRoutable(bool $bool = true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,10 +22,9 @@ use Grav\Framework\Flex\FlexIndex;
|
|||
* @method FlexPageIndex withPublished(bool $bool = true)
|
||||
* @method FlexPageIndex withVisible(bool $bool = true)
|
||||
*
|
||||
* @template TKey
|
||||
* @template T of FlexPageObject
|
||||
* @template C of FlexPageCollection
|
||||
* @extends FlexIndex<TKey,T,C>
|
||||
* @extends FlexIndex<T,C>
|
||||
*/
|
||||
class FlexPageIndex extends FlexIndex
|
||||
{
|
||||
|
|
|
|||
|
|
@ -205,10 +205,10 @@ trait FlexMediaTrait
|
|||
$filename = $info['path'] ?? $info['name'];
|
||||
}
|
||||
|
||||
/** @var Medium|null $thumbFile */
|
||||
/** @var Medium|null $imageFile */
|
||||
$imageFile = $media[$filename];
|
||||
|
||||
/** @var Medium|null $thumbFile */
|
||||
/** @var Medium|null $originalFile */
|
||||
$originalFile = $originalMedia ? $originalMedia[$filename] : null;
|
||||
|
||||
$url = $imageFile ? $imageFile->url() : null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user