PHP 8.1 return type fixes

This commit is contained in:
Matias Griese
2021-11-30 21:20:17 +02:00
parent c220b6e0c2
commit 4c3daf6e6f
22 changed files with 27 additions and 10 deletions

View File

@@ -248,6 +248,7 @@ abstract class BaseAsset extends PropertyObject
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return ['type' => $this->getType(), 'elements' => $this->getElements()];

View File

@@ -335,6 +335,7 @@ class Data implements DataInterface, ArrayAccess, \Countable, JsonSerializable,
/**
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->items;

View File

@@ -84,6 +84,7 @@ trait UserObjectLegacyTrait
* @return int
* @deprecated 1.6 Method makes no sense for user account.
*/
#[\ReturnTypeWillChange]
public function count()
{
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6', E_USER_DEPRECATED);

View File

@@ -32,6 +32,7 @@ class Package extends BasePackage implements \JsonSerializable
/**
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->data->toArray();

View File

@@ -129,6 +129,7 @@ abstract class Getters implements ArrayAccess, Countable
/**
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
{
if ($this->gettersVariable) {

View File

@@ -30,6 +30,7 @@ class Header implements ArrayAccess, ExportInterface, JsonSerializable
/**
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toArray();

View File

@@ -28,7 +28,7 @@ class Link implements RenderableInterface, MediaLinkInterface
/** @var array */
protected $attributes = [];
/** @var MediaObjectInterface */
/** @var MediaObjectInterface|MediaLinkInterface */
protected $source;
/**

View File

@@ -84,7 +84,7 @@ class Page implements PageInterface
protected $unpublish_date;
/** @var string */
protected $slug;
/** @var string */
/** @var string|null */
protected $route;
/** @var string|null */
protected $raw_route;

View File

@@ -295,6 +295,7 @@ class User extends Data implements UserInterface
* @return int
* @deprecated 1.6 Method makes no sense for user account.
*/
#[\ReturnTypeWillChange]
public function count()
{
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6', E_USER_DEPRECATED);

View File

@@ -206,6 +206,7 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
/**
* @return ArrayIterator|Traversable
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($this->actions);

View File

@@ -257,6 +257,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
/**
* {@inheritDoc}
*/
#[\ReturnTypeWillChange]
public function count()
{
return count($this->entries);
@@ -301,6 +302,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
*
* {@inheritDoc}
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($this->loadElements());
@@ -468,6 +470,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->loadCollection()->jsonSerialize();

View File

@@ -78,6 +78,7 @@ abstract class AbstractLazyCollection extends BaseAbstractLazyCollection impleme
/**
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
$this->initialize();

View File

@@ -97,6 +97,7 @@ class ArrayCollection extends BaseArrayCollection implements CollectionInterface
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toArray();

View File

@@ -520,6 +520,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
/**
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
$elements = [];

View File

@@ -656,6 +656,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
/**
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->getElements();

View File

@@ -176,6 +176,7 @@ class FormFlashFile implements UploadedFileInterface, JsonSerializable
/**
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->upload;

View File

@@ -181,6 +181,7 @@ trait ObjectCollectionTrait
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->doSerialize();

View File

@@ -172,6 +172,7 @@ trait ObjectTrait
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->doSerialize();

View File

@@ -235,6 +235,7 @@ class AbstractPagination implements PaginationInterface
/**
* @return ArrayIterator
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
$this->loadItems();

View File

@@ -392,6 +392,7 @@ class Session implements SessionInterface
/**
* @inheritdoc
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($_SESSION);

View File

@@ -108,6 +108,7 @@ interface SessionInterface extends IteratorAggregate
*
* @return ArrayIterator Return an ArrayIterator of $_SESSION
*/
#[\ReturnTypeWillChange]
public function getIterator();
/**

View File

@@ -33,13 +33,9 @@ parameters:
dynamicConstantNames:
- GRAV_CLI
ignoreErrors:
# New in phpstan 0.12, ignore them for now.
# New in phpstan 1, ignore them for now.
- '#Unsafe usage of new static\(\)#'
- '#Cannot instantiate interface Grav\\Framework\\#'
# TODO: phpstan bug #3875 (fixed, test if can be removed)
-
message: '#Unreachable statement - code above always terminates#'
path: '*/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php'
# FIXME: Bugs that need to be fixed
# FIXME: PHP 7.3 bug workaround
@@ -84,12 +80,12 @@ parameters:
-
message: '#unknown class Grav\\Plugin\\Admin#'
path: '*/system/src/Grav/Common/Flex/Pages/PageObject.php'
-
message: '#unknown class Grav\\Common\\Grav\\Plugin\\Form\\Forms#'
path: '*/system/src/Grav/Common/Session.php'
-
message: '#unknown class Grav\\Plugin\\Admin\\Admin#'
path: '*/system/src/Grav/Common/Flex/Types/Pages/PageObject.php'
-
message: '#unknown class Grav\\Plugin\\Form\\Forms#'
path: '*/system/src/Grav/Common/Processors/PagesProcessor.php'
# Can be ignored, after fopen there's always an $http_response_header locally available
-