Skip to content

Phpstan fixes #4116

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
merged 7 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -434,11 +434,11 @@ public function getFilterElementName($attributeCode)
* Get row edit URL.
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $row
* @return false
* @return string
*/
public function getRowUrl($row)
{
return false;
return '';
}

/**
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/ImportExport/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class Mage_ImportExport_Helper_Data extends Mage_Core_Helper_Data
*/
public function getMaxUploadSize()
{
return min(ini_get('post_max_size'), ini_get('upload_max_filesize'));
$postMaxSizeBytes = ini_parse_quantity(ini_get('post_max_size'));
$uploadMaxSizeBytes = ini_parse_quantity(ini_get('upload_max_filesize'));
return min($postMaxSizeBytes, $uploadMaxSizeBytes);
}

/**
Expand Down
11 changes: 7 additions & 4 deletions app/code/core/Mage/ImportExport/Model/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ protected function _getEntityAdapter()

if (isset($validTypes[$this->getEntity()])) {
try {
$this->_entityAdapter = Mage::getModel($validTypes[$this->getEntity()]['model']);
/** @var Mage_ImportExport_Model_Export_Entity_Abstract $_entityAdapter */
$_entityAdapter = Mage::getModel($validTypes[$this->getEntity()]['model']);
$this->_entityAdapter = $_entityAdapter;
} catch (Exception $e) {
Mage::logException($e);
Mage::throwException(
Expand Down Expand Up @@ -104,7 +106,9 @@ protected function _getWriter()

if (isset($validWriters[$this->getFileFormat()])) {
try {
$this->_writer = Mage::getModel($validWriters[$this->getFileFormat()]['model']);
/** @var Mage_ImportExport_Model_Export_Adapter_Abstract $_writer */
$_writer = Mage::getModel($validWriters[$this->getFileFormat()]['model']);
$this->_writer = $_writer;
} catch (Exception $e) {
Mage::logException($e);
Mage::throwException(
Expand Down Expand Up @@ -185,8 +189,7 @@ public function exportFile()
Mage::throwException(
Mage::helper('importexport')->__('There is no data for export')
);
}
if ($result['rows']) {
} else {
$this->addLogComment([
Mage::helper('importexport')->__('Exported %s rows.', $result['rows']),
Mage::helper('importexport')->__('Export has been done.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ abstract class Mage_ImportExport_Model_Export_Entity_Abstract
/**
* Entity type id.
*
* @var int
* @var string|null
*/
protected $_entityTypeId;

Expand Down Expand Up @@ -170,7 +170,10 @@ public function __construct()
{
$entityCode = $this->getEntityTypeCode();
$this->_entityTypeId = Mage::getSingleton('eav/config')->getEntityType($entityCode)->getEntityTypeId();
$this->_connection = Mage::getSingleton('core/resource')->getConnection('write');

/** @var Varien_Db_Adapter_Pdo_Mysql $_connection */
$_connection = Mage::getSingleton('core/resource')->getConnection('write');
$this->_connection = $_connection;
}

/**
Expand Down Expand Up @@ -436,7 +439,7 @@ abstract public function getEntityTypeCode();
/**
* Entity type ID getter.
*
* @return int
* @return string|null
*/
public function getEntityTypeId()
{
Expand Down
8 changes: 5 additions & 3 deletions app/code/core/Mage/ImportExport/Model/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Mage_ImportExport_Model_Import extends Mage_ImportExport_Model_Abstract
/**
* Entity invalidated indexes.
*
* @var Mage_ImportExport_Model_Import_Entity_Abstract
* @var array<string, array<int, string>>
*/
protected static $_entityInvalidatedIndexes = [
'catalog_product' => [
Expand All @@ -80,7 +80,9 @@ protected function _getEntityAdapter()

if (isset($validTypes[$this->getEntity()])) {
try {
$this->_entityAdapter = Mage::getModel($validTypes[$this->getEntity()]['model']);
/** @var Mage_ImportExport_Model_Import_Entity_Abstract $_entityAdapter */
$_entityAdapter = Mage::getModel($validTypes[$this->getEntity()]['model']);
$this->_entityAdapter = $_entityAdapter;
} catch (Exception $e) {
Mage::logException($e);
Mage::throwException(
Expand Down Expand Up @@ -366,7 +368,7 @@ public function expandSource()
if (!empty($row[$colName])) {
preg_match($regExps[$regExpType], $row[$colName], $m);

$row[$colName] = $m[1] . ($m[2] + $size) . ($regExpType == 'middle' ? $m[3] : '');
$row[$colName] = $m[1] . ((int) $m[2] + $size) . ($regExpType == 'middle' ? $m[3] : '');
}
}
$writer->writeRow($row);
Expand Down
13 changes: 8 additions & 5 deletions app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class Mage_ImportExport_Model_Import_Entity_Abstract
/**
* DB connection.
*
* @var Varien_Convert_Adapter_Interface
* @var Varien_Db_Adapter_Pdo_Mysql
*/
protected $_connection;

Expand All @@ -54,7 +54,7 @@ abstract class Mage_ImportExport_Model_Import_Entity_Abstract
/**
* Entity type id.
*
* @var int
* @var string|null
*/
protected $_entityTypeId;

Expand Down Expand Up @@ -183,10 +183,13 @@ abstract class Mage_ImportExport_Model_Import_Entity_Abstract

public function __construct()
{
$entityType = Mage::getSingleton('eav/config')->getEntityType($this->getEntityTypeCode());
$entityType = Mage::getSingleton('eav/config')->getEntityType($this->getEntityTypeCode());
$this->_entityTypeId = $entityType->getEntityTypeId();
$this->_dataSourceModel = Mage_ImportExport_Model_Import::getDataSourceModel();
$this->_connection = Mage::getSingleton('core/resource')->getConnection('write');

/** @var Varien_Db_Adapter_Pdo_Mysql $_connection */
$_connection = Mage::getSingleton('core/resource')->getConnection('write');
$this->_connection = $_connection;
}

/**
Expand Down Expand Up @@ -398,7 +401,7 @@ abstract public function getEntityTypeCode();
/**
* Entity type ID getter.
*
* @return int
* @return string|null
*/
public function getEntityTypeId()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ protected function _saveCustomers()
$entityRowsIn = [];
$entityRowsUp = [];
$attributes = [];
$entityId = null;

$oldCustomersToLower = array_change_key_case($this->_oldCustomers, CASE_LOWER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ class Mage_ImportExport_Model_Import_Entity_Product extends Mage_ImportExport_Mo
/**
* url_key attribute id
*
* @var int
* @var string|false|null
*/
protected $_urlKeyAttributeId;

Expand Down Expand Up @@ -901,6 +901,8 @@ protected function _saveCustomOptions()
'updated_at' => Varien_Date::now()
];
}

$prevOptionId = 0;
if ($rowIsMain) {
$solidParams = [
'option_id' => $nextOptionId,
Expand Down Expand Up @@ -1152,6 +1154,7 @@ protected function _saveLinks()
$productIds = [];
$linkRows = [];
$positionRows = [];
$sku = null;

foreach ($bunch as $rowNum => $rowData) {
$this->_filterRowData($rowData);
Expand Down Expand Up @@ -1362,6 +1365,7 @@ protected function _saveProducts()
$tierPrices = [];
$groupPrices = [];
$mediaGallery = [];
$rowSku = null;
$uploadedGalleryFiles = [];
$previousType = null;
$previousAttributeSet = null;
Expand Down Expand Up @@ -2207,7 +2211,7 @@ public function getAffectedEntityIds()
/**
* Get product url_key attribute id
*
* @return null|int
* @return string|false|null
*/
protected function _getUrlKeyAttributeId()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ public function saveData()
$newSku = $this->_entityModel->getNewSku();
$oldSku = $this->_entityModel->getOldSku();
$productSuperData = [];
$productSuperAttrId = null;
$productId = null;
$productData = null;
/** @var Mage_ImportExport_Model_Resource_Helper_Mysql4 $helper */
$helper = Mage::getResourceHelper('importexport');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function saveData()
$newSku = $this->_entityModel->getNewSku();
$oldSku = $this->_entityModel->getOldSku();
$attributes = [];
$productData = [];

// pre-load attributes parameters
$select = $connection->select()
Expand Down Expand Up @@ -101,6 +102,7 @@ public function saveData()
} else {
continue;
}

$scope = $this->_entityModel->getRowScope($rowData);
if (Mage_ImportExport_Model_Import_Entity_Product::SCOPE_DEFAULT == $scope) {
$productData = $newSku[$rowData[Mage_ImportExport_Model_Import_Entity_Product::COL_SKU]];
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Shipping/Model/Carrier/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ abstract class Mage_Shipping_Model_Carrier_Abstract extends Varien_Object
/**
* Rate result data
*
* @var Mage_Shipping_Model_Rate_Result|null
* @var Mage_Shipping_Model_Rate_Result|Mage_Shipping_Model_Tracking_Result|null
*/
protected $_result;

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Uploader/Helper/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ public function getUploadMaxSize()
/**
* Get max upload size
*
* @return mixed
* @return string
*/
public function getDataMaxSize()
{
Expand Down
17 changes: 13 additions & 4 deletions app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,18 @@ class Mage_Usa_Model_Shipping_Carrier_Usps extends Mage_Usa_Model_Shipping_Carri
*/
protected $_rawRequest = null;


/**
* Raw rate tracking request data
*
* @var Varien_Object|null
*/
protected $_rawTrackRequest = null;

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

Expand Down Expand Up @@ -425,7 +433,7 @@ protected function _getXmlQuotes()
*
* @link http://www.usps.com/webtools/htm/Rate-Calculators-v2-3.htm
* @param string $response
* @return Mage_Shipping_Model_Rate_Result
* @return Mage_Shipping_Model_Rate_Result|void
*/
protected function _parseXmlResponse($response)
{
Expand Down Expand Up @@ -512,6 +520,7 @@ protected function _parseXmlResponse($response)
}
}
}

/**
* Get configuration data of carrier
*
Expand Down Expand Up @@ -901,7 +910,7 @@ public function getTracking($trackingData)
/**
* Set tracking request
*
* @return null
* @return void
*/
protected function setTrackingRequest()
{
Expand Down Expand Up @@ -960,7 +969,7 @@ protected function _getXmlTracking($trackingData)
*
* @param array $trackingValue
* @param string $response
* @return null
* @return void
*/
protected function _parseXmlTrackingResponse($trackingValue, $response)
{
Expand Down
Loading
Loading