diff --git a/system/src/Grav/Common/Data/Data.php b/system/src/Grav/Common/Data/Data.php index 76f38762e..bfae2dae8 100644 --- a/system/src/Grav/Common/Data/Data.php +++ b/system/src/Grav/Common/Data/Data.php @@ -26,7 +26,7 @@ class Data implements DataInterface, \ArrayAccess, \Countable, \JsonSerializable /** @var array */ protected $items; - /** @var Blueprints */ + /** @var Blueprint */ protected $blueprints; /** @var File */ diff --git a/system/src/Grav/Common/Language/Language.php b/system/src/Grav/Common/Language/Language.php index e83f72f7e..70a82f0cd 100644 --- a/system/src/Grav/Common/Language/Language.php +++ b/system/src/Grav/Common/Language/Language.php @@ -11,6 +11,7 @@ namespace Grav\Common\Language; use Grav\Common\Grav; use Grav\Common\Config\Config; +use Negotiation\AcceptLanguage; use Negotiation\LanguageNegotiator; class Language @@ -208,7 +209,7 @@ class Language $negotiator = new LanguageNegotiator(); $best_language = $negotiator->getBest($accept, $this->languages); - if ($best_language) { + if ($best_language instanceof AcceptLanguage) { $this->active = $best_language->getType(); } else { $this->active = $this->getDefault(); diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index adf938495..5c16bbabb 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -23,6 +23,7 @@ use Grav\Common\Taxonomy; use Grav\Common\Uri; use Grav\Common\Utils; use Grav\Common\Yaml; +use Negotiation\Accept; use Negotiation\Negotiator; use RocketTheme\Toolbox\Event\Event; use RocketTheme\Toolbox\File\MarkdownFile; @@ -1405,7 +1406,8 @@ class Page implements PageInterface $priorities = Utils::getMimeTypes($supported_types); $media_type = $negotiator->getBest($http_accept, $priorities); - $mimetype = $media_type ? $media_type->getValue() : ''; + $mimetype = $media_type instanceof Accept ? $media_type->getValue() : ''; + $this->template_format = Utils::getExtensionByMime($mimetype); return $this->template_format; diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon index 3e169581f..d55a66070 100644 --- a/tests/phpstan/phpstan.neon +++ b/tests/phpstan/phpstan.neon @@ -19,7 +19,16 @@ parameters: - Grav\Common\Session ignoreErrors: - # Errors that needs some more thinking (design...) + # FIXME: Bugs that need to be fixed + + # TODO: Errors that needs some more thinking (bad design?) + - '#Access to an undefined property RocketTheme\\Toolbox\\Event\\Event::#' + - '#Access to an undefined property Grav\\Common\\Data\\Blueprint::#' + - '#Access to an undefined property Grav\\Common\\Media\\Interfaces\\MediaObjectInterface::#' + - '#Access to an undefined property Grav\\Common\\Page\\Interfaces\\PageInterface::#' + - + message: '#Cannot call method path\(\) on string#' + path: 'system/src/Grav/Common/Page/Media.php' # Needed: full coverage (probably with admin plugin...) then redesign constructor - @@ -28,7 +37,7 @@ parameters: # Needed: psr-17 (http-factories) support (through decorator or further investigations) - - message: '#Call to an undefined static method Grav\\Framework\\Psr7\\Stream::create\(\).#' + message: '#Call to an undefined static method Grav\\Framework\\Psr7\\Stream::create\(\)#' path: 'system/src/Grav/Framework/Form/FormFlashFile.php' # PSR-16 Exception interfaces do not extend \Throwable @@ -37,7 +46,7 @@ parameters: # Medium __call() methods - '#Call to an undefined method Grav\\Common\\Page\\Medium\\(\w*)Medium::#' - # Those errors are about plugins (need to find a better solution) + # These errors are about plugins (need to find a better solution) - message: '#Call to static method sendEmail\(\) on an unknown class Grav\\Plugin\\Email\\Utils#' path: 'system/src/Grav/Common/Scheduler/Job.php' @@ -50,11 +59,11 @@ parameters: # Can be ignored, after fopen there's always an $http_response_header locally available - - message: '#Variable \$http_response_header in isset\(\) always exists and is not nullable.#' + message: '#Variable \$http_response_header in isset\(\) always exists and is not nullable#' path: 'system/src/Grav/Common/GPM/Response.php' - # Those errors can be ignored (they depends on installed extensions) + # These errors can be ignored (they depend on installed extensions) - message: '#Instantiated class (Memcache|Memcached|Redis|RedisException) not found#' path: 'system/src/Grav/Common/Cache.php'