mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Some phpstan level 6 fixes
This commit is contained in:
parent
e991056106
commit
37f69d89cc
|
|
@ -20,6 +20,7 @@ use Grav\Framework\Form\Traits\FormTrait;
|
|||
use Grav\Framework\Route\Route;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Template;
|
||||
use Twig\TemplateWrapper;
|
||||
|
||||
/**
|
||||
|
|
@ -277,7 +278,7 @@ class FlexForm implements FlexFormInterface
|
|||
|
||||
/**
|
||||
* @param string $layout
|
||||
* @return TemplateWrapper
|
||||
* @return Template|TemplateWrapper
|
||||
* @throws LoaderError
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -312,9 +312,10 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
|||
// Ordering can be done by using index only.
|
||||
$previous = null;
|
||||
foreach (array_reverse($orderings) as $field => $ordering) {
|
||||
$field = (string)$field;
|
||||
if ($this->getKeyField() === $field) {
|
||||
$keys = $this->getKeys();
|
||||
$search = array_combine($keys, $keys);
|
||||
$search = array_combine($keys, $keys) ?: [];
|
||||
} elseif ($field === 'flex_key') {
|
||||
$search = $this->getFlexKeys();
|
||||
} else {
|
||||
|
|
@ -462,7 +463,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
|||
$first = reset($entries);
|
||||
if ($first) {
|
||||
$keys = array_keys($first);
|
||||
$keys = array_combine($keys, $keys);
|
||||
$keys = array_combine($keys, $keys) ?: [];
|
||||
} else {
|
||||
$keys = [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ use Psr\SimpleCache\InvalidArgumentException;
|
|||
use RocketTheme\Toolbox\Event\Event;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Template;
|
||||
use Twig\TemplateWrapper;
|
||||
|
||||
/**
|
||||
|
|
@ -391,7 +392,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
}
|
||||
|
||||
try {
|
||||
$data = $cache ? $cache->get($key) : null;
|
||||
$data = $cache && $key ? $cache->get($key) : null;
|
||||
|
||||
$block = $data ? HtmlBlock::fromArray($data) : null;
|
||||
} catch (InvalidArgumentException $e) {
|
||||
|
|
@ -410,7 +411,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
}
|
||||
|
||||
if (!$block) {
|
||||
$block = HtmlBlock::create($key);
|
||||
$block = HtmlBlock::create($key ?: null);
|
||||
$block->setChecksum($checksum);
|
||||
if ($key === false) {
|
||||
$block->disableCache();
|
||||
|
|
@ -434,7 +435,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
$block->setContent($output);
|
||||
|
||||
try {
|
||||
$cache && $block->isCached() && $cache->set($key, $block->toArray());
|
||||
$cache && $key && $block->isCached() && $cache->set($key, $block->toArray());
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$debugger->addException($e);
|
||||
}
|
||||
|
|
@ -541,7 +542,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
$result = $this->getFlexDirectory()->getStorage()->replaceRows([$this->getStorageKey() => $this->prepareStorage()]);
|
||||
|
||||
$value = reset($result);
|
||||
$storageKey = key($result);
|
||||
$storageKey = (string)key($result);
|
||||
if ($value && $storageKey) {
|
||||
$this->setStorageKey($storageKey);
|
||||
if (!$this->hasKey()) {
|
||||
|
|
@ -558,7 +559,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
if (method_exists($this, 'clearMediaCache')) {
|
||||
$this->clearMediaCache();
|
||||
}
|
||||
} catch (InvalidArgumentException $e) {
|
||||
} catch (\Exception $e) {
|
||||
/** @var Debugger $debugger */
|
||||
$debugger = Grav::instance()['debugger'];
|
||||
$debugger->addException($e);
|
||||
|
|
@ -586,7 +587,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
if (method_exists($this, 'clearMediaCache')) {
|
||||
$this->clearMediaCache();
|
||||
}
|
||||
} catch (InvalidArgumentException $e) {
|
||||
} catch (\Exception $e) {
|
||||
/** @var Debugger $debugger */
|
||||
$debugger = Grav::instance()['debugger'];
|
||||
$debugger->addException($e);
|
||||
|
|
@ -807,7 +808,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
|
||||
/**
|
||||
* @param string $layout
|
||||
* @return TemplateWrapper
|
||||
* @return Template|TemplateWrapper
|
||||
* @throws LoaderError
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ abstract class AbstractFilesystemStorage implements FlexStorageInterface
|
|||
return $path;
|
||||
}
|
||||
|
||||
return (string) $locator->findResource($path) ?: $locator->findResource($path, true, true);
|
||||
return (string)($locator->findResource($path) ?: $locator->findResource($path, true, true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -455,6 +455,8 @@ class FolderStorage extends AbstractFilesystemStorage
|
|||
protected function initOptions(array $options): void
|
||||
{
|
||||
$extension = $this->dataFormatter->getDefaultFileExtension();
|
||||
|
||||
/** @var string $pattern */
|
||||
$pattern = !empty($options['pattern']) ? $options['pattern'] : $this->dataPattern;
|
||||
|
||||
$this->dataFolder = $options['folder'];
|
||||
|
|
|
|||
|
|
@ -227,7 +227,12 @@ class SimpleStorage extends AbstractFilesystemStorage
|
|||
$keys = array_keys($this->data);
|
||||
$keys[array_search($src, $keys, true)] = $dst;
|
||||
|
||||
$this->data = array_combine($keys, $this->data);
|
||||
$data = array_combine($keys, $this->data);
|
||||
if (false === $data) {
|
||||
throw new \LogicException('Bad data');
|
||||
}
|
||||
|
||||
$this->data = $data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,14 +41,15 @@ parameters:
|
|||
message: '#Grav\\Common\\GPM\\Remote\\GravCore::__construct\(\) does not call parent constructor from Grav\\Common\\GPM\\Remote\\AbstractPackageCollection#'
|
||||
path: 'system/src/Grav/Common/GPM/Remote/GravCore.php'
|
||||
|
||||
# PSR-16 Exception interfaces do not extend \Throwable
|
||||
- '#PHPDoc tag \@throws with type Psr\\SimpleCache\\(CacheException|InvalidArgumentException) is not subtype of Throwable#'
|
||||
- '#expects Exception, Psr\\SimpleCache\\InvalidArgumentException&Throwable given#'
|
||||
|
||||
# Needed: psr-17 (http-factories) support (through decorator or further investigations)
|
||||
-
|
||||
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
|
||||
- '#PHPDoc tag \@throws with type Psr\\SimpleCache\\(CacheException|InvalidArgumentException) is not subtype of Throwable#'
|
||||
|
||||
# Medium __call() methods
|
||||
- '#Call to an undefined method Grav\\Common\\Page\\Medium\\(\w*)Medium::#'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user