Skip to content
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

set phpstan to bleedingEdge config #3011

Merged
merged 25 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
80aa85c
set phpstan config to use bleedingEdge
Flyingmana Feb 3, 2023
9424c20
pseudo change to trigger phpstan
Flyingmana Feb 3, 2023
9c178ce
Some phpstan fixes
elidrissidev Feb 7, 2023
97a8cd4
removed empty line
fballiano Feb 7, 2023
28aa612
Merge branch '1.9.4.x' into patch-phpstan
fballiano Feb 18, 2023
1337694
Update IndexController.php
fballiano Feb 18, 2023
14abb80
PHP suggestion
fballiano Feb 18, 2023
96ebe2d
PHP Suggestion: removed unreachable condition
fballiano Feb 18, 2023
a8a9a9e
Update phpstan.dist.baseline.neon
fballiano Feb 18, 2023
43fa045
PHPStan suggestions
fballiano Feb 18, 2023
469749b
Update phpstan.dist.baseline.neon
fballiano Feb 18, 2023
f6c544f
Update phpstan.dist.baseline.neon
fballiano Feb 18, 2023
8ed769a
Update phpstan.dist.baseline.neon
fballiano Feb 18, 2023
c3f1f00
Merge branch '1.9.4.x' into patch-phpstan
fballiano Feb 26, 2023
86182c3
removed ignored errors
fballiano Feb 26, 2023
18c8159
regenerated baseline
Feb 26, 2023
3cb3c63
Fix some newly ignored errors
elidrissidev Feb 27, 2023
8457fd1
Merge branch '1.9.4.x' into patch-phpstan
fballiano Feb 27, 2023
9af7347
Update app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php
fballiano Feb 27, 2023
6041348
Update app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php
fballiano Feb 27, 2023
64cb770
not needed
Feb 27, 2023
3be3a6d
Update app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php
fballiano Feb 27, 2023
e493e5f
Merge branch '1.9.4.x' into patch-phpstan
fballiano Feb 27, 2023
73bc128
Merge branch '1.9.4.x' into patch-phpstan
fballiano Feb 28, 2023
dbc40f4
revert
Feb 28, 2023
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
18 changes: 8 additions & 10 deletions app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public function getCategory()

public function getCategoryId()
{
if ($this->getCategory()) {
return $this->getCategory()->getId();
$category = $this->getCategory();
if (is_object($category) && $category->getId()) {
elidrissidev marked this conversation as resolved.
Show resolved Hide resolved
fballiano marked this conversation as resolved.
Show resolved Hide resolved
fballiano marked this conversation as resolved.
Show resolved Hide resolved
return $category->getId();
}
return Mage_Catalog_Model_Category::TREE_ROOT_ID;
}
Expand Down Expand Up @@ -93,8 +94,9 @@ public function getRoot($parentNodeCategory = null, $recursionLevel = 3)
$tree = Mage::getResourceSingleton('catalog/category_tree')
->load(null, $recursionLevel);

if ($this->getCategory()) {
$tree->loadEnsuredNodes($this->getCategory(), $tree->getNodeById($rootId));
$category = $this->getCategory();
if (is_object($category) and $category->getId()) {
fballiano marked this conversation as resolved.
Show resolved Hide resolved
fballiano marked this conversation as resolved.
Show resolved Hide resolved
$tree->loadEnsuredNodes($category, $tree->getNodeById($rootId));
}

$tree->addCollectionData($this->getCategoryCollection());
Expand Down Expand Up @@ -132,9 +134,7 @@ public function getRootByIds($ids)
$tree = $categoryTreeResource->loadByIds($ids);
$rootId = Mage_Catalog_Model_Category::TREE_ROOT_ID;
$root = $tree->getNodeById($rootId);
if ($root && $rootId != Mage_Catalog_Model_Category::TREE_ROOT_ID) {
$root->setIsVisible(true);
} elseif ($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) {
if ($root && $root->getId() == Mage_Catalog_Model_Category::TREE_ROOT_ID) {
$root->setName(Mage::helper('catalog')->__('Root'));
}

Expand All @@ -148,9 +148,7 @@ public function getNode($parentNodeCategory, $recursionLevel = 2)
{
$tree = Mage::getResourceModel('catalog/category_tree');

$nodeId = $parentNodeCategory->getId();
$parentId = $parentNodeCategory->getParentId();

$nodeId = $parentNodeCategory->getId();
$node = $tree->loadNode($nodeId);
$node->loadChildren($recursionLevel);

Expand Down
56 changes: 26 additions & 30 deletions app/code/core/Mage/Adminhtml/controllers/PollController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,48 +141,44 @@ public function validateAction()
Mage::throwException(Mage::helper('adminhtml')->__('Please, select "Visible in Stores" for this poll first.'));
}

if (is_array($stores)) {
$storeIds = [];
foreach ($stores as $storeIdList) {
$storeIdList = explode(',', $storeIdList);
if (!$storeIdList) {
continue;
}
foreach ($storeIdList as $storeId) {
if ($storeId > 0) {
$storeIds[] = $storeId;
}
}
$storeIds = [];
foreach ($stores as $storeIdList) {
$storeIdList = explode(',', $storeIdList);
if (!$storeIdList) {
continue;
}
if (count($storeIds) === 0) {
Mage::throwException(Mage::helper('adminhtml')->__('Please, select "Visible in Stores" for this poll first.'));
foreach ($storeIdList as $storeId) {
if ($storeId > 0) {
$storeIds[] = $storeId;
}
}
$pollModel->setStoreIds($storeIds);
}
if (count($storeIds) === 0) {
Mage::throwException(Mage::helper('adminhtml')->__('Please, select "Visible in Stores" for this poll first.'));
}
$pollModel->setStoreIds($storeIds);

$answers = $this->getRequest()->getParam('answer');

if (!is_array($answers) || !count($answers)) {
Mage::throwException(Mage::helper('adminhtml')->__('Please, add some answers to this poll first.'));
}

if (is_array($answers)) {
$_titles = [];
foreach ($answers as $key => $answer) {
if (in_array($answer['title'], $_titles)) {
Mage::throwException(Mage::helper('adminhtml')->__('Your answers contain duplicates.'));
}
$_titles[] = $answer['title'];

$answerModel = Mage::getModel('poll/poll_answer');
if ((int) $key > 0) {
$answerModel->setId($key);
}
$answerModel->setAnswerTitle($answer['title'])
->setVotesCount($answer['votes']);
$_titles = [];
foreach ($answers as $key => $answer) {
if (in_array($answer['title'], $_titles)) {
Mage::throwException(Mage::helper('adminhtml')->__('Your answers contain duplicates.'));
}
$_titles[] = $answer['title'];

$pollModel->addAnswer($answerModel);
$answerModel = Mage::getModel('poll/poll_answer');
if ((int) $key > 0) {
$answerModel->setId($key);
}
$answerModel->setAnswerTitle($answer['title'])
->setVotesCount($answer['votes']);

$pollModel->addAnswer($answerModel);
}

$pollModel->save();
Expand Down
5 changes: 2 additions & 3 deletions app/code/core/Mage/Api2/Model/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,12 +765,11 @@ protected function _applyFilter(Varien_Data_Collection_Db $collection)
if (!is_array($filter)) {
$this->_critical(self::RESOURCE_COLLECTION_FILTERING_ERROR);
}

if (method_exists($collection, 'addAttributeToFilter')) {
$methodName = 'addAttributeToFilter';
} elseif (method_exists($collection, 'addFieldToFilter')) {
$methodName = 'addFieldToFilter';
} else {
return $this;
$methodName = 'addFieldToFilter';
}
$allowedAttributes = $this->getFilter()->getAllowedAttributes(self::OPERATION_ATTRIBUTE_READ);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ public function prepareTierPrices($product, $tierPrices = null)
return null;
}

if (!is_array($tierPrices)) {
$this->_fault('data_invalid', Mage::helper('catalog')->__('Invalid Tier Prices'));
}

$updateValue = [];

foreach ($tierPrices as $tierPrice) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Mage_CatalogSearch_Model_Resource_Fulltext_Collection extends Mage_Catalog
/**
* Sort order by relevance
*
* @var null
* @var int
*/
protected $_relevanceSortOrder = SORT_DESC;

Expand Down
4 changes: 1 addition & 3 deletions app/code/core/Mage/Customer/Helper/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ public function convertStreetLines($origStreets, $toCount)
--$modulo;
}
$values = array_slice($origStreets, $offset, $neededLinesCount);
if (is_array($values)) {
$lines[] = implode(' ', $values);
}
$lines[] = implode(' ', $values);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function downloadCustomOptionAction()
$optionId = null;
if (strpos($option->getCode(), Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX) === 0) {
$optionId = str_replace(Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX, '', $option->getCode());
if ((int)$optionId != $optionId) {
if (!is_numeric($optionId)) {
$optionId = null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Tax/Model/Resource/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ protected function _getRates($request)
->where("rate.tax_region_id IN(?)", [0, (int)$regionId]);
$postcodeIsNumeric = is_numeric($postcode);
$postcodeIsRange = false;
if (is_string($postcode) && preg_match('/^(.+)-(.+)$/', $postcode, $matches)) {
if (preg_match('/^(.+)-(.+)$/', $postcode, $matches)) {
if (is_numeric($matches[2]) && strlen($matches[2]) < 5) {
$postcodeIsNumeric = true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ protected function _formShipmentRequest(Varien_Object $request)

$deliveryConfirmation = $packageParams->getDeliveryConfirmation();
if ($deliveryConfirmation) {
/** @var SimpleXMLElement $serviceOptionsNode */
/** @var SimpleXMLElement|null $serviceOptionsNode */
$serviceOptionsNode = null;
switch ($this->_getDeliveryConfirmationLevel($request->getRecipientAddressCountryCode())) {
case self::DELIVERY_CONFIRMATION_PACKAGE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ public function downloadCustomOptionAction()
$optionId = null;
if (strpos($option->getCode(), Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX) === 0) {
$optionId = str_replace(Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX, '', $option->getCode());
if ((int)$optionId != $optionId) {
if (!is_numeric($optionId)) {
return $this->_forward('noRoute');
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Mage/HTTP/Client/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Mage_HTTP_Client_Curl implements Mage_HTTP_IClient
* User ovverides options hash
* Are applied before curl_exec
*
* @var array();
* @var array
*/
protected $_curlUserOptions = [];

Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Data/Form/Element/Obscure.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getEscapedValue($index = null)
/**
* Returns list of html attributes possible to output in HTML
*
* @return array()
* @return array
*/
public function getHtmlAttributes()
{
Expand Down
4 changes: 1 addition & 3 deletions lib/Varien/Image/Adapter/Gd2.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,6 @@ public function watermark($watermarkImage, $positionX = 0, $positionY = 0, $wate
'Unsupported watermark image format.'
), $watermarkImage);

$merged = false;

if ($this->getWatermarkWidth() &&
$this->getWatermarkHeigth() &&
($this->getWatermarkPosition() != self::POSITION_STRETCH)
Expand Down Expand Up @@ -559,7 +557,7 @@ public function watermark($watermarkImage, $positionX = 0, $positionY = 0, $wate
);
}

if ($repeat === false && $merged === false) {
if ($repeat === false) {
imagecopymerge(
$this->_imageHandler,
$watermark,
Expand Down
Loading