Skip to content

Fixed PHP 8.2 deprecation warnings: 'creation of dynamic property'. #37573

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
7 changes: 0 additions & 7 deletions app/code/Magento/CatalogImportExport/Model/Export/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
*/
protected $_productTypeModels = [];

/**
* Array of pairs store ID to its code.
*
* @var array
*/
protected $_storeIdToCode = [];

/**
* Array of Website ID-to-code.
*
Expand Down
7 changes: 0 additions & 7 deletions app/code/Magento/Dhl/Model/Carrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,6 @@ class Carrier extends AbstractDhl implements CarrierInterface
*/
protected $_request;

/**
* Rate result data
*
* @var Result|null
*/
protected $_result;

/**
* Countries parameters data
*
Expand Down
7 changes: 0 additions & 7 deletions app/code/Magento/Fedex/Model/Carrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C
*/
protected $_request = null;

/**
* Rate result data
*
* @var Result|null
*/
protected $_result = null;

/**
* Path to wsdl file of rate service
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ abstract class AbstractEntity
*/
protected $_storeManager;

/**
* Array of pairs store ID to its code.
*
* @var array
*/
protected $_storeIdToCode = [];

/**
* @var array
*/
private $_invalidRows = [];

/**
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Eav\Model\Config $config
Expand Down Expand Up @@ -172,10 +184,8 @@ public function __construct(
protected function _initStores()
{
foreach ($this->_storeManager->getStores(true) as $store) {
// phpstan:ignore "Access to an undefined property"
$this->_storeIdToCode[$store->getId()] = $store->getCode();
}
// phpstan:ignore "Access to an undefined property"
ksort($this->_storeIdToCode);
// to ensure that 'admin' store (ID is zero) goes first

Expand Down Expand Up @@ -350,7 +360,6 @@ public function addRowError($errorCode, $errorRowNum)
$errorCode = (string)$errorCode;
$this->_errors[$errorCode][] = $errorRowNum + 1;
// one added for human readability
// phpstan:ignore "Access to an undefined property"
$this->_invalidRows[$errorRowNum] = true;
$this->_errorsCount++;

Expand Down Expand Up @@ -508,7 +517,6 @@ public function getErrorsCount()
*/
public function getInvalidRowsCount()
{
// phpstan:ignore "Access to an undefined property"
return count($this->_invalidRows);
}

Expand Down
11 changes: 9 additions & 2 deletions app/code/Magento/Shipping/Model/Carrier/AbstractCarrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Magento\Shipping\Model\Carrier;

use Magento\Quote\Model\Quote\Address\RateResult\Error;
use Magento\Shipping\Model\Rate\Result as RateResult;
use Magento\Shipping\Model\Shipment\Request;

/**
Expand Down Expand Up @@ -45,6 +46,13 @@ abstract class AbstractCarrier extends \Magento\Framework\DataObject implements
*/
protected $_isFixed = false;

/**
* Rate result data
*
* @var RateResult|null
*/
protected $_result = null;

/**
* @var string[]
*/
Expand Down Expand Up @@ -331,7 +339,7 @@ public function processAdditionalValidation(\Magento\Framework\DataObject $reque
* @param \Magento\Framework\DataObject $request
* @return $this|bool|\Magento\Framework\DataObject
* @deprecated 100.2.6
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @see processAdditionalValidation()
*/
public function proccessAdditionalValidation(\Magento\Framework\DataObject $request)
{
Expand Down Expand Up @@ -426,7 +434,6 @@ protected function _updateFreeMethodQuote($request)
return;
}
$freeRateId = false;
// phpstan:ignore
if (is_object($this->_result)) {
foreach ($this->_result->getAllRates() as $i => $item) {
if ($item->getMethod() == $freeMethod) {
Expand Down
7 changes: 0 additions & 7 deletions app/code/Magento/Ups/Model/Carrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@ class Carrier extends AbstractCarrierOnline implements CarrierInterface
*/
protected $_request;

/**
* Rate result data
*
* @var Result
*/
protected $_result;

/**
* @var float
*/
Expand Down
7 changes: 0 additions & 7 deletions app/code/Magento/Usps/Model/Carrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C
*/
protected $_request = null;

/**
* Rate result data
*
* @var Result|null
*/
protected $_result = null;

/**
* Default cgi gateway url
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@
* Class performs assertion that generated simple products are valid
* after running setup:performance:generate-fixtures command
*/
#[\AllowDynamicProperties]
class SimpleProductsAssert
{
/**
* @var \Magento\Catalog\Api\ProductRepositoryInterface
*/
private $productRepository;

/**
* @var \Magento\ConfigurableProduct\Api\OptionRepositoryInterface
*/
private $optionRepository;

/**
* @var \Magento\Setup\Fixtures\FixturesAsserts\ProductAssert
*/
Expand Down
16 changes: 15 additions & 1 deletion pub/errors/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* phpcs:ignoreFile
*/
#[\AllowDynamicProperties]
class Processor
{
const MAGE_ERRORS_LOCAL_XML = 'local.xml';
Expand Down Expand Up @@ -111,6 +110,21 @@ class Processor
*/
public $reportUrl;

/**
* @var string
*/
public $_reportDir;

/**
* @var string
*/
public $_indexDir;

/**
* @var string
*/
public $_errorDir;

/**
* Server script name
*
Expand Down