mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
More minor fixes for PHP 8.1
This commit is contained in:
parent
a56453cf0a
commit
6079562c90
|
|
@ -145,31 +145,37 @@ abstract class AbstractIndexCollection implements CollectionInterface
|
|||
/**
|
||||
* Required by interface ArrayAccess.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
* @param string|int|null $offset
|
||||
* @return bool
|
||||
* @phpstan-param TKey|null $offset
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
/** @phpstan-ignore-next-line phpstan bug? */
|
||||
return $offset !== null ? $this->containsKey($offset) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by interface ArrayAccess.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
* @param string|int|null $offset
|
||||
* @return mixed
|
||||
* @phpstan-param TKey|null $offset
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
/** @phpstan-ignore-next-line phpstan bug? */
|
||||
return $offset !== null ? $this->get($offset) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by interface ArrayAccess.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
* @param string|int|null $offset
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @phpstan-param TKey|null $offset
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
|
|
@ -178,6 +184,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
|
|||
if (null === $offset) {
|
||||
$this->add($value);
|
||||
} else {
|
||||
/** @phpstan-ignore-next-line phpstan bug? */
|
||||
$this->set($offset, $value);
|
||||
}
|
||||
}
|
||||
|
|
@ -185,13 +192,15 @@ abstract class AbstractIndexCollection implements CollectionInterface
|
|||
/**
|
||||
* Required by interface ArrayAccess.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
* @param string|int|null $offset
|
||||
* @return void
|
||||
* @phpstan-param TKey|null $offset
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
if ($offset !== null) {
|
||||
/** @phpstan-ignore-next-line phpstan bug? */
|
||||
$this->remove($offset);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,6 +239,8 @@ class Filesystem implements FilesystemInterface
|
|||
|
||||
if (null !== $scheme) {
|
||||
$info['scheme'] = $scheme;
|
||||
|
||||
/** @phpstan-ignore-next-line because pathinfo('') doesn't have dirname */
|
||||
$dirname = $info['dirname'] ?? '.';
|
||||
|
||||
if ('' !== $dirname && '.' !== $dirname) {
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
|||
*/
|
||||
public function getFlexFeatures(): array
|
||||
{
|
||||
/** @var array $implements */
|
||||
$implements = class_implements($this);
|
||||
|
||||
$list = [];
|
||||
|
|
|
|||
|
|
@ -907,6 +907,10 @@ class FlexDirectory implements FlexDirectoryInterface
|
|||
$className = $storage['class'] ?? SimpleStorage::class;
|
||||
$options = $storage['options'] ?? [];
|
||||
|
||||
if (!is_a($className, FlexStorageInterface::class, true)) {
|
||||
throw new \RuntimeException('Bad storage class: ' . $className);
|
||||
}
|
||||
|
||||
return new $className($options);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
|
|||
*/
|
||||
public function getFlexFeatures(): array
|
||||
{
|
||||
/** @var array $implements */
|
||||
$implements = class_implements($this->getFlexDirectory()->getCollectionClass());
|
||||
|
||||
$list = [];
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
*/
|
||||
public function getFlexFeatures(): array
|
||||
{
|
||||
/** @var array $implements */
|
||||
$implements = class_implements($this);
|
||||
|
||||
$list = [];
|
||||
|
|
|
|||
|
|
@ -155,9 +155,10 @@ class FlexPageCollection extends FlexCollection
|
|||
public function adjacentSibling($path, $direction = 1)
|
||||
{
|
||||
$keys = $this->getKeys();
|
||||
$direction = (int)$direction;
|
||||
$pos = array_search($path, $keys, true);
|
||||
|
||||
if ($pos !== false) {
|
||||
if (is_int($pos)) {
|
||||
$pos += $direction;
|
||||
if (isset($keys[$pos])) {
|
||||
return $this[$keys[$pos]];
|
||||
|
|
@ -177,7 +178,7 @@ class FlexPageCollection extends FlexCollection
|
|||
{
|
||||
$pos = array_search($path, $this->getKeys(), true);
|
||||
|
||||
return $pos !== false ? $pos : null;
|
||||
return is_int($pos) ? $pos : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user