mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Fix phpstan issues
This commit is contained in:
parent
9df7b35c65
commit
6c7064db93
|
|
@ -744,6 +744,7 @@ trait PageContentTrait
|
|||
}
|
||||
|
||||
if ($process_twig) {
|
||||
\assert(is_string($this->_content));
|
||||
$this->_content = $this->processTwig($this->_content);
|
||||
}
|
||||
}
|
||||
|
|
@ -753,6 +754,8 @@ trait PageContentTrait
|
|||
}
|
||||
}
|
||||
|
||||
\assert(is_string($this->_content));
|
||||
|
||||
// Handle summary divider
|
||||
$delimiter = $config->get('site.summary.delimiter', '===');
|
||||
$divider_pos = mb_strpos($this->_content, "<p>{$delimiter}</p>");
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use Grav\Framework\File\Formatter\YamlFormatter;
|
|||
use Grav\Framework\Filesystem\Filesystem;
|
||||
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
|
||||
use Grav\Framework\Flex\Interfaces\FlexIndexInterface;
|
||||
use Grav\Framework\Flex\Pages\FlexPageCollection;
|
||||
use Grav\Framework\Flex\Pages\FlexPageIndex;
|
||||
use Grav\Framework\Flex\Pages\FlexPageObject;
|
||||
use InvalidArgumentException;
|
||||
|
|
@ -298,7 +299,7 @@ trait PageLegacyTrait
|
|||
|
||||
$parentStorageKey = ltrim($filesystem->dirname("/{$this->getMasterKey()}"), '/');
|
||||
|
||||
/** @var FlexPageIndex $index */
|
||||
/** @var FlexPageIndex<FlexPageObject,FlexPageCollection<FlexPageObject>> $index */
|
||||
$index = $this->getFlexDirectory()->getIndex();
|
||||
|
||||
if ($parent) {
|
||||
|
|
@ -321,6 +322,7 @@ trait PageLegacyTrait
|
|||
if ($this instanceof FlexPageObject) {
|
||||
$key = trim($parentKey . '/' . $this->folder(), '/');
|
||||
$key = preg_replace(static::PAGE_ORDER_PREFIX_REGEX, '', $key);
|
||||
\assert(is_string($key));
|
||||
} else {
|
||||
$key = trim($parentKey . '/' . basename($this->getKey()), '/');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Grav\Framework\Flex\Traits;
|
||||
|
||||
use Grav\Framework\Flex\FlexCollection;
|
||||
use Grav\Framework\Flex\FlexDirectory;
|
||||
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
|
||||
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
|
||||
use RuntimeException;
|
||||
use function in_array;
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ trait FlexRelatedDirectoryTrait
|
|||
/**
|
||||
* @param string $type
|
||||
* @param string $property
|
||||
* @return FlexCollectionInterface
|
||||
* @return FlexCollectionInterface<FlexObjectInterface>
|
||||
*/
|
||||
protected function getCollectionByProperty($type, $property)
|
||||
{
|
||||
|
|
@ -34,7 +34,7 @@ trait FlexRelatedDirectoryTrait
|
|||
$collection = $directory->getCollection();
|
||||
$list = $this->getNestedProperty($property) ?: [];
|
||||
|
||||
/** @var FlexCollection $collection */
|
||||
/** @var FlexCollectionInterface<FlexObjectInterface> $collection */
|
||||
$collection = $collection->filter(static function ($object) use ($list) {
|
||||
return in_array($object->getKey(), $list, true);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use function is_object;
|
|||
* @package Grav\Framework\Object
|
||||
*
|
||||
* @template TKey as array-key
|
||||
* @template T as object
|
||||
* @template T as ObjectInterface
|
||||
*/
|
||||
trait ObjectCollectionTrait
|
||||
{
|
||||
|
|
@ -366,6 +366,7 @@ trait ObjectCollectionTrait
|
|||
{
|
||||
$collections = [];
|
||||
foreach ($this->group($property) as $id => $elements) {
|
||||
/** @phpstan-var static<TKey,T> $collection */
|
||||
$collection = $this->createFrom($elements);
|
||||
|
||||
$collections[$id] = $collection;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use function array_slice;
|
|||
* Class contains a collection of objects.
|
||||
*
|
||||
* @template TKey of array-key
|
||||
* @template T of object
|
||||
* @template T of \Grav\Framework\Object\Interfaces\ObjectInterface
|
||||
* @extends ArrayCollection<TKey,T>
|
||||
* @implements NestedObjectCollectionInterface<TKey,T>
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class UriFactory
|
|||
|
||||
$encodedUrl = preg_replace_callback(
|
||||
'%[^:/@?&=#]+%u',
|
||||
function ($matches) {
|
||||
static function ($matches) {
|
||||
return rawurlencode($matches[0]);
|
||||
},
|
||||
$url
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user