Skip to content

Fixes to launch Magento with PHP 8.1 - part 1 #34637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function __construct(
*
* @return array
*/
#[\ReturnTypeWillChange]
public function current()
{
$current = parent::current();
Expand Down
12 changes: 8 additions & 4 deletions app/code/Magento/Analytics/ReportXml/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public function __construct(
}

/**
* Returns query select
*
* @return Select
*/
public function getSelect()
Expand All @@ -61,6 +63,8 @@ public function getSelect()
}

/**
* Returns Connection name
*
* @return string
*/
public function getConnectionName()
Expand All @@ -69,6 +73,8 @@ public function getConnectionName()
}

/**
* Returns configuration
*
* @return array
*/
public function getConfig()
Expand All @@ -77,11 +83,9 @@ public function getConfig()
}

/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return [
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Backend/Model/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function getParentItems($itemId)
*
* @param \Magento\Backend\Model\Menu $menu
* @param string $itemId
* @param array &$parents
* @param array $parents
* @return bool
*/
protected function _findParentItems($menu, $itemId, &$parents)
Expand All @@ -267,6 +267,7 @@ protected function _findParentItems($menu, $itemId, &$parents)
*
* @return string
*/
#[\ReturnTypeWillChange]
public function serialize()
{
return $this->serializer->serialize($this->toArray());
Expand Down Expand Up @@ -294,6 +295,7 @@ public function toArray()
* @return void
* @since 100.2.0
*/
#[\ReturnTypeWillChange]
public function unserialize($serialized)
{
$data = $this->serializer->unserialize($serialized);
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Backend/Model/Menu/Filter/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Iterator extends \FilterIterator
*
* @param \Iterator $iterator
*/
public function __construct(\Iterator $iterator)
public function __construct(\Iterator $iterator) // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod
{
parent::__construct($iterator);
}
Expand All @@ -27,6 +27,7 @@ public function __construct(\Iterator $iterator)
*
* @return bool true if the current element is acceptable, otherwise false.
*/
#[\ReturnTypeWillChange]
public function accept()
{
return !($this->current()->isDisabled() || !$this->current()->isAllowed());
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Backend/Model/Menu/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Iterator extends \ArrayIterator
*
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
{
$this->ksort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
namespace Magento\Catalog\Model\ResourceModel\Product\Collection;

/**
* Class ProductLimitation
*
* @api
* @since 101.0.0
*/
Expand All @@ -31,47 +29,61 @@ class ProductLimitation implements \ArrayAccess
private $productLimitationFilters = [];

/**
* Check if the value is set for the given offset.
*
* @param string $offset
* @return bool
* @since 101.0.0
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return array_key_exists($offset, $this->productLimitationFilters);
}

/**
* Get the value by provided offset.
*
* @param string $offset
* @return mixed
* @since 101.0.0
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->productLimitationFilters[$offset];
}

/**
* Set the given offset to filters.
*
* @param string $offset
* @param mixed $value
* @return void
* @since 101.0.0
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
$this->productLimitationFilters[$offset] = $value;
}

/**
* Unset the given offset from filters.
*
* @param string $offset
* @return void
* @since 101.0.0
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->productLimitationFilters[$offset]);
}

/**
* Returns Store ID.
*
* @return int|null
* @since 101.0.0
*/
Expand All @@ -81,6 +93,8 @@ public function getStoreId()
}

/**
* Returns category ID.
*
* @return int|null
* @since 101.0.0
*/
Expand All @@ -90,6 +104,8 @@ public function getCategoryId()
}

/**
* Returns is category an anchor.
*
* @return int|null
* @since 101.0.0
*/
Expand All @@ -99,6 +115,8 @@ public function getCategoryIsAnchor()
}

/**
* Returns visibility value.
*
* @return array|int|null
* @since 101.0.0
*/
Expand All @@ -108,6 +126,8 @@ public function getVisibility()
}

/**
* Returns website IDs.
*
* @return array|int|null
* @since 101.0.0
*/
Expand All @@ -117,6 +137,8 @@ public function getWebsiteIds()
}

/**
* Returns Store table.
*
* @return string|null
* @since 101.0.0
*/
Expand All @@ -137,13 +159,15 @@ public function isUsingPriceIndex()
}

/**
* Sets 'Use Price' index flag.
*
* @param bool $value
* @return void
* @since 101.0.0
*/
public function setUsePriceIndex($value)
{
$this->offsetSet('use_price_index', (bool)$value);
$this->offsetSet('use_price_index', (bool) $value);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function setElements(array $elements, $scope)
*
* @return \Magento\Config\Model\Config\StructureElementInterface
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->_flyweight;
Expand All @@ -79,6 +80,7 @@ public function current()
*
* @return void Any returned value is ignored.
*/
#[\ReturnTypeWillChange]
public function next()
{
next($this->_elements);
Expand Down Expand Up @@ -106,6 +108,7 @@ protected function _initFlyweight(array $element)
*
* @return void
*/
#[\ReturnTypeWillChange]
public function key()
{
key($this->_elements);
Expand All @@ -117,6 +120,7 @@ public function key()
* @return bool The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
*/
#[\ReturnTypeWillChange]
public function valid()
{
return (bool)current($this->_elements);
Expand All @@ -127,6 +131,7 @@ public function valid()
*
* @return void Any returned value is ignored.
*/
#[\ReturnTypeWillChange]
public function rewind()
{
reset($this->_elements);
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Customer/Model/Indexer/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function addFieldToFilter($attribute, $condition = null)
/**
* @inheritdoc
*/
#[\ReturnTypeWillChange]
public function count()
{
return $this->customerCollection->getSize();
Expand All @@ -92,6 +93,7 @@ public function count()
*
* @return Traversable
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
$this->customerCollection->setPageSize($this->batchSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function __construct(
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
if ($this->options === null) {
Expand Down
7 changes: 7 additions & 0 deletions app/code/Magento/ImportExport/Model/Import/AbstractSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Magento\ImportExport\Model\Import\AbstractEntity;

// phpcs:disable Magento2.Classes.AbstractApi
/**
* Data source with columns for Magento_ImportExport
*
Expand Down Expand Up @@ -83,6 +84,7 @@ public function getColNames()
*
* @return array
*/
#[\ReturnTypeWillChange]
public function current()
{
$row = $this->_row;
Expand All @@ -101,6 +103,7 @@ public function current()
*
* @return void
*/
#[\ReturnTypeWillChange]
public function next()
{
$this->_key++;
Expand All @@ -127,6 +130,7 @@ abstract protected function _getNextRow();
*
* @return int -1 if out of bounds, 0 or more otherwise
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->_key;
Expand All @@ -137,6 +141,7 @@ public function key()
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function valid()
{
return -1 !== $this->_key;
Expand All @@ -147,6 +152,7 @@ public function valid()
*
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
{
$this->_key = -1;
Expand All @@ -161,6 +167,7 @@ public function rewind()
* @return void
* @throws \OutOfBoundsException
*/
#[\ReturnTypeWillChange]
public function seek($position)
{
if ($position == $this->_key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ protected function _construct()
*
* @return \Iterator
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
$connection = $this->getConnection();
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Shipping/Model/Simplexml/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Element extends \Magento\Framework\Simplexml\Element
* @param string $namespace If specified, the namespace to which the attribute belongs.
* @return void
*/
#[\ReturnTypeWillChange]
public function addAttribute($name, $value = null, $namespace = null)
{
$value = $value !== null ? $this->xmlentities($value) : '';
Expand All @@ -34,6 +35,7 @@ public function addAttribute($name, $value = null, $namespace = null)
* @param string $namespace If specified, the namespace to which the child element belongs.
* @return \Magento\Shipping\Model\Simplexml\Element
*/
#[\ReturnTypeWillChange]
public function addChild($name, $value = null, $namespace = null)
{
if ($value !== null) {
Expand Down
Loading