More minor fixes for PHP 8.1

This commit is contained in:
Matias Griese 2021-12-08 10:58:38 +02:00
parent a56453cf0a
commit 6079562c90
7 changed files with 25 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -125,6 +125,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
*/
public function getFlexFeatures(): array
{
/** @var array $implements */
$implements = class_implements($this);
$list = [];

View File

@ -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);
}

View File

@ -133,6 +133,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
*/
public function getFlexFeatures(): array
{
/** @var array $implements */
$implements = class_implements($this->getFlexDirectory()->getCollectionClass());
$list = [];

View File

@ -163,6 +163,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
*/
public function getFlexFeatures(): array
{
/** @var array $implements */
$implements = class_implements($this);
$list = [];

View File

@ -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;
}
/**