From aff71b1fde0308637828725e5ecbe77c516dac2b Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 6 Sep 2024 04:15:38 +0200 Subject: [PATCH 1/4] PhpStan: bumped to 1.12.1 & renamed config files (#4183) * Moved files * Updated labeler.yml --- .github/labeler.yml | 1 + .gitignore | 5 ++++- ...dist.baseline.neon => .phpstan.dist.baseline.neon | 5 +++++ phpstan.dist.neon => .phpstan.dist.neon | 2 +- composer.json | 2 +- composer.lock | 12 ++++++------ 6 files changed, 18 insertions(+), 9 deletions(-) rename phpstan.dist.baseline.neon => .phpstan.dist.baseline.neon (99%) rename phpstan.dist.neon => .phpstan.dist.neon (98%) diff --git a/.github/labeler.yml b/.github/labeler.yml index 61d73ee8dba..a1b1d9fad16 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -887,6 +887,7 @@ 'phpstan': - changed-files: - any-glob-to-any-file: [ + .phpstan*, phpstan*, .github/workflows/phpstan.yml ] diff --git a/.gitignore b/.gitignore index b4818b73403..e5aaad872a9 100644 --- a/.gitignore +++ b/.gitignore @@ -70,8 +70,11 @@ .phpcs*.xml !.phpcs*.xml.dist +# PhpStan +.phpstan*.neon phpstan*.neon -!phpstan.dist.*.neon +!.phpstan.dist.neon +!.phpstan.dist.*.neon # dev scripts loaded via composer /shell/update-copyright.php diff --git a/phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon similarity index 99% rename from phpstan.dist.baseline.neon rename to .phpstan.dist.baseline.neon index b417687de7d..d70de206053 100644 --- a/phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -3965,6 +3965,11 @@ parameters: count: 1 path: app/code/core/Mage/Sales/Model/Entity/Quote/Address/Attribute/Frontend/Tax.php + - + message: "#^Negated boolean expression is always true\\.$#" + count: 1 + path: app/code/core/Mage/Sales/Model/Order.php + - message: "#^Variable \\$oldArea might not be defined\\.$#" count: 1 diff --git a/phpstan.dist.neon b/.phpstan.dist.neon similarity index 98% rename from phpstan.dist.neon rename to .phpstan.dist.neon index c95f0f64594..a3a1dc335cb 100644 --- a/phpstan.dist.neon +++ b/.phpstan.dist.neon @@ -1,6 +1,6 @@ includes: - vendor/macopedia/phpstan-magento1/extension.neon - - phpstan.dist.baseline.neon + - .phpstan.dist.baseline.neon - phar://phpstan.phar/conf/bleedingEdge.neon parameters: magentoRootPath: %currentWorkingDirectory% diff --git a/composer.json b/composer.json index a63c329cfb3..7d2fd3da332 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "openmage/dev-meta-package": "^1.0", "phpcompatibility/php-compatibility": "^9.3", "phpmd/phpmd": "^2.13", - "phpstan/phpstan": "^1.11", + "phpstan/phpstan": "^1.12.1", "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "^3.7", "symplify/vendor-patches": "^11.1" diff --git a/composer.lock b/composer.lock index 7416609aac5..11ab5747805 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "40e9d3cfc444bb72b7cf7754c735f694", + "content-hash": "59d169c9f9fd98541d9af1b1f00dc20b", "packages": [ { "name": "colinmollenhour/cache-backend-redis", @@ -3486,16 +3486,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.0", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "384af967d35b2162f69526c7276acadce534d0e1" + "reference": "d8ed7fffa66de1db0d2972267d8ed1d8fa0fe5a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/384af967d35b2162f69526c7276acadce534d0e1", - "reference": "384af967d35b2162f69526c7276acadce534d0e1", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d8ed7fffa66de1db0d2972267d8ed1d8fa0fe5a2", + "reference": "d8ed7fffa66de1db0d2972267d8ed1d8fa0fe5a2", "shasum": "" }, "require": { @@ -3540,7 +3540,7 @@ "type": "github" } ], - "time": "2024-08-27T09:18:05+00:00" + "time": "2024-09-03T19:55:22+00:00" }, { "name": "phpunit/php-code-coverage", From 7f13c913fca51f9d63ccce458aa480637886694a Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 6 Sep 2024 16:55:18 +0200 Subject: [PATCH 2/4] phpstan L7 update (#4187) --- app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend.php | 3 +++ app/code/core/Mage/Sendfriend/Model/Sendfriend.php | 4 ++-- .../core/Mage/Sendfriend/controllers/ProductController.php | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend.php b/app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend.php index cea3d167fa2..5dbf8ee1aad 100644 --- a/app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend.php +++ b/app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend.php @@ -21,6 +21,9 @@ */ class Mage_Sendfriend_Model_Resource_Sendfriend extends Mage_Core_Model_Resource_Db_Abstract { + /** + * @return void + */ protected function _construct() { $this->_init('sendfriend/sendfriend', 'log_id'); diff --git a/app/code/core/Mage/Sendfriend/Model/Sendfriend.php b/app/code/core/Mage/Sendfriend/Model/Sendfriend.php index 3f9ff489fa5..a202f9acba6 100644 --- a/app/code/core/Mage/Sendfriend/Model/Sendfriend.php +++ b/app/code/core/Mage/Sendfriend/Model/Sendfriend.php @@ -233,7 +233,7 @@ public function getCookie() /** * Set Visitor Remote Address * - * @param int $ipAddr the IP address on Long Format + * @param string|false $ipAddr the IP address on Long Format * @return $this */ public function setRemoteAddr($ipAddr) @@ -255,7 +255,7 @@ public function getRemoteAddr() /** * Set Website Id * - * @param int $id - website id + * @param int|string|null $id - website id * @return $this */ public function setWebsiteId($id) diff --git a/app/code/core/Mage/Sendfriend/controllers/ProductController.php b/app/code/core/Mage/Sendfriend/controllers/ProductController.php index 6a738071404..42592be7091 100644 --- a/app/code/core/Mage/Sendfriend/controllers/ProductController.php +++ b/app/code/core/Mage/Sendfriend/controllers/ProductController.php @@ -96,6 +96,7 @@ protected function _initSendToFriendModel() /** * Show Send to a Friend Form * + * @return void */ public function sendAction() { @@ -132,6 +133,7 @@ public function sendAction() /** * Send Email Post Action * + * @return $this|void */ public function sendmailAction() { From 96e02334685405503a7f022e662199c626c384f6 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 6 Sep 2024 16:57:15 +0200 Subject: [PATCH 3/4] DDEV: file permission and bugfix (#4145) * Set permissions to 755 * Fixed typo --- .ddev/commands/web/magerun | 2 +- .ddev/commands/web/openmage-admin | 0 2 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 .ddev/commands/web/magerun mode change 100644 => 100755 .ddev/commands/web/openmage-admin diff --git a/.ddev/commands/web/magerun b/.ddev/commands/web/magerun old mode 100644 new mode 100755 index 5ddff79db21..a03899bf01f --- a/.ddev/commands/web/magerun +++ b/.ddev/commands/web/magerun @@ -5,7 +5,7 @@ ## Example: "ddev magerun" if [ ! -f vendor/bin/n98-magerun ]; then - read -r -p "n98-magerun is not installed. Do you want to install it? [y/N] " INSTALL_MAGE + read -r -p "n98-magerun is not installed. Do you want to install it? [y/N] " INSTALL_MAGERUN INSTALL_MAGERUN=${INSTALL_MAGERUN,,} # to lower if [[ "${INSTALL_MAGERUN}" =~ ^(yes|y) ]]; then composer require --dev n98/magerun:dev-develop diff --git a/.ddev/commands/web/openmage-admin b/.ddev/commands/web/openmage-admin old mode 100644 new mode 100755 From a375fad1b69c4b4915bbd91b9d7b7af4e5bd04d0 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 6 Sep 2024 16:58:40 +0200 Subject: [PATCH 4/4] updated php-cs-fixer (#4185) --- .php-cs-fixer.dist.php | 2 ++ .../Block/Catalog/Product/Edit/Tab/Super/Settings.php | 2 +- .../Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php | 2 +- .../Adminhtml/Block/Customer/Edit/Tab/Addresses.php | 4 ++-- app/code/core/Mage/Catalog/Model/Product/Image.php | 6 +++--- app/code/core/Mage/Core/Model/Translate.php | 2 +- app/code/core/Mage/ImportExport/Model/Export.php | 2 +- .../Adminhtml/System/Config/Fieldset/Location.php | 10 +++++----- app/code/core/Mage/Rule/Model/Resource/Abstract.php | 2 +- .../sql/sales_setup/mysql4-upgrade-1.3.99-1.4.0.0.php | 4 ++-- .../Usa/Model/Shipping/Carrier/Dhl/International.php | 2 +- .../core/Mage/Usa/Model/Shipping/Carrier/Fedex.php | 2 +- lib/Varien/Data/Form/Element/Color.php | 2 +- lib/Varien/Db/Tree.php | 4 ++-- lib/Varien/Filter/FormElementName.php | 2 +- 15 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 8c1bf39a95b..56299528928 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -20,6 +20,8 @@ 'class_definition' => true, // Remove extra spaces in a nullable typehint. 'compact_nullable_typehint' => true, + // Concatenation should be spaced according to configuration. + 'concat_space' => ['spacing' => 'one'], // The PHP constants `true`, `false`, and `null` MUST be written using the correct casing. 'constant_case' => true, // Equal sign in declare statement should be surrounded by spaces or not following configuration. diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php index 9255504e2f3..218ef0eb592 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php @@ -76,7 +76,7 @@ protected function _prepareForm() $fieldset->addField('req_text', 'note', [ 'text' => '
    • ' - . $this->__('Only attributes with scope "Global", input type "Dropdown" and Use To Create Configurable Product "Yes" are available.') + . $this->__('Only attributes with scope "Global", input type "Dropdown" and Use To Create Configurable Product "Yes" are available.') . '
' ]); diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php index b7296fb1162..b0846a73b7c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php @@ -78,7 +78,7 @@ public function initForm() $form->getElement('website_id')->setAfterElementHtml( '