Phpstan fixes

This commit is contained in:
Matias Griese
2022-02-19 15:20:06 +02:00
parent f5e21645f6
commit 46f2a81b21
6 changed files with 18 additions and 10 deletions

View File

@@ -10,7 +10,6 @@
namespace Grav\Common;
use DirectoryIterator;
use Doctrine\Common\Cache\Cache as DoctrineCache;
use Doctrine\Common\Cache\CacheProvider;
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
use Exception;
@@ -332,7 +331,7 @@ class Cache extends Getters
* If there is no config option for $driver in the config, or it's set to 'auto', it will
* pick the best option based on which cache extensions are installed.
*
* @return DoctrineCache The cache driver to use
* @return CacheProvider The cache driver to use
*/
public function getCacheDriver(AdapterInterface $adapter = null)
{
@@ -340,7 +339,12 @@ class Cache extends Getters
$adapter = $this->getCacheAdapter();
}
return DoctrineProvider::wrap($adapter);
$cache = DoctrineProvider::wrap($adapter);
if (!$cache instanceof CacheProvider) {
throw new \RuntimeException('Internal error');
}
return $cache;
}
/**

View File

@@ -57,7 +57,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
public const ORDER_LIST_REGEX = '/(\/\d+)\.[^\/]+/u';
public const PAGE_ROUTE_REGEX = '/\/\d+\./u';
/** @var PageObject|array */
/** @var T|array */
protected $_root;
/** @var array|null */
protected $_params;

View File

@@ -87,9 +87,9 @@ class UserObject extends FlexObject implements UserInterface, Countable
protected $_uploads_original;
/** @var FileInterface|null */
protected $_storage;
/** @var UserGroupIndex */
/** @var UserGroupIndex|null */
protected $_groups;
/** @var Access */
/** @var Access|null */
protected $_access;
/** @var array|null */
protected $access;

View File

@@ -46,7 +46,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
* Add a single page to a collection
*
* @param PageInterface $page
* @return $this
* @return $this|PageCollectionInterface<TKey,T>
*/
public function addPage(PageInterface $page);
@@ -63,7 +63,7 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
*
* Create a copy of this collection
*
* @return static
* @return static<TKey,T>
*/
public function copy();

View File

@@ -753,6 +753,10 @@ class Pages
break;
}
if (!$collection instanceof Collection) {
$collection = new Collection($collection->toArray());
}
return $collection;
}

View File

@@ -415,6 +415,7 @@ class FlexDirectory implements FlexDirectoryInterface
$config = $this->getConfig('object.cache.' . $namespace);
if (empty($config['enabled'])) {
$cache = new MemoryCache('flex-objects-' . $this->getFlexType());
$cache->setValidation(false);
} else {
$lifetime = $config['lifetime'] ?? 60;
@@ -431,10 +432,9 @@ class FlexDirectory implements FlexDirectoryInterface
$debugger->addException($e);
$cache = new MemoryCache('flex-objects-' . $this->getFlexType());
$cache->setValidation(false);
}
// Disable cache key validation.
$cache->setValidation(false);
$this->cache[$namespace] = $cache;
}