Skip to content

Commit 16fe79d

Browse files
committed
Merge branch 'main' into validation
# Conflicts: # composer.lock
2 parents 39e5606 + f1ae19d commit 16fe79d

File tree

413 files changed

+3695
-3427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

413 files changed

+3695
-3427
lines changed

.github/workflows/spellcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Checkout
1414
uses: actions/checkout@v4
1515
- name: Check Spelling
16-
uses: rojopolis/spellcheck-github-actions@0.49.0
16+
uses: rojopolis/spellcheck-github-actions@0.51.0
1717
with:
1818
config_path: .github/spellcheck.yml
1919
task_name: Markdown

.phpstan.dist.baseline.neon

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,10 +1422,16 @@ parameters:
14221422
count: 1
14231423
path: app/code/core/Mage/Catalog/Model/Api/Resource.php
14241424

1425+
-
1426+
message: '#^Elseif condition is always false\.$#'
1427+
identifier: elseif.alwaysFalse
1428+
count: 1
1429+
path: app/code/core/Mage/Catalog/Model/Api2/Product/Rest.php
1430+
14251431
-
14261432
message: '#^If condition is always false\.$#'
14271433
identifier: if.alwaysFalse
1428-
count: 2
1434+
count: 1
14291435
path: app/code/core/Mage/Catalog/Model/Api2/Product/Rest.php
14301436

14311437
-
@@ -1932,6 +1938,12 @@ parameters:
19321938
count: 1
19331939
path: app/code/core/Mage/Catalog/Model/Resource/Config.php
19341940

1941+
-
1942+
message: '#^Argument of an invalid type hasOffsetValue\(string, mixed\) supplied for foreach, only iterables are supported\.$#'
1943+
identifier: foreach.nonIterable
1944+
count: 1
1945+
path: app/code/core/Mage/Catalog/Model/Resource/Layer/Filter/Price.php
1946+
19351947
-
19361948
message: '#^Binary operation "\-" between int and non\-falsy\-string results in an error\.$#'
19371949
identifier: binaryOp.invalid
@@ -2628,12 +2640,6 @@ parameters:
26282640
count: 2
26292641
path: app/code/core/Mage/Core/Model/Domainpolicy.php
26302642

2631-
-
2632-
message: '#^Method Zend_Mail\:\:addBcc\(\) invoked with 2 parameters, 1 required\.$#'
2633-
identifier: arguments.count
2634-
count: 1
2635-
path: app/code/core/Mage/Core/Model/Email/Queue.php
2636-
26372643
-
26382644
message: '#^Method Mage_Core_Model_Email_Template\:\:getProcessedTemplate\(\) invoked with 2 parameters, 0\-1 required\.$#'
26392645
identifier: arguments.count
@@ -2701,7 +2707,7 @@ parameters:
27012707
path: app/code/core/Mage/Core/Model/Layout.php
27022708

27032709
-
2704-
message: '#^Cannot unset offset ''@attributes'' on \(array\{\}\|array\{\000\*\000_parent\: Varien_Simplexml_Element\}\)\.$#'
2710+
message: '#^Cannot unset offset ''@attributes'' on \(array\{\}\|array\{''\000\*\000_parent''\: Varien_Simplexml_Element\}\)\.$#'
27052711
identifier: unset.offset
27062712
count: 1
27072713
path: app/code/core/Mage/Core/Model/Layout.php
@@ -3690,12 +3696,6 @@ parameters:
36903696
count: 2
36913697
path: app/code/core/Mage/Index/Model/Resource/Lock/Resource.php
36923698

3693-
-
3694-
message: '#^Offset ''path'' does not exist on array\{\000\*\000_parent\: Varien_Simplexml_Element\}\|array\{false\}\.$#'
3695-
identifier: offsetAccess.notFound
3696-
count: 1
3697-
path: app/code/core/Mage/Install/Model/Config.php
3698-
36993699
-
37003700
message: '#^Method Mage_Install_Model_Installer\:\:getDataModel\(\) should return Mage_Install_Model_Session but returns Mage_Install_Model_Installer_Data\|null\.$#'
37013701
identifier: return.type
@@ -4674,18 +4674,6 @@ parameters:
46744674
count: 3
46754675
path: app/code/core/Mage/Sales/Model/Recurring/Profile.php
46764676

4677-
-
4678-
message: '#^Parameter \#2 \$attribute of method Mage_Sales_Model_Resource_Order_Abstract\:\:_afterSaveAttribute\(\) expects string, array\<mixed, mixed\> given\.$#'
4679-
identifier: argument.type
4680-
count: 1
4681-
path: app/code/core/Mage/Sales/Model/Resource/Order/Abstract.php
4682-
4683-
-
4684-
message: '#^Parameter \#2 \$attribute of method Mage_Sales_Model_Resource_Order_Abstract\:\:_beforeSaveAttribute\(\) expects string, array\<mixed, mixed\> given\.$#'
4685-
identifier: argument.type
4686-
count: 1
4687-
path: app/code/core/Mage/Sales/Model/Resource/Order/Abstract.php
4688-
46894677
-
46904678
message: '#^Cannot call method updateOnRelatedRecordChanged\(\) on Mage_Core_Model_Resource_Db_Collection_Abstract\|false\.$#'
46914679
identifier: method.nonObject
@@ -5568,6 +5556,30 @@ parameters:
55685556
count: 1
55695557
path: app/design/adminhtml/default/default/template/system/config/form/field/array.phtml
55705558

5559+
-
5560+
message: '#^Access to protected property Mage_Adminhtml_Block_System_Config_Form_Field_Csp_Hosts\:\:\$_addAfter\.$#'
5561+
identifier: property.protected
5562+
count: 4
5563+
path: app/design/adminhtml/default/default/template/system/config/form/field/csp.phtml
5564+
5565+
-
5566+
message: '#^Access to protected property Mage_Adminhtml_Block_System_Config_Form_Field_Csp_Hosts\:\:\$_addButtonLabel\.$#'
5567+
identifier: property.protected
5568+
count: 2
5569+
path: app/design/adminhtml/default/default/template/system/config/form/field/csp.phtml
5570+
5571+
-
5572+
message: '#^Access to protected property Mage_Adminhtml_Block_System_Config_Form_Field_Csp_Hosts\:\:\$_columns\.$#'
5573+
identifier: property.protected
5574+
count: 5
5575+
path: app/design/adminhtml/default/default/template/system/config/form/field/csp.phtml
5576+
5577+
-
5578+
message: '#^Call to protected method _renderCellTemplate\(\) of class Mage_Adminhtml_Block_System_Config_Form_Field_Csp_Hosts\.$#'
5579+
identifier: method.protected
5580+
count: 2
5581+
path: app/design/adminhtml/default/default/template/system/config/form/field/csp.phtml
5582+
55715583
-
55725584
message: '#^Unreachable statement \- code above always terminates\.$#'
55735585
identifier: deadCode.unreachable

.rector.php

Lines changed: 90 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Rector\CodingStyle\Rector as CodingStyle;
88
use Rector\Config\RectorConfig;
99
use Rector\DeadCode\Rector as DeadCode;
10+
use Rector\EarlyReturn\Rector as EarlyReturn;
1011
use Rector\Exception\Configuration\InvalidConfigurationException;
1112
use Rector\Php53\Rector as Php53;
1213
use Rector\Php71\Rector as Php71;
@@ -18,6 +19,10 @@
1819
use Rector\Php83\Rector as Php83;
1920
use Rector\Php84\Rector as Php84;
2021
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
22+
use Rector\Privatization\Rector as Privatization;
23+
use Rector\Renaming\Rector as Renaming;
24+
use Rector\Strict\Rector as Strict;
25+
use Rector\Transform\Rector as Transform;
2126
use Rector\TypeDeclaration\Rector as TypeDeclaration;
2227

2328
try {
@@ -28,15 +33,84 @@
2833
cacheClass: FileCacheStorage::class,
2934
)
3035
->withPhpSets(
31-
php74: true,
36+
php81: true,
3237
)
3338
->withPaths([
3439
__DIR__,
3540
])
3641
->withSkipPath(__DIR__ . '/vendor')
3742
->withSkip([
43+
CodeQuality\Assign\CombinedAssignRector::class, # todo: TMP
3844
CodeQuality\BooleanNot\SimplifyDeMorganBinaryRector::class,
45+
# skip: causes issues with Mage_Api2_Model_Auth_Adapter_Oauth::getUserParams()
46+
CodeQuality\Catch_\ThrowWithPreviousExceptionRector::class => [
47+
__DIR__ . '/app/code/core/Mage/Api2/Model/Auth/Adapter/Oauth.php',
48+
],
49+
CodeQuality\Class_\CompleteDynamicPropertiesRector::class, # todo: TMP (!?!)
50+
CodeQuality\Class_\InlineConstructorDefaultToPropertyRector::class, # todo: TMP
51+
CodeQuality\ClassMethod\ExplicitReturnNullRector::class, # todo: TMP
52+
CodeQuality\Concat\JoinStringConcatRector::class, # todo: TMP
53+
CodeQuality\Empty_\SimplifyEmptyCheckOnEmptyArrayRector::class, # todo: TMP
54+
CodeQuality\Equal\UseIdenticalOverEqualWithSameTypeRector::class, # todo: TMP
55+
CodeQuality\Expression\InlineIfToExplicitIfRector::class, # todo: TMP (!?!)
56+
CodeQuality\Expression\TernaryFalseExpressionToIfRector::class, # todo: TMP (!?!)
57+
CodeQuality\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector::class, # todo: TMP
58+
CodeQuality\FunctionLike\SimplifyUselessVariableRector::class, # todo: TMP
59+
CodeQuality\Identical\SimplifyBoolIdenticalTrueRector::class, # todo: TMP
60+
CodeQuality\Identical\SimplifyConditionsRector::class, # todo: TMP
61+
CodeQuality\If_\CombineIfRector::class, # todo: TMP<
62+
CodeQuality\If_\CompleteMissingIfElseBracketRector::class, # todo: TMP (!?!)
63+
CodeQuality\If_\ExplicitBoolCompareRector::class, # todo: TMP
64+
CodeQuality\If_\SimplifyIfElseToTernaryRector::class,
3965
CodeQuality\If_\SimplifyIfReturnBoolRector::class,
66+
CodeQuality\Include_\AbsolutizeRequireAndIncludePathRector::class, # todo: TMP
67+
CodeQuality\Isset_\IssetOnPropertyObjectToPropertyExistsRector::class, # todo: TMP
68+
CodeQuality\Ternary\SwitchNegatedTernaryRector::class, # todo: TMP
69+
CodeQuality\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector::class, # todo: TMP
70+
CodeQuality\Ternary\UnnecessaryTernaryExpressionRector::class, # todo: TMP
71+
CodingStyle\Assign\SplitDoubleAssignRector::class, # todo: TMP
72+
CodingStyle\Catch_\CatchExceptionNameMatchingTypeRector::class, # todo: TMP
73+
CodingStyle\ClassMethod\FuncGetArgsToVariadicParamRector::class, # todo: TMP
74+
CodingStyle\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector::class, # todo: TMP
75+
CodingStyle\ClassMethod\NewlineBeforeNewAssignSetRector::class, # todo: TMP
76+
CodingStyle\Encapsed\EncapsedStringsToSprintfRector::class, # todo: TMP
77+
CodingStyle\Encapsed\WrapEncapsedVariableInCurlyBracesRector::class, # todo: TMP
78+
CodingStyle\FuncCall\CallUserFuncArrayToVariadicRector::class, # todo: TMP
79+
CodingStyle\FuncCall\CountArrayToEmptyArrayComparisonRector::class, # todo: TMP
80+
CodingStyle\FuncCall\StrictArraySearchRector::class, # todo: TMP
81+
CodingStyle\If_\NullableCompareToNullRector::class, # todo: TMP
82+
CodingStyle\PostInc\PostIncDecToPreIncDecRector::class, # todo: TMP
83+
CodingStyle\Stmt\NewlineAfterStatementRector::class, # todo: TMP
84+
CodingStyle\String_\SymplifyQuoteEscapeRector::class, # todo: TMP
85+
DeadCode\Assign\RemoveUnusedVariableAssignRector::class, # todo: TMP
86+
DeadCode\Cast\RecastingRemovalRector::class, # todo: TMP (!?!)
87+
DeadCode\ClassMethod\RemoveUnusedConstructorParamRector::class, # todo: TMP (!?!)
88+
DeadCode\ClassMethod\RemoveEmptyClassMethodRector::class, # todo: TMP
89+
DeadCode\ClassMethod\RemoveNullTagValueNodeRector::class, # todo: TMP
90+
DeadCode\ClassMethod\RemoveUnusedPrivateMethodParameterRector::class, # todo: TMP (!?!)
91+
DeadCode\Concat\RemoveConcatAutocastRector::class, # todo: TMP (!?!)
92+
DeadCode\Foreach_\RemoveUnusedForeachKeyRector::class, # todo: TMP
93+
DeadCode\FunctionLike\RemoveDeadReturnRector::class, # todo: TMP
94+
DeadCode\If_\ReduceAlwaysFalseIfOrRector::class, # todo: TMP
95+
DeadCode\If_\RemoveAlwaysTrueIfConditionRector::class, # todo: TMP
96+
DeadCode\If_\RemoveDeadInstanceOfRector::class, # todo: TMP
97+
DeadCode\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector::class, # todo: TMP
98+
DeadCode\If_\SimplifyIfElseWithSameContentRector::class, # todo: TMP
99+
DeadCode\Node\RemoveNonExistingVarAnnotationRector::class, # todo: TMP (!?!)
100+
DeadCode\Plus\RemoveDeadZeroAndOneOperationRector::class, # todo: TMP (!?!)
101+
DeadCode\Property\RemoveUnusedPrivatePropertyRector::class, # todo: TMP
102+
DeadCode\PropertyProperty\RemoveNullPropertyInitializationRector::class, # todo: TMP
103+
DeadCode\Switch_\RemoveDuplicatedCaseInSwitchRector::class, # todo: TMP (!?!)
104+
DeadCode\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class, # todo: TMP
105+
DeadCode\TryCatch\RemoveDeadTryCatchRector::class, # todo: TMP (!?!)
106+
EarlyReturn\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector::class, # todo: TMP
107+
EarlyReturn\If_\ChangeIfElseValueAssignToEarlyReturnRector::class, # todo: TMP
108+
EarlyReturn\If_\ChangeNestedIfsToEarlyReturnRector::class, # todo: TMP
109+
EarlyReturn\If_\ChangeOrIfContinueToMultiContinueRector::class, # todo: TMP
110+
EarlyReturn\If_\RemoveAlwaysElseRector::class, # todo: TMP
111+
EarlyReturn\Return_\ReturnBinaryOrToEarlyReturnRector::class, # todo: TMP
112+
EarlyReturn\Return_\PreparedValueToEarlyReturnRector::class, # todo: TMP
113+
EarlyReturn\StmtsAwareInterface\ReturnEarlyIfVariableRector::class, # todo: TMP
40114
# skip: may conflict with phpstan strict rules
41115
Php53\Ternary\TernaryToElvisRector::class,
42116
Php71\FuncCall\RemoveExtraParametersRector::class, # todo: check later
@@ -46,46 +120,36 @@
46120
Php74\Closure\ClosureToArrowFunctionRector::class,
47121
# skip: causes issues
48122
Php74\Assign\NullCoalescingOperatorRector::class,
123+
Php80\Catch_\RemoveUnusedVariableInCatchRector::class, # todo: TMP
49124
Php80\Class_\AnnotationToAttributeRector::class, # todo: wait for php80
50125
Php80\Class_\ClassPropertyAssignToConstructorPromotionRector::class, # todo: wait for php80
51126
Php80\Class_\StringableForToStringRector::class, # todo: wait for php80
127+
Php80\ClassMethod\AddParamBasedOnParentClassMethodRector::class, # todo: TMP
128+
Php81\Array_\FirstClassCallableRector::class, # todo: TMP
129+
Php81\FuncCall\NullToStrictStringFuncCallArgRector::class, # todo: check later
130+
Strict\Empty_\DisallowedEmptyRuleFixerRector::class, # todo: TMP
131+
TypeDeclaration\BooleanAnd\BinaryOpNullableToInstanceofRector::class, # todo: TMP
52132
TypeDeclaration\ClassMethod\ReturnNeverTypeRector::class,
53-
# use static methods
133+
# skip: cannot be applied to OpenMage codebase - yet
134+
TypeDeclaration\StmtsAwareInterface\DeclareStrictTypesRector::class,
135+
# skip: use static methods
54136
PreferPHPUnitThisCallRector::class,
55137
__DIR__ . '/shell/translations.php',
56138
__DIR__ . '/shell/update-copyright.php',
57139
__DIR__ . '/tests/unit/Mage/Reports/Model/Resource/Report/CollectionTest.php',
58140
])
59-
->withRules([
60-
CodeQuality\BooleanNot\ReplaceMultipleBooleanNotRector::class,
61-
CodeQuality\Foreach_\UnusedForeachValueToArrayKeysRector::class,
62-
CodeQuality\FuncCall\ChangeArrayPushToArrayAssignRector::class,
63-
CodeQuality\FuncCall\CompactToVariablesRector::class,
64-
CodeQuality\FunctionLike\SimplifyUselessVariableRector::class,
65-
CodeQuality\Identical\SimplifyArraySearchRector::class,
66-
CodeQuality\Identical\SimplifyConditionsRector::class,
67-
CodeQuality\Identical\StrlenZeroToIdenticalEmptyStringRector::class,
68-
CodeQuality\NotEqual\CommonNotEqualRector::class,
69-
CodeQuality\LogicalAnd\LogicalToBooleanRector::class,
70-
CodeQuality\Ternary\SimplifyTautologyTernaryRector::class,
71-
CodingStyle\FuncCall\ConsistentImplodeRector::class,
72-
DeadCode\ClassMethod\RemoveUselessParamTagRector::class,
73-
DeadCode\ClassMethod\RemoveUselessReturnTagRector::class,
74-
DeadCode\Property\RemoveUselessVarTagRector::class,
75-
DeadCode\StaticCall\RemoveParentCallWithoutParentRector::class,
76-
])
77141
->withPreparedSets(
78-
deadCode: false,
79-
codeQuality: false,
80-
codingStyle: false,
142+
deadCode: true,
143+
codeQuality: true,
144+
codingStyle: true,
81145
typeDeclarations: false,
82146
privatization: true,
83147
naming: false,
84-
instanceOf: false,
85-
earlyReturn: false,
148+
instanceOf: true,
149+
earlyReturn: true,
86150
strictBooleans: false,
87151
carbon: false,
88-
rectorPreset: false,
152+
rectorPreset: true,
89153
phpunitCodeQuality: true,
90154
doctrineCodeQuality: false,
91155
symfonyCodeQuality: false,

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ See: https://docs.openmage.org/
2323

2424
## Sponsorship
2525

26-
* [opencollective](https://opencollective.com/openmage) [Colin Mollenhour](https://github.com/colinmollenhour))
26+
* [opencollective](https://opencollective.com/openmage) (maintained by [Colin Mollenhour](https://github.com/colinmollenhour))
2727

2828
## License
2929

app/Mage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public static function getOpenMageVersionInfo(): array
206206
if (self::getOpenMageMajorVersion() === 20) {
207207
return [
208208
'major' => '20',
209-
'minor' => '14',
209+
'minor' => '15',
210210
'patch' => '0',
211211
'stability' => '', // beta,alpha,rc
212212
'number' => '', // 1,2,3,0.3.7,x.7.z.92 @see https://semver.org/#spec-item-9

app/code/core/Mage/Admin/Model/Acl/Role/Registry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function addParent($role, $parents)
3131
$role = $this->get($role);
3232
}
3333
} catch (Zend_Acl_Role_Registry_Exception $e) {
34-
throw new Zend_Acl_Role_Registry_Exception("Child Role id '$roleId' does not exist");
34+
throw new Zend_Acl_Role_Registry_Exception("Child Role id '$roleId' does not exist", $e->getCode(), $e);
3535
}
3636

3737
if (!is_array($parents)) {
@@ -46,7 +46,7 @@ public function addParent($role, $parents)
4646
}
4747
$roleParent = $this->get($roleParentId);
4848
} catch (Zend_Acl_Role_Registry_Exception $e) {
49-
throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist");
49+
throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist", $e->getCode(), $e);
5050
}
5151
$this->_roles[$roleId]['parents'][$roleParentId] = $roleParent;
5252
$this->_roles[$roleParentId]['children'][$roleId] = $role;

app/code/core/Mage/Admin/Model/Observer.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ public function actionPreDispatchAdmin($observer)
5454
$password = $postLogin['password'] ?? '';
5555
$session->login($username, $password, $request);
5656
$request->setPost('login', null);
57-
} else {
58-
if (!$request->getParam('messageSent')) {
59-
Mage::getSingleton('adminhtml/session')->addError(
60-
Mage::helper('adminhtml')->__('Invalid Form Key. Please refresh the page.'),
61-
);
62-
$request->setParam('messageSent', true);
63-
}
57+
} elseif (!$request->getParam('messageSent')) {
58+
Mage::getSingleton('adminhtml/session')->addError(
59+
Mage::helper('adminhtml')->__('Invalid Form Key. Please refresh the page.'),
60+
);
61+
$request->setParam('messageSent', true);
6462
}
6563

6664
$coreSession->renewFormKey();

app/code/core/Mage/Admin/Model/Redirectpolicy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function getRedirectUrl(
3939
?Zend_Controller_Request_Http $request = null,
4040
$alternativeUrl = null
4141
) {
42-
if (empty($request)) {
42+
if (!$request instanceof Zend_Controller_Request_Http) {
4343
return null;
4444
}
4545
$countRequiredParams = ($this->_urlModel->useSecretKey()

app/code/core/Mage/Admin/Model/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,6 @@ public function getMinAdminPasswordLength()
819819
{
820820
$minLength = Mage::getStoreConfigAsInt(self::XML_PATH_MIN_ADMIN_PASSWORD_LENGTH);
821821
$absoluteMinLength = Mage_Core_Model_App::ABSOLUTE_MIN_PASSWORD_LENGTH;
822-
return ($minLength < $absoluteMinLength) ? $absoluteMinLength : $minLength;
822+
return max($absoluteMinLength, $minLength);
823823
}
824824
}

app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Main.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ protected function _prepareForm()
2828
$fieldset->addField('user_id', 'hidden', [
2929
'name' => 'user_id',
3030
]);
31-
} else {
32-
if (!$model->hasData('is_active')) {
33-
$model->setIsActive(1);
34-
}
31+
} elseif (!$model->hasData('is_active')) {
32+
$model->setIsActive(1);
3533
}
3634

3735
$fieldset->addField('username', 'text', [

0 commit comments

Comments
 (0)