Some phpstan fixes

This commit is contained in:
Matias Griese
2019-11-18 11:21:25 +02:00
parent fc70a50fd6
commit ce5729ba53
3 changed files with 24 additions and 11 deletions

View File

@@ -367,7 +367,7 @@ interface PageLegacyInterface
/**
* Returns children of this page.
*
* @return \Grav\Common\Page\Collection
* @return Collection
*/
public function children();

View File

@@ -69,7 +69,7 @@ class Page implements PageInterface
protected $slug;
/** @var string */
protected $route;
/** @var string */
/** @var string|null */
protected $raw_route;
/** @var string */
protected $url;
@@ -89,15 +89,15 @@ class Page implements PageInterface
protected $frontmatter;
/** @var string */
protected $language;
/** @var string */
/** @var string|null */
protected $content;
/** @var array */
protected $content_meta;
/** @var string */
protected $summry;
/** @var string|null */
protected $summary;
/** @var string */
protected $raw_content;
/** @var array */
/** @var array|null */
protected $metadata;
/** @var string */
protected $title;
@@ -115,13 +115,13 @@ class Page implements PageInterface
protected $order_by;
/** @var string */
protected $order_dir;
/** @var array */
/** @var array|string|null */
protected $order_manual;
/** @var bool */
protected $modular_twig;
/** @var array */
protected $process;
/** @var int */
/** @var int|null */
protected $summary_size;
/** @var bool */
protected $markdown_extra;

View File

@@ -21,6 +21,7 @@ use Grav\Framework\Cache\CacheInterface;
use Grav\Framework\File\Formatter\MarkdownFormatter;
use Grav\Framework\File\Formatter\YamlFormatter;
use Grav\Framework\Flex\FlexDirectory;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexIndexInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
use Grav\Framework\Flex\Pages\FlexPageIndex;
@@ -867,8 +868,12 @@ trait PageLegacyTrait
public function isFirst(): bool
{
$parent = $this->parent();
$children = $parent ? $parent->children() : null;
if ($children instanceof FlexCollectionInterface) {
$children = $children->withKeyField();
}
return $parent ? $parent->children()->withKeyField()->isFirst($this->getKey()) : true;
return $children instanceof PageCollectionInterface ? $children->isFirst($this->getKey()) : true;
}
/**
@@ -879,8 +884,12 @@ trait PageLegacyTrait
public function isLast(): bool
{
$parent = $this->parent();
$children = $parent ? $parent->children() : null;
if ($children instanceof FlexCollectionInterface) {
$children = $children->withKeyField();
}
return $parent ? $parent->children()->withKeyField()->isLast($this->getKey()) : true;
return $children instanceof PageCollectionInterface ? $children->isLast($this->getKey()) : true;
}
/**
@@ -913,8 +922,12 @@ trait PageLegacyTrait
public function adjacentSibling($direction = 1)
{
$parent = $this->parent();
$children = $parent ? $parent->children() : null;
if ($children instanceof FlexCollectionInterface) {
$children = $children->withKeyField();
}
return $parent ? $parent->children()->withKeyField()->adjacentSibling($this->getKey(), $direction) : false;
return $children instanceof PageCollectionInterface ? $children->adjacentSibling($this->getKey(), $direction) : false;
}
/**