From a06520337f2fd5bcb52fd649eeed7a4f08f46f8d Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 15 Nov 2019 13:21:20 +0200 Subject: [PATCH] Fully comply phpstan level2! --- system/src/Grav/Common/Page/Page.php | 4 ++-- system/src/Grav/Common/Twig/Twig.php | 12 +++++++----- tests/phpstan/phpstan.neon | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 2da55856a..89330edb9 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1217,8 +1217,8 @@ class Page implements PageInterface /** * Gets and sets the associated media as found in the page folder. * - * @param MediaCollectionInterface|Media $var Representation of associated media. - * @return MediaCollectionInterface|Media Representation of associated media. + * @param Media $var Representation of associated media. + * @return Media Representation of associated media. */ public function media($var = null) { diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index 2984d6652..301c5c414 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -26,6 +26,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\TwigFilter; use Twig\TwigFunction; @@ -455,13 +456,14 @@ class Twig $twig_extension = $extension ? '.'. $extension .TWIG_EXT : TEMPLATE_EXT; $template_file = $this->template($page->template() . $twig_extension); - if ($this->twig->getLoader()->exists($template_file)) { + $loader = $this->twig->getLoader(); + if ($loader instanceof ExistsLoaderInterface && $loader->exists($template_file)) { return $template_file; - } else { - // Default to HTML - $page->templateFormat('html'); - return $template . TEMPLATE_EXT; } + + // Default to HTML + $page->templateFormat('html'); + return $template . TEMPLATE_EXT; } /** diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon index 413a3030f..8996656a8 100644 --- a/tests/phpstan/phpstan.neon +++ b/tests/phpstan/phpstan.neon @@ -71,7 +71,7 @@ parameters: path: 'system/src/Grav/Common/Page/Pages.php' - message: '#on an unknown class Grav\\Plugin\\Admin#' - path: 'system/src/Grav/Common/Page/Flex/PageObject.php' + path: 'system/src/Grav/Common/Flex/Pages/PageObject.php' - message: '#Call to method getFlash\(\) on an unknown class Grav\\Common\\Grav\\Plugin\\Form\\Forms#' path: 'system/src/Grav/Common/Session.php'