mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Fixed some phpstan errors
This commit is contained in:
parent
8256af5cfa
commit
a57c18f63f
|
|
@ -47,10 +47,10 @@ 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 static shuffle()
|
||||
* @method static select(array $keys)
|
||||
* @method static unselect(array $keys)
|
||||
* @method static createFrom(array $elements, string $keyField = null)
|
||||
* @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
|
||||
|
|
|
|||
|
|
@ -118,6 +118,8 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
|
|||
$element = $element->getTranslation(ltrim($params, '.'));
|
||||
}
|
||||
|
||||
\assert($element instanceof PageObject);
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ use Twig\Extension\DebugExtension;
|
|||
use Twig\Extension\StringLoaderExtension;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
use Twig\Loader\ChainLoader;
|
||||
use Twig\Loader\ExistsLoaderInterface;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
use Twig\Profiler\Profile;
|
||||
use Twig\TwigFilter;
|
||||
|
|
@ -160,7 +161,7 @@ class Twig
|
|||
|
||||
$this->twig = new TwigEnvironment($loader_chain, $params);
|
||||
|
||||
$this->twig->registerUndefinedFunctionCallback(function ($name) use ($config) {
|
||||
$this->twig->registerUndefinedFunctionCallback(function (string $name) use ($config) {
|
||||
$allowed = $config->get('system.twig.safe_functions');
|
||||
if (is_array($allowed) && in_array($name, $allowed, true) && function_exists($name)) {
|
||||
return new TwigFunction($name, $name);
|
||||
|
|
@ -184,7 +185,7 @@ class Twig
|
|||
return false;
|
||||
});
|
||||
|
||||
$this->twig->registerUndefinedFilterCallback(function ($name) use ($config) {
|
||||
$this->twig->registerUndefinedFilterCallback(function (string $name) use ($config) {
|
||||
$allowed = $config->get('system.twig.safe_filters');
|
||||
if (is_array($allowed) && in_array($name, $allowed, true) && function_exists($name)) {
|
||||
return new TwigFilter($name, $name);
|
||||
|
|
@ -514,6 +515,8 @@ class Twig
|
|||
$twig_extension = $extension ? '.'. $extension .TWIG_EXT : TEMPLATE_EXT;
|
||||
$template_file = $this->template($page->template() . $twig_extension);
|
||||
|
||||
// TODO: no longer needed in Twig 3.
|
||||
/** @var ExistsLoaderInterface $loader */
|
||||
$loader = $this->twig->getLoader();
|
||||
if ($loader->exists($template_file)) {
|
||||
// template.xxx.twig
|
||||
|
|
|
|||
|
|
@ -164,7 +164,6 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
|||
return $this->orderBy($orderings);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @see FlexCollectionInterface::filterBy()
|
||||
|
|
|
|||
|
|
@ -22,16 +22,18 @@ final class DeferredNodeVisitorCompat implements NodeVisitorInterface
|
|||
{
|
||||
private $hasDeferred = false;
|
||||
|
||||
public function enterNode(\Twig_NodeInterface $node, Environment $env) : Node
|
||||
public function enterNode(\Twig_NodeInterface $node, Environment $env): Node
|
||||
{
|
||||
if (!$this->hasDeferred && $node instanceof DeferredBlockNode) {
|
||||
$this->hasDeferred = true;
|
||||
}
|
||||
|
||||
\assert($node instanceof Node);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
public function leaveNode(\Twig_NodeInterface $node, Environment $env) : ?Node
|
||||
public function leaveNode(\Twig_NodeInterface $node, Environment $env): ?Node
|
||||
{
|
||||
if ($this->hasDeferred && $node instanceof ModuleNode) {
|
||||
$node->setNode('constructor_end', new Node([new DeferredExtensionNode(), $node->getNode('constructor_end')]));
|
||||
|
|
@ -39,6 +41,8 @@ final class DeferredNodeVisitorCompat implements NodeVisitorInterface
|
|||
$this->hasDeferred = false;
|
||||
}
|
||||
|
||||
\assert($node instanceof Node);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ parameters:
|
|||
-
|
||||
message: '#Cannot call method path\(\) on string#'
|
||||
path: '*/system/src/Grav/Common/Page/Media.php'
|
||||
- '"FlexCollectionInterface::filterBy\(\) invoked with 2 parameters"'
|
||||
|
||||
# TODO: system.twig.umask_fix will not work with Twig 2 anymore
|
||||
-
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user