mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
More phpstan fixes
This commit is contained in:
parent
d59a4c63db
commit
179dec4c3b
|
|
@ -34,8 +34,9 @@ use function is_string;
|
|||
* Class GravPageCollection
|
||||
* @package Grav\Plugin\FlexObjects\Types\GravPages
|
||||
*
|
||||
* @extends FlexPageCollection<PageObject>
|
||||
* @implements PageCollectionInterface<string,PageObject>
|
||||
* @template T as PageObject
|
||||
* @extends FlexPageCollection<T>
|
||||
* @implements PageCollectionInterface<string,T>
|
||||
*
|
||||
* Incompatibilities with Grav\Common\Page\Collection:
|
||||
* $page = $collection->key() will not work at all
|
||||
|
|
@ -47,10 +48,6 @@ use function is_string;
|
|||
* $collection->prev() does not rewind the internal pointer
|
||||
* AND most methods are immutable; they do not update the current collection, but return updated one
|
||||
*
|
||||
* @method PageCollection shuffle()
|
||||
* @method PageCollection select(array $keys)
|
||||
* @method PageCollection unselect(array $keys)
|
||||
* @method PageCollection createFrom(array $elements, string $keyField = null)
|
||||
* @method PageIndex getIndex()
|
||||
*/
|
||||
class PageCollection extends FlexPageCollection implements PageCollectionInterface
|
||||
|
|
@ -109,13 +106,11 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
}
|
||||
|
||||
/**
|
||||
* @return PageObject
|
||||
* @return PageInterface
|
||||
*/
|
||||
public function getRoot()
|
||||
{
|
||||
$index = $this->getIndex();
|
||||
|
||||
return $index->getRoot();
|
||||
return $this->getIndex()->getRoot();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -155,7 +150,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Add a single page to a collection
|
||||
*
|
||||
* @param PageInterface $page
|
||||
* @return static
|
||||
* @return $this
|
||||
*/
|
||||
public function addPage(PageInterface $page)
|
||||
{
|
||||
|
|
@ -175,6 +170,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
*
|
||||
* @param PageCollectionInterface $collection
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function merge(PageCollectionInterface $collection)
|
||||
{
|
||||
|
|
@ -186,6 +182,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
*
|
||||
* @param PageCollectionInterface $collection
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function intersect(PageCollectionInterface $collection)
|
||||
{
|
||||
|
|
@ -204,7 +201,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Return previous item.
|
||||
*
|
||||
* @return PageInterface|false
|
||||
* @phpstan-return PageObject|false
|
||||
* @phpstan-return T|false
|
||||
*/
|
||||
public function prev()
|
||||
{
|
||||
|
|
@ -219,7 +216,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Return nth item.
|
||||
* @param int $key
|
||||
* @return PageInterface|bool
|
||||
* @phpstan-return PageObject|false
|
||||
* @phpstan-return T|false
|
||||
*/
|
||||
public function nth($key)
|
||||
{
|
||||
|
|
@ -231,6 +228,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
*
|
||||
* @param int $num Specifies how many entries should be picked.
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function random($num = 1)
|
||||
{
|
||||
|
|
@ -242,6 +240,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
*
|
||||
* @param array $items Items to be appended. Existing keys will be overridden with the new values.
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function append($items)
|
||||
{
|
||||
|
|
@ -253,6 +252,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
*
|
||||
* @param int $size
|
||||
* @return static[]
|
||||
* @phpstan-return static<T>[]
|
||||
*/
|
||||
public function batch($size): array
|
||||
{
|
||||
|
|
@ -274,6 +274,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* @param array|null $manual
|
||||
* @param int|null $sort_flags
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function order($by, $dir = 'asc', $manual = null, $sort_flags = null)
|
||||
{
|
||||
|
|
@ -442,6 +443,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* @param string|null $endDate
|
||||
* @param string|null $field
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
* @throws Exception
|
||||
*/
|
||||
public function dateRange($startDate = null, $endDate = null, $field = null)
|
||||
|
|
@ -469,6 +471,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Creates new collection with only visible pages
|
||||
*
|
||||
* @return static The collection with only visible pages
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function visible()
|
||||
{
|
||||
|
|
@ -486,6 +489,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Creates new collection with only non-visible pages
|
||||
*
|
||||
* @return static The collection with only non-visible pages
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function nonVisible()
|
||||
{
|
||||
|
|
@ -503,6 +507,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Creates new collection with only pages
|
||||
*
|
||||
* @return static The collection with only pages
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function pages()
|
||||
{
|
||||
|
|
@ -524,6 +529,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Creates new collection with only modules
|
||||
*
|
||||
* @return static The collection with only modules
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function modules()
|
||||
{
|
||||
|
|
@ -545,6 +551,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Alias of modules()
|
||||
*
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function modular()
|
||||
{
|
||||
|
|
@ -555,6 +562,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Alias of pages()
|
||||
*
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function nonModular()
|
||||
{
|
||||
|
|
@ -565,6 +573,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Creates new collection with only published pages
|
||||
*
|
||||
* @return static The collection with only published pages
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function published()
|
||||
{
|
||||
|
|
@ -582,6 +591,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Creates new collection with only non-published pages
|
||||
*
|
||||
* @return static The collection with only non-published pages
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function nonPublished()
|
||||
{
|
||||
|
|
@ -599,6 +609,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Creates new collection with only routable pages
|
||||
*
|
||||
* @return static The collection with only routable pages
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function routable()
|
||||
{
|
||||
|
|
@ -616,6 +627,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* Creates new collection with only non-routable pages
|
||||
*
|
||||
* @return static The collection with only non-routable pages
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function nonRoutable()
|
||||
{
|
||||
|
|
@ -634,6 +646,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
*
|
||||
* @param string $type
|
||||
* @return static The collection
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function ofType($type)
|
||||
{
|
||||
|
|
@ -652,6 +665,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
*
|
||||
* @param string[] $types
|
||||
* @return static The collection
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function ofOneOfTheseTypes($types)
|
||||
{
|
||||
|
|
@ -670,6 +684,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
*
|
||||
* @param array $accessLevels
|
||||
* @return static The collection
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function ofOneOfTheseAccessLevels($accessLevels)
|
||||
{
|
||||
|
|
@ -711,6 +726,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
/**
|
||||
* @param bool $bool
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function withOrdered(bool $bool = true)
|
||||
{
|
||||
|
|
@ -722,6 +738,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
/**
|
||||
* @param bool $bool
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function withModules(bool $bool = true)
|
||||
{
|
||||
|
|
@ -733,6 +750,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
/**
|
||||
* @param bool $bool
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function withPages(bool $bool = true)
|
||||
{
|
||||
|
|
@ -746,6 +764,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* @param string|null $languageCode
|
||||
* @param bool|null $fallback
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function withTranslation(bool $bool = true, string $languageCode = null, bool $fallback = null)
|
||||
{
|
||||
|
|
@ -779,6 +798,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
* @param array $filters
|
||||
* @param bool $recursive
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function filterBy(array $filters, bool $recursive = false)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,8 +39,10 @@ use function is_string;
|
|||
* Class GravPageObject
|
||||
* @package Grav\Plugin\FlexObjects\Types\GravPages
|
||||
*
|
||||
* @extends FlexPageIndex<PageObject,PageCollection>
|
||||
* @implements PageCollectionInterface<string,PageObject>
|
||||
* @template T of PageObject
|
||||
* @template C of PageCollection
|
||||
* @extends FlexPageIndex<T,C>
|
||||
* @implements PageCollectionInterface<string,T>
|
||||
*
|
||||
* @method PageIndex withModules(bool $bool = true)
|
||||
* @method PageIndex withPages(bool $bool = true)
|
||||
|
|
@ -102,6 +104,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
/**
|
||||
* @param string $key
|
||||
* @return PageObject|null
|
||||
* @phpstan-return T|null
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
|
|
@ -124,7 +127,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* @return PageObject
|
||||
* @return PageInterface
|
||||
*/
|
||||
public function getRoot()
|
||||
{
|
||||
|
|
@ -175,7 +178,8 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
/**
|
||||
* @param string|null $languageCode
|
||||
* @param bool|null $fallback
|
||||
* @return PageIndex
|
||||
* @return static
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function withTranslated(string $languageCode = null, bool $fallback = null)
|
||||
{
|
||||
|
|
@ -279,6 +283,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* @param array $filters
|
||||
* @param bool $recursive
|
||||
* @return static
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function filterBy(array $filters, bool $recursive = false)
|
||||
{
|
||||
|
|
@ -335,6 +340,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
/**
|
||||
* @param array $filters
|
||||
* @return static
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
protected function filterByParent(array $filters)
|
||||
{
|
||||
|
|
@ -405,6 +411,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* @param array $entries
|
||||
* @param string|null $keyField
|
||||
* @return static
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
protected function createFrom(array $entries, string $keyField = null)
|
||||
{
|
||||
|
|
@ -790,6 +797,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
*
|
||||
* @param PageInterface $page
|
||||
* @return PageCollection
|
||||
* @phpstan-return C
|
||||
*/
|
||||
public function addPage(PageInterface $page)
|
||||
{
|
||||
|
|
@ -801,6 +809,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* Create a copy of this collection
|
||||
*
|
||||
* @return static
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function copy()
|
||||
{
|
||||
|
|
@ -813,6 +822,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
*
|
||||
* @param PageCollectionInterface $collection
|
||||
* @return PageCollection
|
||||
* @phpstan-return C
|
||||
*/
|
||||
public function merge(PageCollectionInterface $collection)
|
||||
{
|
||||
|
|
@ -825,6 +835,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
*
|
||||
* @param PageCollectionInterface $collection
|
||||
* @return PageCollection
|
||||
* @phpstan-return C
|
||||
*/
|
||||
public function intersect(PageCollectionInterface $collection)
|
||||
{
|
||||
|
|
@ -836,6 +847,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
*
|
||||
* @param int $size
|
||||
* @return PageCollection[]
|
||||
* @phpstan-return C[]
|
||||
*/
|
||||
public function batch($size)
|
||||
{
|
||||
|
|
@ -847,6 +859,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
*
|
||||
* @param string $key
|
||||
* @return PageObject|null
|
||||
* @phpstan-return T|null
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function remove($key)
|
||||
|
|
@ -862,6 +875,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* @param array $manual
|
||||
* @param string $sort_flags
|
||||
* @return static
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function order($by, $dir = 'asc', $manual = null, $sort_flags = null)
|
||||
{
|
||||
|
|
@ -905,6 +919,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
*
|
||||
* @param string $path
|
||||
* @return PageObject|null The previous item.
|
||||
* @phpstan-return T|null
|
||||
*/
|
||||
public function prevSibling($path)
|
||||
{
|
||||
|
|
@ -919,6 +934,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
*
|
||||
* @param string $path
|
||||
* @return PageObject|null The next item.
|
||||
* @phpstan-return T|null
|
||||
*/
|
||||
public function nextSibling($path)
|
||||
{
|
||||
|
|
@ -934,6 +950,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* @param string $path
|
||||
* @param int $direction either -1 or +1
|
||||
* @return PageObject|false The sibling item.
|
||||
* @phpstan-return T|false
|
||||
*/
|
||||
public function adjacentSibling($path, $direction = 1)
|
||||
{
|
||||
|
|
@ -967,6 +984,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* @param string|null $endDate
|
||||
* @param string|null $field
|
||||
* @return static
|
||||
* @phpstan-return static<T,C>
|
||||
* @throws Exception
|
||||
*/
|
||||
public function dateRange($startDate = null, $endDate = null, $field = null)
|
||||
|
|
@ -991,6 +1009,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* Creates new collection with only visible pages
|
||||
*
|
||||
* @return static The collection with only visible pages
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function visible()
|
||||
{
|
||||
|
|
@ -1003,6 +1022,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* Creates new collection with only non-visible pages
|
||||
*
|
||||
* @return static The collection with only non-visible pages
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function nonVisible()
|
||||
{
|
||||
|
|
@ -1015,6 +1035,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* Creates new collection with only non-modular pages
|
||||
*
|
||||
* @return static The collection with only non-modular pages
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function pages()
|
||||
{
|
||||
|
|
@ -1027,6 +1048,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* Creates new collection with only modular pages
|
||||
*
|
||||
* @return static The collection with only modular pages
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function modules()
|
||||
{
|
||||
|
|
@ -1039,6 +1061,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* Creates new collection with only modular pages
|
||||
*
|
||||
* @return static The collection with only modular pages
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function modular()
|
||||
{
|
||||
|
|
@ -1049,6 +1072,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* Creates new collection with only non-modular pages
|
||||
*
|
||||
* @return static The collection with only non-modular pages
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function nonModular()
|
||||
{
|
||||
|
|
@ -1059,6 +1083,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* Creates new collection with only published pages
|
||||
*
|
||||
* @return static The collection with only published pages
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function published()
|
||||
{
|
||||
|
|
@ -1071,6 +1096,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* Creates new collection with only non-published pages
|
||||
*
|
||||
* @return static The collection with only non-published pages
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function nonPublished()
|
||||
{
|
||||
|
|
@ -1083,6 +1109,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* Creates new collection with only routable pages
|
||||
*
|
||||
* @return static The collection with only routable pages
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function routable()
|
||||
{
|
||||
|
|
@ -1095,6 +1122,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
* Creates new collection with only non-routable pages
|
||||
*
|
||||
* @return static The collection with only non-routable pages
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function nonRoutable()
|
||||
{
|
||||
|
|
@ -1108,6 +1136,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
*
|
||||
* @param string $type
|
||||
* @return static The collection
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function ofType($type)
|
||||
{
|
||||
|
|
@ -1121,6 +1150,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
*
|
||||
* @param string[] $types
|
||||
* @return static The collection
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function ofOneOfTheseTypes($types)
|
||||
{
|
||||
|
|
@ -1134,6 +1164,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
*
|
||||
* @param array $accessLevels
|
||||
* @return static The collection
|
||||
* @phpstan-return static<T,C>
|
||||
*/
|
||||
public function ofOneOfTheseAccessLevels($accessLevels)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -386,6 +386,7 @@ class PageObject extends FlexPageObject
|
|||
/**
|
||||
* @param array $ordering
|
||||
* @return PageCollection|null
|
||||
* @phpstan-return ObjectCollection<string,PageObject>|null
|
||||
*/
|
||||
protected function reorderSiblings(array $ordering)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -898,7 +898,9 @@ class UserObject extends FlexObject implements UserInterface, Countable
|
|||
protected function getGroups()
|
||||
{
|
||||
if (null === $this->_groups) {
|
||||
$this->_groups = $this->getUserGroups()->select((array)$this->getProperty('groups'));
|
||||
/** @var UserGroupIndex $groups */
|
||||
$groups = $this->getUserGroups()->select((array)$this->getProperty('groups'));
|
||||
$this->_groups = $groups;
|
||||
}
|
||||
|
||||
return $this->_groups;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
*
|
||||
* @param PageCollectionInterface $collection
|
||||
* @return PageCollectionInterface
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function merge(PageCollectionInterface $collection);
|
||||
|
||||
|
|
@ -81,6 +82,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
*
|
||||
* @param PageCollectionInterface $collection
|
||||
* @return PageCollectionInterface
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function intersect(PageCollectionInterface $collection);
|
||||
|
||||
|
|
@ -89,6 +91,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
*
|
||||
* @param int $size
|
||||
* @return PageCollectionInterface[]
|
||||
* @phpstan-return array<PageCollectionInterface<TKey,T>>
|
||||
*/
|
||||
public function batch($size);
|
||||
|
||||
|
|
@ -97,6 +100,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
*
|
||||
* @param PageInterface|string|null $key
|
||||
* @return PageCollectionInterface
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
//public function remove($key = null);
|
||||
|
|
@ -109,6 +113,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* @param array|null $manual
|
||||
* @param string|null $sort_flags
|
||||
* @return PageCollectionInterface
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function order($by, $dir = 'asc', $manual = null, $sort_flags = null);
|
||||
|
||||
|
|
@ -133,6 +138,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
*
|
||||
* @param string $path
|
||||
* @return PageInterface The previous item.
|
||||
* @phpstan-return T
|
||||
*/
|
||||
public function prevSibling($path);
|
||||
|
||||
|
|
@ -141,6 +147,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
*
|
||||
* @param string $path
|
||||
* @return PageInterface The next item.
|
||||
* @phpstan-return T
|
||||
*/
|
||||
public function nextSibling($path);
|
||||
|
||||
|
|
@ -150,6 +157,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* @param string $path
|
||||
* @param int $direction either -1 or +1
|
||||
* @return PageInterface|PageCollectionInterface|false The sibling item.
|
||||
* @phpstan-return T|false
|
||||
*/
|
||||
public function adjacentSibling($path, $direction = 1);
|
||||
|
||||
|
|
@ -171,6 +179,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* @param string|null $endDate
|
||||
* @param string|null $field
|
||||
* @return PageCollectionInterface
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
* @throws Exception
|
||||
*/
|
||||
public function dateRange($startDate = null, $endDate = null, $field = null);
|
||||
|
|
@ -179,6 +188,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* Creates new collection with only visible pages
|
||||
*
|
||||
* @return PageCollectionInterface The collection with only visible pages
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function visible();
|
||||
|
||||
|
|
@ -186,6 +196,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* Creates new collection with only non-visible pages
|
||||
*
|
||||
* @return PageCollectionInterface The collection with only non-visible pages
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function nonVisible();
|
||||
|
||||
|
|
@ -193,6 +204,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* Creates new collection with only pages
|
||||
*
|
||||
* @return PageCollectionInterface The collection with only pages
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function pages();
|
||||
|
||||
|
|
@ -200,6 +212,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* Creates new collection with only modules
|
||||
*
|
||||
* @return PageCollectionInterface The collection with only modules
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function modules();
|
||||
|
||||
|
|
@ -207,6 +220,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* Creates new collection with only modules
|
||||
*
|
||||
* @return PageCollectionInterface The collection with only modules
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
* @deprecated 1.7 Use $this->modules() instead
|
||||
*/
|
||||
public function modular();
|
||||
|
|
@ -215,6 +229,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* Creates new collection with only non-module pages
|
||||
*
|
||||
* @return PageCollectionInterface The collection with only non-module pages
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
* @deprecated 1.7 Use $this->pages() instead
|
||||
*/
|
||||
public function nonModular();
|
||||
|
|
@ -223,6 +238,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* Creates new collection with only published pages
|
||||
*
|
||||
* @return PageCollectionInterface The collection with only published pages
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function published();
|
||||
|
||||
|
|
@ -230,6 +246,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* Creates new collection with only non-published pages
|
||||
*
|
||||
* @return PageCollectionInterface The collection with only non-published pages
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function nonPublished();
|
||||
|
||||
|
|
@ -237,6 +254,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* Creates new collection with only routable pages
|
||||
*
|
||||
* @return PageCollectionInterface The collection with only routable pages
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function routable();
|
||||
|
||||
|
|
@ -244,6 +262,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
* Creates new collection with only non-routable pages
|
||||
*
|
||||
* @return PageCollectionInterface The collection with only non-routable pages
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function nonRoutable();
|
||||
|
||||
|
|
@ -252,6 +271,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
*
|
||||
* @param string $type
|
||||
* @return PageCollectionInterface The collection
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function ofType($type);
|
||||
|
||||
|
|
@ -260,6 +280,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
*
|
||||
* @param string[] $types
|
||||
* @return PageCollectionInterface The collection
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function ofOneOfTheseTypes($types);
|
||||
|
||||
|
|
@ -268,6 +289,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
|
|||
*
|
||||
* @param array $accessLevels
|
||||
* @return PageCollectionInterface The collection
|
||||
* @phpstan-return PageCollectionInterface<TKey,T>
|
||||
*/
|
||||
public function ofOneOfTheseAccessLevels($accessLevels);
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,8 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
|
||||
/**
|
||||
* @param array $filters
|
||||
* @return FlexCollectionInterface|Collection
|
||||
* @return static
|
||||
* @phpstan-return static<T>
|
||||
*/
|
||||
public function filterBy(array $filters)
|
||||
{
|
||||
|
|
@ -502,7 +503,8 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
/**
|
||||
* @param string $value
|
||||
* @param string $field
|
||||
* @return T|null
|
||||
* @return FlexObjectInterface|null
|
||||
* @phpstan-return T|null
|
||||
*/
|
||||
public function find($value, $field = 'id')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace Grav\Framework\Flex;
|
|||
|
||||
use Exception;
|
||||
use Grav\Common\Debugger;
|
||||
use Grav\Common\File\CompiledJsonFile;
|
||||
use Grav\Common\File\CompiledYamlFile;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Inflector;
|
||||
|
|
@ -606,9 +607,11 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
|||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return ObjectInterface|null
|
||||
* @phpstan-return T|null
|
||||
*/
|
||||
protected function loadElement($key, $value): ?ObjectInterface
|
||||
{
|
||||
/** @phpstan-var T[] $objects */
|
||||
$objects = $this->getFlexDirectory()->loadObjects([$key => $value]);
|
||||
|
||||
return $objects ? reset($objects): null;
|
||||
|
|
@ -617,10 +620,14 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
|||
/**
|
||||
* @param array|null $entries
|
||||
* @return ObjectInterface[]
|
||||
* @phpstan-return T[]
|
||||
*/
|
||||
protected function loadElements(array $entries = null): array
|
||||
{
|
||||
return $this->getFlexDirectory()->loadObjects($entries ?? $this->getEntries());
|
||||
/** @phpstan-var T[] $objects */
|
||||
$objects = $this->getFlexDirectory()->loadObjects($entries ?? $this->getEntries());
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -823,7 +830,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
|||
|
||||
/**
|
||||
* @param FlexStorageInterface $storage
|
||||
* @return CompiledYamlFile|null
|
||||
* @return CompiledYamlFile|CompiledJsonFile|null
|
||||
*/
|
||||
protected static function getIndexFile(FlexStorageInterface $storage)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,11 +17,9 @@ use Grav\Common\Page\Interfaces\PageInterface;
|
|||
use Grav\Common\Page\Pages;
|
||||
use Grav\Common\Utils;
|
||||
use Grav\Common\Yaml;
|
||||
use Grav\Framework\Cache\CacheInterface;
|
||||
use Grav\Framework\File\Formatter\MarkdownFormatter;
|
||||
use Grav\Framework\File\Formatter\YamlFormatter;
|
||||
use Grav\Framework\Filesystem\Filesystem;
|
||||
use Grav\Framework\Flex\FlexDirectory;
|
||||
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
|
||||
use Grav\Framework\Flex\Interfaces\FlexIndexInterface;
|
||||
use Grav\Framework\Flex\Pages\FlexPageIndex;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user