Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9ac46b5
PHPStan fix in app/Mage.php
fballiano Feb 17, 2023
a47ca34
Solved PHPStan problems with lib/Varien/Object/Cache.php
fballiano Feb 17, 2023
75fe5c0
PHPStan fixes for lib/Varien/Object/Mapper.php
fballiano Feb 17, 2023
e20adda
PHPStan fixes for lib/Varien/Io/File.php
fballiano Feb 17, 2023
32a491d
Fixed PHPStan error for lib/Varien/Image/Adapter/Gd2.php
fballiano Feb 17, 2023
a8a38e7
Merge branch '1.9.4.x' into phpstan1
fballiano Feb 21, 2023
001ad20
Fixed signature for getSingleton
fballiano Feb 22, 2023
2b8e071
Merge branch '1.9.4.x' into phpstan1
fballiano Feb 22, 2023
18d12dc
Merged 1.9.4.x
fballiano Feb 23, 2023
5beb4ad
removed what this PR fixed
fballiano Feb 23, 2023
3e46fb9
Update lib/Varien/Io/File.php
fballiano Feb 23, 2023
6c94094
Update lib/Varien/Object/Cache.php
fballiano Feb 23, 2023
34b8eb4
seems not necessary anymore
fballiano Feb 23, 2023
465d4a8
seems not necessary anymore
fballiano Feb 23, 2023
e3b51b3
updates
fballiano Feb 25, 2023
b1758b5
Merge branch '1.9.4.x' into phpstan1
fballiano Feb 25, 2023
d4a3753
updates
fballiano Feb 25, 2023
a2c6d05
updates
fballiano Feb 25, 2023
c1db557
revert
fballiano Feb 26, 2023
101fceb
trying to fix the baseline
fballiano Feb 26, 2023
ac23d81
trying to fix the baseline
fballiano Feb 26, 2023
e18dcf6
failed comparisons
fballiano Feb 26, 2023
a296283
types
fballiano Feb 26, 2023
0984bdc
test type hint
fballiano Feb 26, 2023
9362142
typehint
fballiano Feb 26, 2023
17a3234
nullable
fballiano Feb 26, 2023
82dc8de
fixes
fballiano Feb 26, 2023
2f326e9
fixes
fballiano Feb 26, 2023
7c20188
small revert
fballiano Feb 26, 2023
938d791
small revert
fballiano Feb 26, 2023
60a4abc
Merge branch '1.9.4.x' into phpstan1
fballiano Feb 28, 2023
776f3f6
Merge branch '1.9.4.x' into phpstan1
fballiano Mar 8, 2023
8ca5513
better error message
fballiano Mar 11, 2023
bf7f204
Merge branch '1.9.4.x' into phpstan1
fballiano Mar 11, 2023
65eb991
Merge branch '1.9.4.x' into phpstan1
fballiano Mar 15, 2023
4d49158
Merge branch '1.9.4.x' into phpstan1
fballiano Mar 15, 2023
426c8fb
Update app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
fballiano Mar 16, 2023
c7a7d37
Update app/code/core/Mage/Paypal/Controller/Express/Abstract.php
fballiano Mar 16, 2023
4ca14e8
suggestion
fballiano Mar 16, 2023
796f5f8
Merge branch '1.9.4.x' into phpstan1
fballiano Mar 16, 2023
a1f5310
Update app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
fballiano Mar 16, 2023
a56dc45
Exception added
fballiano Mar 16, 2023
07b4be3
Merge branch '1.9.4.x' into phpstan1
fballiano Mar 17, 2023
f68d7aa
small rewrite
fballiano Mar 17, 2023
080b762
Merge branch 'phpstan1' of github.com:fballiano/openmage into phpstan1
fballiano Mar 17, 2023
9e93039
phpcs
fballiano Mar 18, 2023
1d4c3f5
Merge branch '1.9.4.x' into phpstan1
fballiano Mar 18, 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
2 changes: 1 addition & 1 deletion app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public static function getModel($modelClass = '', $arguments = [])
*
* @param string $modelClass
* @param array $arguments
* @return Mage_Core_Model_Abstract
* @return Mage_Core_Model_Abstract|false
*/
public static function getSingleton($modelClass = '', array $arguments = [])
{
Expand Down
18 changes: 14 additions & 4 deletions app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ protected function _getDependence()
* @param Varien_Simplexml_Element $section
* @param string $fieldPrefix
* @param string $labelPrefix
* @throw Mage_Core_Exception
* @return $this
*/
public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = '')
Expand Down Expand Up @@ -425,21 +426,30 @@ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labe
}

$sourceModel = Mage::getSingleton($factoryName);
if (!$sourceModel) {
Mage::throwException("Source model '{$factoryName}' is not found");
}
if ($sourceModel instanceof Varien_Object) {
$sourceModel->setPath($path);
}

$optionArray = [];
if ($method) {
if ($fieldType == 'multiselect') {
$optionArray = $sourceModel->$method();
} else {
$optionArray = [];
foreach ($sourceModel->$method() as $value => $label) {
$optionArray[] = ['label' => $label, 'value' => $value];
}
}
} else {
$optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
if (method_exists($sourceModel, 'toOptionArray')) {
$optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
} else {
Mage::throwException("Missing method 'toOptionArray()' in source model '{$factoryName}'");
}
}

$field->setValues($optionArray);
}
}
Expand Down Expand Up @@ -637,9 +647,9 @@ public function getScope()
*/
public function getScopeLabel($element)
{
if ($element->show_in_store == 1) {
if ((int)$element->show_in_store === 1) {
return $this->_scopeLabels[self::SCOPE_STORES];
} elseif ($element->show_in_website == 1) {
} elseif ((int)$element->show_in_website === 1) {
return $this->_scopeLabels[self::SCOPE_WEBSITES];
}
return $this->_scopeLabels[self::SCOPE_DEFAULT];
Expand Down
9 changes: 6 additions & 3 deletions app/code/core/Mage/Catalog/Helper/Product/Flat.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,24 @@ class Mage_Catalog_Helper_Product_Flat extends Mage_Catalog_Helper_Flat_Abstract
/**
* Old Catalog Product Flat forced status
*
* @var bool
* @var bool|null
*/
protected $_forceFlatStatusOld;

/**
* Retrieve Catalog Product Flat Flag object
*
* @return Mage_Catalog_Model_Product_Flat_Flag
* @throws Mage_Core_Exception
*/
public function getFlag()
{
if (is_null($this->_flagObject)) {
$className = (string)Mage::getConfig()->getNode(self::XML_PATH_FLAT_FLAG);
$this->_flagObject = Mage::getSingleton($className)
->loadSelf();
/** @var Mage_Catalog_Model_Product_Flat_Flag $classInstance */
$classInstance = Mage::getSingleton($className);
$this->_flagObject = $classInstance;
$this->_flagObject->loadSelf();
}
return $this->_flagObject;
}
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/CatalogIndex/Model/Retreiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ protected function _construct()
* Returns data retriever model by specified product type
*
* @param string $type
* @return Mage_CatalogIndex_Model_Data_Abstract
* @return Mage_CatalogIndex_Model_Data_Abstract|false
* @throws Mage_Core_Exception
*/
public function getRetreiver($type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Mage_Oauth_Customer_TokenController extends Mage_Core_Controller_Front_Act
/**
* Customer session model
*
* @var Mage_Customer_Model_Session
* @var string
*/
protected $_sessionName = 'customer/session';

Expand All @@ -52,7 +52,9 @@ class Mage_Oauth_Customer_TokenController extends Mage_Core_Controller_Front_Act
public function preDispatch()
{
parent::preDispatch();
$this->_session = Mage::getSingleton($this->_sessionName);
/** @var Mage_Customer_Model_Session $classInstance */
$classInstance = Mage::getSingleton($this->_sessionName);
$this->_session = $classInstance;
if (!$this->_session->authenticate($this)) {
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
}
Expand Down
14 changes: 9 additions & 5 deletions app/code/core/Mage/Paypal/Controller/Express/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class Mage_Paypal_Controller_Express_Abstract extends Mage_Core_Control
protected $_config = null;

/**
* @var Mage_Sales_Model_Quote
* @var Mage_Sales_Model_Quote|false
*/
protected $_quote = false;

Expand All @@ -64,7 +64,9 @@ abstract class Mage_Paypal_Controller_Express_Abstract extends Mage_Core_Control
protected function _construct()
{
parent::_construct();
$this->_config = Mage::getModel($this->_configType, [$this->_configMethod]);
/** @var Mage_Paypal_Model_Config $classInstance */
$classInstance = Mage::getModel($this->_configType, [$this->_configMethod]);
$this->_config = $classInstance;
}

/**
Expand Down Expand Up @@ -457,11 +459,13 @@ protected function _initCheckout()
$this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden');
Mage::throwException(Mage::helper('paypal')->__('Unable to initialize Express Checkout.'));
}
$this->_checkout = Mage::getSingleton($this->_checkoutType, [

/** @var Mage_Paypal_Model_Express_Checkout $classInstance */
$classInstance = Mage::getSingleton($this->_checkoutType, [
'config' => $this->_config,
'quote' => $quote,
]);

$this->_checkout = $classInstance;
return $this->_checkout;
}

Expand All @@ -470,7 +474,7 @@ protected function _initCheckout()
* Combined getter/setter
*
* @param string $setToken
* @return Mage_Paypal_ExpressController|string
* @return $this|string
*/
protected function _initToken($setToken = null)
{
Expand Down
8 changes: 4 additions & 4 deletions app/code/core/Mage/Paypal/Model/Api/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,12 @@ protected function _importFromResponse(array $privateResponseMap, array $respons
*
* @param array &$request
* @param int $i
* @return true|bool
* @return bool
*/
protected function _exportLineItems(array &$request, $i = 0)
{
if (!$this->_cart) {
return;
return false;
}

// always add cart totals, even if line items are not requested
Expand All @@ -403,9 +403,9 @@ protected function _exportLineItems(array &$request, $i = 0)
// add cart line items
$items = $this->_cart->getItems();
if (empty($items) || !$this->getIsLineItemsEnabled()) {
return;
return false;
}
$result = null;
$result = false;
foreach ($items as $item) {
foreach ($this->_lineItemExportItemsFormat as $publicKey => $privateFormat) {
$result = true;
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Paypal/Model/Api/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ public function debugRequest($request)
*
* @param array $request
* @param int $i
* @return true|null
* @return bool
*/
protected function _exportLineItems(array &$request, $i = 1)
{
if (!$this->_cart) {
return;
return false;
}
if ($this->getIsLineItemsEnabled()) {
$this->_cart->isShippingAsItem(true);
Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Image/Adapter/Gd2.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function _convertToByte($memoryValue)
}
if (preg_match('~^([1-9][0-9]*)[\s]*(k|m|g)b?$~i', $memoryValue, $matches)) {
$option = strtolower($matches[2]);
$memoryValue = $matches[1];
$memoryValue = (int)$matches[1];
switch ($option) {
case 'g':
$memoryValue *= 1024;
Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Io/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Varien_Io_File extends Varien_Io_Abstract
/**
* Stream open file pointer
*
* @var resource
* @var resource|null
*/
protected $_streamHandler;

Expand Down
15 changes: 10 additions & 5 deletions lib/Varien/Object/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Varien_Object_Cache
/**
* Singleton instance
*
* @var Varien_Object_Cache
* @var Varien_Object_Cache|null
*/
protected static $_instance;

Expand Down Expand Up @@ -91,6 +91,11 @@ class Varien_Object_Cache
*/
protected $_objectReferences = [];

/**
* @var array
*/
protected $_referencesByObject = [];

/**
* Debug data such as backtrace per class
*
Expand Down Expand Up @@ -196,7 +201,7 @@ public function reference($refName, $idx)
foreach ($refName as $ref) {
$this->reference($ref, $idx);
}
return;
return false;
}

if (isset($this->_references[$refName])) {
Expand Down Expand Up @@ -243,7 +248,7 @@ public function delete($idx)
}

if (isset($this->_objectReferences[$idx])) {
foreach ($references as $r => $dummy) {
foreach ($this->_references as $r => $dummy) {
unset($this->_references[$r]);
}
unset($this->_objectReferences[$idx]);
Expand Down Expand Up @@ -345,7 +350,7 @@ public function findByTags($tags)
if (isset($objects[$idx])) {
continue;
}
$objects[$ids] = $this->load($idx);
$objects[$idx] = $this->load($idx);
}
}
return $objects;
Expand Down Expand Up @@ -375,7 +380,7 @@ public function debug($idx, $object = null)
$debug[$i] = [
'file' => isset($step['file']) ? $step['file'] : null,
'line' => isset($step['line']) ? $step['line'] : null,
'function' => isset($step['function']) ? $step['function'] : null,
'function' => $step['function'],
];
}
$this->_debug[$idx] = $debug;
Expand Down
1 change: 1 addition & 0 deletions lib/Varien/Object/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public static function &accumulateByMap($from, $to, array $map, array $defaults
$to[$keyTo] = $value;
}
} elseif ($toIsVO) {
/** @var Varien_Object $to */
if (!$to->hasData($keyTo)) {
$to->$set($keyTo, $value);
}
Expand Down
Loading