From eaf63c172ed61a86623cd736b27bbfad2c7c2838 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 11 Nov 2024 11:46:25 +0100 Subject: [PATCH] Code quality: added PHPMD, updated workflow (#4303) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added phpmd to workflow * replaced variabvĺe $_item * replaced variabvĺe $_rss_url * replaced variabvĺe $_storeIds * replaced variabvĺe $_buyRequest * replaced variabvĺe $_typeId * replaced variabvĺe $_serviceCode * replaced variabvĺe $access_key * replaced variabvĺe $method_arr * replaced variabvĺe $font_size * phpcs * phpstan * fix phpunit workflow * phpstan baseline * tmp - disabled ShortVariable phpmd rule * phpmd - ignore long class/variable names * phpmd - ignore BooleanGetMethodName * replaced variabvĺe $increment_id * replaced variabvĺe $_profilerKey * replaced variabvĺe $_option * replaced variabvĺe $drawing_text * replaced variabvĺe $read_adapter * replaced variabvĺe $rules_set * replaced variabvĺe $select_id * replaced variabvĺe $currency_code * replaced variabvĺe $_selection * replaced variabvĺe $_checkedPaths * replaced variabvĺe $_optionId * replaced variabvĺe $url_prefix * replaced variabvĺe $logo_src * replaced variabvĺe $_printValue * replaced variabvĺe $entity_id * replaced variabvĺe $_key * replaced variabvĺe $_value * replaced variabvĺe $item_id * replaced variable $tax_amount * replaced variable $tax_info * replaced variable ... * replaced variable $total_reviews * replaced variable $_truncatedValue * replaced variable ... * replaced variable ... * replaced variable ... * replaced variable ... * update * copyright dates * fix * rector * updated commands * updated commands * removed some phpcs comments * added phpcs default config (for phpstorm) * added github label * phpcs * update baseline --- .ddev/commands/web/phpcs | 2 +- .ddev/commands/web/phpmd | 2 +- .ddev/commands/web/phpmd-no-baseline | 7 + .ddev/commands/web/phpunit | 2 +- .ddev/commands/web/phpunit-coverage | 2 +- .ddev/commands/web/phpunit-coverage-local | 2 +- .ddev/commands/web/rector | 2 +- .gitattributes | 5 +- .github/labeler.yml | 12 +- .github/workflows/check-files.yml | 17 +- .github/workflows/phpcs.yml | 8 +- .github/workflows/phpmd.yml | 32 +++ .github/workflows/phpstan.yml | 4 +- .github/workflows/phpunit.yml | 2 +- .github/workflows/rector.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/workflow.yml | 30 ++- .gitignore | 11 +- .phpcs.dist.ecg.xml | 146 +++++++++++++ .phpcs.php.xml.dist => .phpcs.dist.php.xml | 2 +- .phpcs.xml.dist => .phpcs.dist.xml | 3 +- .phpcs.ecg.xml.dist | 184 ---------------- .phpcs.xml | 6 + .phpmd.dist.baseline.xml | 24 +++ .phpmd.dist.xml | 45 ++-- .phpstan.dist.baseline.neon | 145 ------------- phpunit.xml.dist => .phpunit.dist.xml | 0 rector.php => .rector.php | 0 .../Adminhtml/Block/Api/Tab/Rolesedit.php | 6 +- .../Adminhtml/Block/Api/Tab/Userroles.php | 4 +- .../core/Mage/Adminhtml/Block/Cache/Grid.php | 2 - .../Product/Edit/Tab/Options/Option.php | 48 ++--- .../Catalog/Product/Helper/Form/Gallery.php | 6 +- .../Block/Customer/Edit/Tab/Account.php | 6 +- .../Mage/Adminhtml/Block/Dashboard/Graph.php | 5 - .../Block/Permissions/Tab/Rolesedit.php | 8 +- .../Block/Permissions/Tab/Userroles.php | 4 +- .../Report/Config/Form/Field/YtdStart.php | 6 +- .../Adminhtml/Block/Report/Grid/Abstract.php | 1 - .../Report/Grid/Column/Renderer/Currency.php | 9 +- .../Mage/Adminhtml/Block/Report/Wishlist.php | 3 +- .../Block/Sales/Items/Column/Default.php | 8 +- .../Block/Sales/Items/Column/Name.php | 8 +- .../Sales/Order/Create/Sidebar/Pcompared.php | 6 +- .../Sales/Order/Invoice/Create/Items.php | 14 +- .../Mage/Adminhtml/Block/Sales/Order/View.php | 14 +- .../Block/Sales/Order/View/Tab/History.php | 61 +++--- .../Mage/Adminhtml/Block/Store/Switcher.php | 6 +- .../Email/Template/Grid/Renderer/Type.php | 6 +- .../Adminhtml/Block/Urlrewrite/Edit/Form.php | 26 +-- .../Mage/Adminhtml/Block/Widget/Container.php | 18 +- .../core/Mage/Adminhtml/Block/Widget/Form.php | 1 - .../core/Mage/Adminhtml/Block/Widget/Grid.php | 2 - .../Adminhtml/Block/Widget/Grid/Column.php | 2 - .../Widget/Grid/Column/Renderer/Currency.php | 6 +- .../Widget/Grid/Column/Renderer/Price.php | 6 +- .../core/Mage/Adminhtml/Controller/Action.php | 24 ++- .../Model/Customer/Renderer/Region.php | 4 + .../Adminhtml/Model/Sales/Order/Create.php | 14 +- .../System/Config/Backend/Admin/Observer.php | 3 +- .../Model/System/Config/Backend/Color.php | 6 +- .../Model/System/Config/Backend/File.php | 1 + .../System/Config/Source/Currency/Service.php | 10 +- .../Config/Source/Storage/Media/Database.php | 12 +- .../Mage/Adminhtml/Model/System/Store.php | 1 - app/code/core/Mage/Adminhtml/Model/Url.php | 16 +- .../Adminhtml/controllers/AjaxController.php | 3 +- .../Catalog/CategoryController.php | 16 +- .../controllers/Catalog/ProductController.php | 20 +- .../Cms/Wysiwyg/ImagesController.php | 8 +- .../controllers/CustomerController.php | 18 +- .../Config/System/StorageController.php | 4 +- .../controllers/System/ConfigController.php | 6 +- .../controllers/Tax/RateController.php | 7 + .../Mage/Api/Model/Server/Adapter/Soap.php | 1 + .../Api/Model/Server/Handler/Abstract.php | 1 + .../Api/controllers/V2/SoapController.php | 8 +- app/code/core/Mage/Api2/Model/Acl/Filter.php | 1 + app/code/core/Mage/Api2/Model/Resource.php | 2 - .../Catalog/Product/Edit/Tab/Attributes.php | 14 +- .../Adminhtml/Sales/Order/Items/Renderer.php | 21 +- .../Catalog/Product/View/Type/Bundle.php | 54 ++--- .../Product/View/Type/Bundle/Option.php | 58 ++--- .../Block/Sales/Order/Items/Renderer.php | 21 +- .../core/Mage/Bundle/Model/Product/Type.php | 15 +- .../Model/Resource/Option/Collection.php | 12 +- .../Model/Sales/Order/Pdf/Items/Abstract.php | 21 +- .../Sales/Order/Pdf/Items/Creditmemo.php | 40 ++-- .../Model/Sales/Order/Pdf/Items/Invoice.php | 44 ++-- .../Model/Sales/Order/Pdf/Items/Shipment.php | 36 ++-- .../Mage/Catalog/Block/Product/Abstract.php | 8 +- .../Product/View/Options/Type/Select.php | 76 +++---- .../Catalog/Helper/Product/Configuration.php | 14 +- .../core/Mage/Catalog/Helper/Product/View.php | 3 +- .../core/Mage/Catalog/Model/Category/Api.php | 16 +- .../Mage/Catalog/Model/Category/Api/V2.php | 8 +- .../Category/Attribute/Backend/Image.php | 1 + app/code/core/Mage/Catalog/Model/Product.php | 1 - .../Mage/Catalog/Model/Product/Api/V2.php | 39 ++-- .../Catalog/Model/Product/Attribute/Api.php | 6 +- .../Mage/Catalog/Model/Product/Option.php | 42 ++-- .../Model/Product/Option/Type/Default.php | 16 +- .../Model/Product/Option/Type/File.php | 7 +- .../Model/Product/Option/Type/Select.php | 14 +- .../Catalog/Model/Product/Option/Value.php | 32 +-- .../Catalog/Model/Product/Type/Abstract.php | 18 +- .../Mage/Catalog/Model/Resource/Abstract.php | 4 +- .../Mage/Catalog/Model/Resource/Category.php | 1 - .../Catalog/Model/Resource/Category/Flat.php | 20 +- .../Model/Resource/Collection/Abstract.php | 8 +- .../Mage/Catalog/Model/Resource/Product.php | 1 - .../Product/Attribute/Backend/Image.php | 1 + .../Catalog/Model/Resource/Product/Option.php | 4 +- .../Model/Resource/Product/Option/Value.php | 2 +- .../core/Mage/Catalog/Model/Resource/Url.php | 10 +- .../Catalog/controllers/ProductController.php | 4 + .../Model/Resource/Indexer/Abstract.php | 1 - .../Mage/CatalogInventory/Model/Observer.php | 2 - .../Block/Multishipping/Billing/Items.php | 8 +- .../Checkout/Block/Multishipping/Overview.php | 8 +- app/code/core/Mage/Checkout/Helper/Data.php | 8 +- .../Checkout/Model/Type/Multishipping.php | 28 +-- app/code/core/Mage/Cms/Controller/Router.php | 2 +- .../core/Mage/Cms/Helper/Wysiwyg/Images.php | 7 - .../Mage/Cms/Model/Wysiwyg/Images/Storage.php | 14 -- .../Mage/ConfigurableSwatches/Helper/Data.php | 3 +- app/code/core/Mage/Core/Block/Abstract.php | 6 +- app/code/core/Mage/Core/Block/Profiler.php | 2 +- .../Mage/Core/Block/Text/Tag/Css/Admin.php | 5 +- .../core/Mage/Core/Block/Text/Tag/Debug.php | 2 +- .../Mage/Core/Controller/Front/Action.php | 5 +- .../Mage/Core/Controller/Request/Http.php | 7 +- .../Mage/Core/Controller/Response/Http.php | 5 +- .../Mage/Core/Controller/Varien/Action.php | 32 +-- .../Mage/Core/Controller/Varien/Front.php | 2 + .../Core/Controller/Varien/Router/Admin.php | 3 +- .../Controller/Varien/Router/Standard.php | 5 +- app/code/core/Mage/Core/Helper/Abstract.php | 2 + app/code/core/Mage/Core/Helper/Data.php | 14 -- .../Core/Helper/EnvironmentConfigLoader.php | 2 +- app/code/core/Mage/Core/Helper/Http.php | 5 +- app/code/core/Mage/Core/Helper/String.php | 1 + app/code/core/Mage/Core/Model/Abstract.php | 4 +- app/code/core/Mage/Core/Model/App.php | 29 +-- app/code/core/Mage/Core/Model/Config.php | 19 +- .../core/Mage/Core/Model/Config/Element.php | 1 + .../core/Mage/Core/Model/Config/Options.php | 5 +- .../core/Mage/Core/Model/Design/Package.php | 18 +- app/code/core/Mage/Core/Model/Email/Queue.php | 12 +- app/code/core/Mage/Core/Model/Layout.php | 18 +- .../core/Mage/Core/Model/Layout/Update.php | 16 +- app/code/core/Mage/Core/Model/Locale.php | 1 + .../Mage/Core/Model/Resource/Abstract.php | 5 +- .../Mage/Core/Model/Resource/Email/Queue.php | 2 + .../Mage/Core/Model/Resource/Resource.php | 12 +- .../core/Mage/Core/Model/Resource/Session.php | 3 +- .../core/Mage/Core/Model/Session/Abstract.php | 13 +- .../Core/Model/Session/Abstract/Varien.php | 10 + app/code/core/Mage/Core/Model/Store.php | 2 + app/code/core/Mage/Core/Model/Translate.php | 7 +- .../core/Mage/Core/Model/Translate/Inline.php | 5 +- app/code/core/Mage/Core/Model/Url.php | 3 +- app/code/core/Mage/Core/Model/Url/Rewrite.php | 3 + .../Mage/Core/Model/Url/Rewrite/Request.php | 2 + app/code/core/Mage/Core/functions.php | 20 +- .../Mage/Customer/Model/Address/Abstract.php | 8 +- .../core/Mage/Customer/Model/Customer.php | 9 +- .../Mage/Customer/Model/Customer/Api/V2.php | 6 +- app/code/core/Mage/Customer/Model/Group.php | 3 +- .../Dataflow/Model/Convert/Adapter/Http.php | 13 +- .../Dataflow/Model/Convert/Iterator/Http.php | 6 +- .../Model/Convert/Profile/Abstract.php | 1 + .../Model/Convert/Profile/Collection.php | 3 + app/code/core/Mage/Dataflow/Model/Profile.php | 12 +- .../Dataflow/Model/Session/Adapter/Http.php | 6 +- .../Model/Currency/Import/Abstract.php | 3 +- .../Currency/Import/Currencyconverterapi.php | 1 + .../Model/Currency/Import/Fixerio.php | 1 + .../Model/Resource/Country/Collection.php | 8 +- .../Product/Edit/Tab/Downloadable/Links.php | 6 +- .../Block/Customer/Products/List.php | 8 +- .../Mage/Downloadable/Helper/Download.php | 3 +- .../Sales/Order/Pdf/Items/Creditmemo.php | 6 +- .../Model/Sales/Order/Pdf/Items/Invoice.php | 6 +- .../Downloadable/Product/EditController.php | 3 +- .../controllers/DownloadController.php | 7 +- .../Mage/Eav/Model/Attribute/Data/File.php | 1 + .../core/Mage/Eav/Model/Entity/Abstract.php | 6 - .../Entity/Attribute/Source/Abstract.php | 8 +- .../Eav/Model/Entity/Collection/Abstract.php | 3 +- app/code/core/Mage/Eav/Model/Entity/Setup.php | 2 - .../Block/Adminhtml/Import/Frame/Result.php | 4 +- .../core/Mage/ImportExport/Model/Import.php | 1 + .../Model/Import/Entity/Product.php | 2 + .../Adminhtml/ImportController.php | 2 + app/code/core/Mage/Index/Model/Event.php | 2 - app/code/core/Mage/Index/Model/Lock.php | 6 - .../Mage/Install/Model/Installer/Console.php | 1 + .../Install/Model/Installer/Filesystem.php | 7 +- .../Install/controllers/WizardController.php | 5 + app/code/core/Mage/Oauth/Model/Observer.php | 6 + app/code/core/Mage/Page/Block/Html/Header.php | 10 +- .../core/Mage/Page/Block/Template/Links.php | 1 + app/code/core/Mage/Payment/Block/Info.php | 6 +- app/code/core/Mage/Paypal/Block/Iframe.php | 1 - app/code/core/Mage/Paypal/Model/Ipn.php | 4 +- .../Mage/Paypal/Model/Payflow/Request.php | 2 +- .../Model/System/Config/Backend/Cert.php | 3 +- .../Mage/Paypal/controllers/IpnController.php | 4 +- .../Paypal/controllers/StandardController.php | 7 +- .../Reports/Model/Product/Index/Compared.php | 6 +- .../Model/Resource/Report/Abstract.php | 5 +- .../Mage/Review/Model/Resource/Review.php | 11 +- app/code/core/Mage/Review/Model/Review.php | 12 +- .../core/Mage/Rss/Block/Catalog/Abstract.php | 10 +- .../core/Mage/Rss/Block/Catalog/Category.php | 21 +- app/code/core/Mage/Rss/Block/Catalog/Tag.php | 10 +- .../Block/Order/Item/Renderer/Default.php | 12 +- .../Sales/Model/Entity/Sale/Collection.php | 1 - .../Mage/Sales/Model/Order/Pdf/Abstract.php | 32 +-- .../Order/Pdf/Items/Creditmemo/Default.php | 6 +- .../Model/Order/Pdf/Items/Invoice/Default.php | 6 +- .../Order/Pdf/Items/Shipment/Default.php | 6 +- .../Sales/Model/Order/Pdf/Total/Default.php | 12 +- app/code/core/Mage/Sales/Model/Quote.php | 16 +- .../core/Mage/Sales/Model/Resource/Quote.php | 6 +- .../Sales/controllers/DownloadController.php | 4 +- .../core/Mage/SalesRule/Model/Observer.php | 7 + .../Mage/Shipping/Block/Tracking/Popup.php | 12 +- .../Mage/Shipping/Model/Carrier/Abstract.php | 7 - .../Mage/Shipping/Model/Carrier/Tablerate.php | 6 +- app/code/core/Mage/Shipping/Model/Info.php | 10 +- .../core/Mage/Shipping/Model/Rate/Request.php | 6 +- .../core/Mage/Shipping/Model/Rate/Result.php | 2 +- .../Model/Resource/Carrier/Tablerate.php | 1 + app/code/core/Mage/Tax/Helper/Data.php | 14 +- .../Mage/Tax/Model/Resource/Calculation.php | 8 +- .../Model/Resource/Sales/Order/Tax/Item.php | 9 +- .../Mage/Tax/Model/Sales/Pdf/Grandtotal.php | 4 +- .../Mage/Tax/Model/Sales/Pdf/Shipping.php | 4 +- .../Mage/Tax/Model/Sales/Pdf/Subtotal.php | 4 +- .../core/Mage/Tax/Model/Sales/Pdf/Tax.php | 4 +- .../Mage/Uploader/Model/Config/Abstract.php | 2 +- .../Mage/Usa/Model/Shipping/Carrier/Dhl.php | 203 +++++++++--------- .../Shipping/Carrier/Dhl/Label/Pdf/Page.php | 14 +- .../Carrier/Dhl/Label/Pdf/PageBuilder.php | 4 +- .../Mage/Usa/Model/Shipping/Carrier/Ups.php | 20 +- .../Mage/Usa/Model/Shipping/Carrier/Usps.php | 4 +- .../core/Mage/Wishlist/Block/Abstract.php | 8 +- app/code/core/Mage/Wishlist/Model/Item.php | 9 +- .../Model/Resource/Item/Option/Collection.php | 4 +- .../core/Mage/Wishlist/Model/Wishlist.php | 34 +-- .../Wishlist/controllers/IndexController.php | 6 +- .../template/catalog/product/price.phtml | 1 + composer.json | 16 +- lib/Mage/HTTP/Client/Curl.php | 2 +- lib/Mage/HTTP/Client/Socket.php | 2 +- lib/Mage/System/Ftp.php | 27 --- lib/Mage/Xml/Generator.php | 38 ++-- lib/Varien/Data/Collection/Db.php | 1 - lib/Varien/Data/Form/Abstract.php | 1 - lib/Varien/Db/Adapter/Interface.php | 6 +- lib/Varien/Db/Adapter/Pdo/Mysql.php | 6 +- lib/Varien/Db/Ddl/Table.php | 4 - lib/Varien/Event/Observer.php | 6 +- lib/Varien/Io/Ftp.php | 25 --- lib/Varien/Object.php | 1 - tests/unit/Base/XmlFileLoadingTest.php | 1 - .../Model/Security/HtmlEscapedStringTest.php | 2 - 269 files changed, 1599 insertions(+), 1593 deletions(-) create mode 100755 .ddev/commands/web/phpmd-no-baseline create mode 100644 .github/workflows/phpmd.yml create mode 100644 .phpcs.dist.ecg.xml rename .phpcs.php.xml.dist => .phpcs.dist.php.xml (98%) rename .phpcs.xml.dist => .phpcs.dist.xml (98%) delete mode 100644 .phpcs.ecg.xml.dist create mode 100644 .phpcs.xml create mode 100644 .phpmd.dist.baseline.xml rename phpunit.xml.dist => .phpunit.dist.xml (100%) rename rector.php => .rector.php (100%) diff --git a/.ddev/commands/web/phpcs b/.ddev/commands/web/phpcs index 95cbaa9e02f..41fc539a3b4 100755 --- a/.ddev/commands/web/phpcs +++ b/.ddev/commands/web/phpcs @@ -4,4 +4,4 @@ ## Usage: phpcs ## Example: ddev phpcs -php vendor/bin/phpcs -s -p --report=full,summary "$@" +php vendor/bin/phpcs -s -p --standard=.phpcs.dist.xml --cache=.phpcs.result.cache --report=full,summary "$@" diff --git a/.ddev/commands/web/phpmd b/.ddev/commands/web/phpmd index 88bdd914ea0..3014fd7d6b9 100755 --- a/.ddev/commands/web/phpmd +++ b/.ddev/commands/web/phpmd @@ -4,4 +4,4 @@ ## Usage: phpmd ## Example: ddev phpmd -php vendor/bin/phpmd "$@" text .phpmd.dist.xml +php vendor/bin/phpmd "$@" text .phpmd.dist.xml --color --cache --baseline-file .phpmd.dist.baseline.xml diff --git a/.ddev/commands/web/phpmd-no-baseline b/.ddev/commands/web/phpmd-no-baseline new file mode 100755 index 00000000000..ca6448baa95 --- /dev/null +++ b/.ddev/commands/web/phpmd-no-baseline @@ -0,0 +1,7 @@ +#!/bin/bash + +## Description: run PHPMD +## Usage: phpmd-no-baseline +## Example: ddev phpmd-no-baseline + +php vendor/bin/phpmd "$@" text .phpmd.dist.xml diff --git a/.ddev/commands/web/phpunit b/.ddev/commands/web/phpunit index 40352e7b153..3ff16280ac0 100755 --- a/.ddev/commands/web/phpunit +++ b/.ddev/commands/web/phpunit @@ -4,4 +4,4 @@ ## Usage: phpunit ## Example: ddev phpunit -php vendor/bin/phpunit --no-coverage "$@" --testdox +php vendor/bin/phpunit --configuration .phpunit.dist.xml --no-coverage "$@" --testdox diff --git a/.ddev/commands/web/phpunit-coverage b/.ddev/commands/web/phpunit-coverage index 7a877d6cb6d..c12fd4b7b2d 100755 --- a/.ddev/commands/web/phpunit-coverage +++ b/.ddev/commands/web/phpunit-coverage @@ -5,5 +5,5 @@ ## Example: ddev phpunit-coverage enable_xdebug -XDEBUG_MODE=coverage php vendor/bin/phpunit "$@" --testdox +XDEBUG_MODE=coverage php vendor/bin/phpunit --configuration .phpunit.dist.xml --testdox "$@" disable_xdebug \ No newline at end of file diff --git a/.ddev/commands/web/phpunit-coverage-local b/.ddev/commands/web/phpunit-coverage-local index b563b88268c..0e4ed542650 100755 --- a/.ddev/commands/web/phpunit-coverage-local +++ b/.ddev/commands/web/phpunit-coverage-local @@ -5,5 +5,5 @@ ## Example: ddev phpunit-coverage-local enable_xdebug -XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-html build/coverage "$@" --testdox +XDEBUG_MODE=coverage php vendor/bin/phpunit --configuration .phpunit.dist.xml --coverage-html build/coverage --testdox "$@" disable_xdebug \ No newline at end of file diff --git a/.ddev/commands/web/rector b/.ddev/commands/web/rector index 1189ce12807..db048f56b61 100755 --- a/.ddev/commands/web/rector +++ b/.ddev/commands/web/rector @@ -4,4 +4,4 @@ ## Usage: rector ## Example: ddev rector -php vendor/bin/rector process "$@" +php vendor/bin/rector process --config .rector.php "$@" diff --git a/.gitattributes b/.gitattributes index e000b8e4c36..eaae8b8a097 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14,10 +14,11 @@ /.phpcs.ecg.xml.dist export-ignore /.phpcs.php.xml.dist export-ignore /.phpcs.xml.dist export-ignore +/.phpmd.dist.baseline.xml export-ignore /.phpmd.dist.xml export-ignore /.phpstan.dist.baseline.neon export-ignore /.phpstan.dist.neon export-ignore -/rector.php export-ignore +/.rector.php export-ignore /README.md export-ignore @@ -35,4 +36,4 @@ *.sql text eol=lf *.svg text eol=lf *.txt text eol=lf -*.phtml text eol=lf \ No newline at end of file +*.phtml text eol=lf diff --git a/.github/labeler.yml b/.github/labeler.yml index 876fc5fcf0b..5f54a61a335 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -884,18 +884,24 @@ .github/workflows/php-cs-fixer.yml ] +'phpmd': + - changed-files: + - any-glob-to-any-file: [ + .phpmd*, + .github/workflows/phpmd.yml + ] + 'phpstan': - changed-files: - any-glob-to-any-file: [ .phpstan*, - phpstan*, .github/workflows/phpstan.yml ] 'phpunit': - changed-files: - any-glob-to-any-file: [ - phpunit*, + .phpunit*, tests/*, .github/workflows/phpunit.yml ] @@ -910,6 +916,6 @@ 'rector': - changed-files: - any-glob-to-any-file: [ - rector.php, + .rector.php, .github/workflows/rector.yml ] \ No newline at end of file diff --git a/.github/workflows/check-files.yml b/.github/workflows/check-files.yml index a4114fba292..7279dc632f7 100644 --- a/.github/workflows/check-files.yml +++ b/.github/workflows/check-files.yml @@ -27,6 +27,9 @@ on: php-cs-fixer: description: "Count changed PHP-CS-Fixer files" value: ${{ jobs.check.outputs.php-cs-fixer }} + phpmd: + description: "Count changed PHPMD files" + value: ${{ jobs.check.outputs.phpmd }} phpstan: description: "Count changed PHPStan files" value: ${{ jobs.check.outputs.phpstan }} @@ -52,6 +55,7 @@ jobs: workflow: ${{ steps.changes-workflow.outputs.workflow }} phpcs: ${{ steps.changes-phpcs.outputs.phpcs }} php-cs-fixer: ${{ steps.changes-php-cs-fixer.outputs.php-cs-fixer }} + phpmd: ${{ steps.changes-phpstan.outputs.phpmd }} phpstan: ${{ steps.changes-phpstan.outputs.phpstan }} phpunit-test: ${{ steps.changes-phpunit-test.outputs.phpunit-test }} phpunit: ${{ steps.changes-phpunit.outputs.phpunit }} @@ -87,8 +91,9 @@ jobs: .github/workflows/** **phpcs** **php-cs-fixer** + **phpmd** **phpstan** - rector.php + .rector.php tests/ phpunit* @@ -158,6 +163,14 @@ jobs: echo "$count PHP-CS-Fixer file(s) changed" echo "php-cs-fixer=$count" >> $GITHUB_OUTPUT + - name: Check if PHPMD files changed + id: changes-phpmd + if: steps.changed-files-specific.outputs.any_modified == 'true' + run: | + count="$(grep -oE "**phpmd**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)" + echo "$count PHPMD file(s) changed" + echo "phpmd=$count" >> $GITHUB_OUTPUT + - name: Check if PHPStan files changed id: changes-phpstan if: steps.changed-files-specific.outputs.any_modified == 'true' @@ -178,6 +191,6 @@ jobs: id: changes-phpunit if: steps.changed-files-specific.outputs.any_modified == 'true' run: | - count="$(grep -oE "phpunit*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)" + count="$(grep -oE "**phpunit**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)" echo "$count PHPUnit file(s) changed" echo "phpunit=$count" >> $GITHUB_OUTPUT diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 94c6db028d3..dbb1155d729 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -14,11 +14,11 @@ jobs: matrix: rules: - label: Default - path: .phpcs.xml.dist + path: .phpcs.dist.xml - label: Ecg - path: .phpcs.ecg.xml.dist + path: .phpcs.dist.ecg.xml - label: PhpCompatibility - path: .phpcs.php.xml.dist + path: .phpcs.dist.php.xml steps: - name: Setup PHP @@ -44,4 +44,4 @@ jobs: run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-* - name: PHPCodeSniffer - run: php vendor/bin/phpcs -s --report=full --standard=${{ matrix.rules.path }} + run: php vendor/bin/phpcs -s -p --report=full --standard=${{ matrix.rules.path }} diff --git a/.github/workflows/phpmd.yml b/.github/workflows/phpmd.yml new file mode 100644 index 00000000000..c9ad879aaec --- /dev/null +++ b/.github/workflows/phpmd.yml @@ -0,0 +1,32 @@ +name: PHPMD + +on: + workflow_call: + # Allow manually triggering the workflow. + workflow_dispatch: + +jobs: + phpcs: + name: Mess Detector + runs-on: [ubuntu-latest] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-* + + - name: PHPMD + run: php vendor/bin/phpmd app/code/core/Mage/ github .phpmd.dist.xml --baseline-file .phpmd.dist.baseline.xml diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index b78f2e23a48..43b4d571c02 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -37,7 +37,7 @@ jobs: run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-* - name: Restore result cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: .phpstan.cache key: "phpstan-result-cache-${{ github.run_id }}" @@ -48,7 +48,7 @@ jobs: run: XDEBUG_MODE=off php vendor/bin/phpstan.phar analyze - name: Save result cache - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 if: always() with: path: .phpstan.cache diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index d9142354e3b..04c6eaa23b3 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -87,7 +87,7 @@ jobs: --skip_url_validation 'yes' - name: Run phpUnit - run: php -f vendor/bin/phpunit + run: php vendor/bin/phpunit --configuration .phpunit.dist.xml - name: Publish Unit Test Results uses: EnricoMi/publish-unit-test-result-action@v2 diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 1bbf2ad35f5..032a17702a9 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -34,4 +34,4 @@ jobs: run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-* - name: Rector - run: php vendor/bin/rector process --dry-run + run: php vendor/bin/rector process --config .rector.php --dry-run diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a3b20bfb73..b2e5ff65970 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: php-versions: ['7.4'] steps: - name: Checkout repository - uses: actions/checkout@master + uses: actions/checkout@4 - name: Get composer cache directory id: composer-cache diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 94702280497..72b0121da95 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -11,11 +11,11 @@ on: - '**.js' - '**.xml' - '.php-cs-fixer.dist.php' - - '.phpcs.xml.dist' - - '.phpcs.ecg.xml.dist' - - '.phpcs.php.xml.dist' - - 'phpstan.dist.neon' - - 'phpstan.dist.baseline.neon' + - '.phpcs.dist.xml' + - '.phpcs.dist.ecg.xml' + - '.phpcs.dist.php.xml' + - '.phpstan.dist.neon' + - '.phpstan.dist.baseline.neon' pull_request: paths: @@ -27,11 +27,11 @@ on: - '**.js' - '**.xml' - '.php-cs-fixer.dist.php' - - '.phpcs.xml.dist' - - '.phpcs.ecg.xml.dist' - - '.phpcs.php.xml.dist' - - 'phpstan.dist.neon' - - 'phpstan.dist.baseline.neon' + - '.phpcs.dist.xml' + - '.phpcs.dist.ecg.xml' + - '.phpcs.dist.php.xml' + - '.phpstan.dist.neon' + - '.phpstan.dist.baseline.neon' jobs: debug: @@ -84,6 +84,16 @@ jobs: needs.check.outputs.workflow > 0 uses: ./.github/workflows/php-cs-fixer.yml + phpmd: + name: PHPMD + needs: [check, composer] + if: | + needs.check.outputs.php > 0 || + needs.check.outputs.phpmd > 0 || + needs.check.outputs.composer > 0 || + needs.check.outputs.workflow > 0 + uses: ./.github/workflows/phpmd.yml + phpstan: name: PHPStan needs: [check, composer] diff --git a/.gitignore b/.gitignore index f67b58eed2b..5c63f88e055 100644 --- a/.gitignore +++ b/.gitignore @@ -60,8 +60,15 @@ .php-cs-fixer* !.php-cs-fixer.dist.* +# PHPCS cache +.phpcs.result.cache .phpcs*.xml -!.phpcs*.xml.dist +!.phpcs.dist*.xml +!.phpcs.xml +phpcs.xml + +# PHPMD cache +.phpmd.result-cache.php # PhpStan .phpstan.cache @@ -75,7 +82,7 @@ tests/coverage tests/logging .phpunit.result.cache phpunit.xml -!phpunit.xml.dist +!.phpunit.dist.xml # build /build diff --git a/.phpcs.dist.ecg.xml b/.phpcs.dist.ecg.xml new file mode 100644 index 00000000000..36665bd7db4 --- /dev/null +++ b/.phpcs.dist.ecg.xml @@ -0,0 +1,146 @@ + + + api.php + cron.php + get.php + index.php + install.php + app/Mage.php + app/code/core/Mage/ + errors/ + lib/Mage/ + lib/Magento/ + lib/Varien/ + shell/ + + */core/Mage/*/data/* + */core/Mage/*/sql/* + + + + */core/Mage/Catalog/Model/Resource/Eav/Mysql4/**.php* + */core/Mage/Install/Block/Db/Type/Mysql4.php* + */core/Mage/Install/Model/Installer/Db/Mysql4.php* + + */core/Mage/*/Model/Mysql4/**.php* + + */core/Mage/*/Model/Resource/Helper/Mysql4.php* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.phpcs.php.xml.dist b/.phpcs.dist.php.xml similarity index 98% rename from .phpcs.php.xml.dist rename to .phpcs.dist.php.xml index fe91de479b7..13a31978800 100644 --- a/.phpcs.php.xml.dist +++ b/.phpcs.dist.php.xml @@ -1,5 +1,5 @@ - + api.php cron.php get.php diff --git a/.phpcs.xml.dist b/.phpcs.dist.xml similarity index 98% rename from .phpcs.xml.dist rename to .phpcs.dist.xml index 19a8ceb29dd..9442e31ca55 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.dist.xml @@ -1,5 +1,5 @@ - + api.php cron.php get.php @@ -13,6 +13,7 @@ lib/Varien/ shell/ tests/unit/ + diff --git a/.phpcs.ecg.xml.dist b/.phpcs.ecg.xml.dist deleted file mode 100644 index 531828f8c55..00000000000 --- a/.phpcs.ecg.xml.dist +++ /dev/null @@ -1,184 +0,0 @@ - - - api.php - cron.php - get.php - index.php - install.php - app/Mage.php - app/code/core/Mage/ - errors/ - lib/Mage/ - lib/Magento/ - lib/Varien/ - shell/ - - - - */core/Mage/Admin/Model/Acl/Role/Registry.php* - */core/Mage/Admin/Model/Resource/User.php* - */core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php* - */core/Mage/Adminhtml/Block/Report/Config/Form/Field/YtdStart.php* - */core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Items.php* - */core/Mage/Adminhtml/Block/Widget/Grid.php* - */core/Mage/Adminhtml/controllers/CustomerController.php* - */core/Mage/Adminhtml/controllers/IndexController.php* - */core/Mage/Adminhtml/controllers/NotificationController.php* - */core/Mage/Adminhtml/controllers/PollController.php* - */core/Mage/Adminhtml/controllers/RatingController.php* - */core/Mage/Adminhtml/controllers/TagController.php* - */core/Mage/Adminhtml/controllers/Catalog/ProductController.php* - */core/Mage/Adminhtml/controllers/Catalog/SearchController.php* - */core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php* - */core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php* - */core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php* - */core/Mage/Adminhtml/controllers/Promo/QuoteController.php* - */core/Mage/Adminhtml/controllers/Sales/OrderController.php* - */core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php* - */core/Mage/Adminhtml/controllers/Tax/RateController.php* - */core/Mage/Adminhtml/Model/Email/Template.php* - */core/Mage/Adminhtml/Model/Giftmessage/Save.php* - */core/Mage/Adminhtml/Model/Sales/Order/Create.php* - */core/Mage/Adminhtml/Model/System/Config/Backend/Category.php* - */core/Mage/Adminhtml/Model/System/Config/Backend/Locale.php* - */core/Mage/Adminhtml/Model/System/Config/Backend/Customer/Show/Customer.php* - */core/Mage/Api/Model/Acl/Role/Registry.php* - */core/Mage/Api/Model/Resource/User.php* - */core/Mage/Api2/Model/Observer.php* - */core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php* - */core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php* - */core/Mage/Authorizenet/Helper/Data.php* - */core/Mage/Backup/Model/Fs/Collection.php* - */core/Mage/Bundle/Model/Product/Type.php* - */core/Mage/Catalog/Model/Api2/Product/Website/Rest.php* - */core/Mage/Catalog/Model/Convert/Adapter/Product.php* - */core/Mage/Catalog/Model/Convert/Parser/Product.php* - */core/Mage/Catalog/Model/Product/Option.php* - */core/Mage/Catalog/Model/Product/Attribute/Backend/Price.php* - */core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php* - */core/Mage/Catalog/Model/Product/Option/Value.php* - */core/Mage/Catalog/Model/Product/Type/Configurable.php* - */core/Mage/Catalog/Model/Resource/Category/Flat.php* - */core/Mage/Catalog/Model/Resource/Category/Indexer/Product.php* - */core/Mage/Catalog/Model/Resource/Product.php* - */core/Mage/Catalog/Model/Resource/Product/Link.php* - */core/Mage/Catalog/Model/Resource/Product/Option.php* - */core/Mage/Catalog/Model/Resource/Product/Compare/Item.php* - */core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php* - */core/Mage/Catalog/Model/Resource/Product/Option/Value.php* - */core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute.php* - */core/Mage/CatalogIndex/Model/Indexer.php* - */core/Mage/CatalogInventory/Model/Observer.php* - */core/Mage/CatalogInventory/Model/Api2/Stock/Item/Rest.php* - */core/Mage/CatalogRule/Model/Observer.php* - */core/Mage/Cron/Model/Observer.php* - */core/Mage/Downloadable/Model/Product/Type.php* - */core/Mage/Downloadable/Model/Observer.php* - */core/Mage/Checkout/Model/Cart/Api.php* - */core/Mage/Checkout/Model/Type/Multishipping.php* - */core/Mage/Core/Model/Email/Queue.php* - */core/Mage/Core/Model/File/Storage.php* - */core/Mage/Core/Model/File/Storage/Directory/Database.php* - */core/Mage/Core/Model/Resource/Db/Collection/Abstract.php* - */core/Mage/Core/Model/Resource/Transaction.php* - */core/Mage/Core/Model/Resource/Translate/String.php* - */core/Mage/Core/Model/Session/Abstract.php* - */core/Mage/Core/Model/Session/Abstract/Varien.php* - */core/Mage/Customer/Model/Convert/Adapter/Customer.php* - */core/Mage/Customer/Model/Convert/Parser/Customer.php* - */core/Mage/Customer/Model/Resource/Customer.php* - */core/Mage/Customer/Model/Resource/Group.php* - */core/Mage/Dataflow/Model/Profile.php* - */core/Mage/Dataflow/Model/Convert/Mapper/Column.php* - */core/Mage/Dataflow/Model/Convert/Parser/Csv.php* - */core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php* - */core/Mage/Dataflow/Model/Session/Parser/Csv.php* - */core/Mage/Directory/Model/Currency/Import/Abstract.php* - */core/Mage/Downloadable/Model/Resource/Link.php* - */core/Mage/Eav/Model/Convert/Adapter/Entity.php* - */core/Mage/Eav/Model/Convert/Adapter/Grid.php* - */core/Mage/Eav/Model/Entity/Abstract.php* - */core/Mage/Eav/Model/Entity/Setup.php* - */core/Mage/Eav/Model/Entity/Attribute/Set.php* - */core/Mage/Eav/Model/Entity/Collection/Abstract.php* - */core/Mage/Eav/Model/Form/Type.php* - */core/Mage/Eav/Model/Resource/Entity/Attribute.php* - */core/Mage/Eav/Model/Resource/Entity/Attribute/Group.php* - */core/Mage/Eav/Model/Resource/Entity/Attribute/Set.php* - */core/Mage/GiftMessage/Model/Observer.php* - */core/Mage/ImportExport/Model/Export/Entity/Product.php* - */core/Mage/ImportExport/Model/Import/Entity/Product.php* - */core/Mage/ImportExport/Model/Import/Entity/Product/Type/Configurable.php* - */core/Mage/ImportExport/Model/Import/Entity/Product/Type/Grouped.php* - */core/Mage/ImportExport/Model/Import/Proxy/Product/Resource.php* - */core/Mage/Index/controllers/Adminhtml/ProcessController.php* - */core/Mage/Index/Model/Observer.php* - */core/Mage/Index/Model/Process.php* - */core/Mage/Index/Model/Resource/Event.php* - */core/Mage/Log/Model/Resource/Log.php* - */core/Mage/Newsletter/Model/Queue.php* - */core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php* - */core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php* - */core/Mage/Paypal/Model/Ipn.php* - */core/Mage/Paypal/Model/Report/Settlement.php* - */core/Mage/Poll/Model/Poll.php* - */core/Mage/Poll/Model/Resource/Poll.php* - */core/Mage/ProductAlert/Model/Observer.php* - */core/Mage/Reports/Model/Resource/Event.php* - */core/Mage/Reports/Model/Resource/Customer/Collection.php* - */core/Mage/Reports/Model/Resource/Product/Index/Abstract.php* - */core/Mage/Rating/Model/Resource/Rating/Option/Vote/Collection.php* - */core/Mage/Rating/Model/Resource/Rating/Option.php* - */core/Mage/Review/Model/Resource/Review/Collection.php* - */core/Mage/Review/Model/Resource/Review/Product/Collection.php* - */core/Mage/Sales/Model/Entity/Order/Attribute/Backend/Parent.php* - */core/Mage/Sales/Model/Entity/Order/Creditmemo/Attribute/Backend/Parent.php* - */core/Mage/Sales/Model/Entity/Order/Invoice/Attribute/Backend/Parent.php* - */core/Mage/Sales/Model/Entity/Order/Shipment/Attribute/Backend/Parent.php* - */core/Mage/Sales/Model/Entity/Quote.php* - */core/Mage/Sales/Model/Order/Api.php* - */core/Mage/Sales/Model/Order/Invoice.php* - */core/Mage/Sales/Model/Order/Payment.php* - */core/Mage/Sales/Model/Quote/Item.php* - */core/Mage/Sales/Model/Resource/Order/Attribute/Backend/Parent.php* - */core/Mage/Sales/Model/Resource/Order/Creditmemo/Attribute/Backend/Parent.php - */core/Mage/Sales/Model/Resource/Order/Invoice/Attribute/Backend/Parent.php* - */core/Mage/Sales/Model/Resource/Order/Shipment/Attribute/Backend/Parent.php* - */core/Mage/Sales/Model/Observer.php* - */core/Mage/Sales/Model/Order.php* - */core/Mage/Sales/Model/Order/Creditmemo.php* - */core/Mage/Sales/Model/Order/Shipment.php* - */core/Mage/SalesRule/Model/Observer.php* - */core/Mage/SalesRule/Model/Rule.php* - */core/Mage/SalesRule/Model/Coupon/Massgenerator.php* - */core/Mage/Tag/controllers/IndexController.php* - */core/Mage/Tag/Model/Api.php* - */core/Mage/Tag/Model/Resource/Product/Collection.php* - */core/Mage/Tax/Model/Observer.php* - */core/Mage/Tax/Model/Calculation/Rate.php* - */core/Mage/Tax/Model/Calculation/Rule.php* - */core/Mage/Tax/Model/Resource/Setup.php* - */core/Mage/Wishlist/controllers/IndexController.php* - */core/Mage/Wishlist/Model/Item.php* - */core/Mage/Wishlist/Model/Observer.php* - */lib/Mage/Backup/Filesystem/Rollback/Ftp.php* - */lib/Varien/Cache/Core.php* - */lib/Varien/Cache/Backend/Memcached.php* - */lib/Varien/Convert/Parser/Csv.php* - */lib/Varien/Object/Cache.php* - */shell/indexer.php* - */core/Mage/*/data/* - */core/Mage/*/sql/* - - - */core/Mage/Catalog/Model/Resource/Eav/Mysql4/**.php* - */core/Mage/Install/Block/Db/Type/Mysql4.php* - */core/Mage/Install/Model/Installer/Db/Mysql4.php* - - */core/Mage/*/Model/Mysql4/**.php* - - */core/Mage/*/Model/Resource/Helper/Mysql4.php* - - diff --git a/.phpcs.xml b/.phpcs.xml new file mode 100644 index 00000000000..ca319529bd5 --- /dev/null +++ b/.phpcs.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/.phpmd.dist.baseline.xml b/.phpmd.dist.baseline.xml new file mode 100644 index 00000000000..cb02e06e6bd --- /dev/null +++ b/.phpmd.dist.baseline.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.phpmd.dist.xml b/.phpmd.dist.xml index 8bbcf608db5..7647b102bbb 100644 --- a/.phpmd.dist.xml +++ b/.phpmd.dist.xml @@ -2,24 +2,27 @@ + xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 https://pmd.sf.net/ruleset_xml_schema.xsd" + xsi:noNamespaceSchemaLocation="https://pmd.sf.net/ruleset_xml_schema.xsd"> OpenMage ruleset - + + + + @@ -66,20 +69,26 @@ - - - - - + + + + + + + + + + diff --git a/.phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon index b73f68ac0bc..5c1c001b259 100644 --- a/.phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -675,21 +675,11 @@ parameters: count: 1 path: app/code/core/Mage/Adminhtml/Model/Giftmessage/Save.php - - - message: "#^Method Mage_Adminhtml_Model_Sales_Order_Create\\:\\:initFromOrderItem\\(\\) should return Mage_Sales_Model_Quote_Item\\|string but returns \\$this\\(Mage_Adminhtml_Model_Sales_Order_Create\\)\\.$#" - count: 2 - path: app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php - - message: "#^Parameter \\#1 \\$optionId of method Mage_Catalog_Model_Product\\:\\:getOptionById\\(\\) expects int, string given\\.$#" count: 1 path: app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php - - - message: "#^Parameter \\#2 \\$str of function explode expects string, array given\\.$#" - count: 1 - path: app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php - - message: "#^Variable \\$billingAddress might not be defined\\.$#" count: 2 @@ -1365,21 +1355,11 @@ parameters: count: 1 path: app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Selection.php - - - message: "#^Variable \\$_items might not be defined\\.$#" - count: 1 - path: app/code/core/Mage/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php - - message: "#^Parameter \\#4 \\$cond of method Mage_Eav_Model_Entity_Collection_Abstract\\:\\:joinTable\\(\\) expects array\\|null, string given\\.$#" count: 1 path: app/code/core/Mage/Bundle/Block/Catalog/Product/List/Partof.php - - - message: "#^Variable \\$_items might not be defined\\.$#" - count: 1 - path: app/code/core/Mage/Bundle/Block/Sales/Order/Items/Renderer.php - - message: "#^Call to an undefined method Mage_Catalog_Model_Product_Configuration_Item_Interface\\:\\:getQty\\(\\)\\.$#" count: 1 @@ -1505,11 +1485,6 @@ parameters: count: 1 path: app/code/core/Mage/Bundle/Model/Resource/Price/Index.php - - - message: "#^Variable \\$_items might not be defined\\.$#" - count: 1 - path: app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php - - message: "#^Parameter \\#1 \\$item of method Mage_Bundle_Model_Sales_Order_Pdf_Items_Abstract\\:\\:canShowPriceInfo\\(\\) expects Mage_Sales_Model_Order_Item, Mage_Sales_Model_Order_Invoice_Item given\\.$#" count: 1 @@ -1860,11 +1835,6 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Category/Api.php - - - message: "#^Parameter \\#1 \\$stack of function array_pop is passed by reference, so it expects variables only\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Category/Api.php - - message: "#^Method Mage_Eav_Model_Entity_Attribute_Source_Interface\\:\\:getAllOptions\\(\\) invoked with 1 parameter, 0 required\\.$#" count: 1 @@ -2060,11 +2030,6 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Product/Api/V2.php - - - message: "#^Parameter \\#2 \\$productData of method Mage_Catalog_Model_Product_Api_V2\\:\\:update\\(\\) expects array, stdClass given\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Product/Api/V2.php - - message: "#^Parameter \\#3 \\$attributes \\(stdClass\\) of method Mage_Catalog_Model_Product_Api_V2\\:\\:info\\(\\) should be compatible with parameter \\$attributes \\(array\\) of method Mage_Catalog_Model_Product_Api\\:\\:info\\(\\)$#" count: 1 @@ -2120,36 +2085,11 @@ parameters: count: 1 path: app/code/core/Mage/Catalog/Model/Product/Indexer/Eav.php - - - message: "#^Method Mage_Catalog_Model_Product_Option\\:\\:getValuesCollection\\(\\) should return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Option_Value_Collection but returns Mage_Catalog_Model_Resource_Product_Option_Value_Collection\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Product/Option.php - - - - message: "#^Method Mage_Catalog_Model_Product_Option\\:\\:groupFactory\\(\\) should return Mage_Catalog_Model_Product_Option_Type_Default but returns Mage_Core_Model_Abstract\\|false\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Product/Option.php - - message: "#^Parameter \\#1 \\$optionId of method Mage_Catalog_Model_Product\\:\\:getOptionById\\(\\) expects int, string given\\.$#" count: 1 path: app/code/core/Mage/Catalog/Model/Product/Option/Api.php - - - message: "#^Parameter \\#1 \\$option_id of method Mage_Catalog_Model_Product_Option\\:\\:deletePrices\\(\\) expects int, string given\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Product/Option/Api.php - - - - message: "#^Parameter \\#1 \\$option_id of method Mage_Catalog_Model_Product_Option\\:\\:deleteTitles\\(\\) expects int, string given\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Product/Option/Api.php - - - - message: "#^Parameter \\#1 \\$option_id of method Mage_Catalog_Model_Product_Option_Value\\:\\:deleteValue\\(\\) expects int, string given\\.$#" - count: 1 - path: app/code/core/Mage/Catalog/Model/Product/Option/Api.php - - message: "#^Parameter \\#1 \\$optionId of method Mage_Catalog_Model_Product\\:\\:getOptionById\\(\\) expects int, string given\\.$#" count: 1 @@ -3230,21 +3170,11 @@ parameters: count: 1 path: app/code/core/Mage/Core/Controller/Varien/Router/Admin.php - - - message: "#^Argument of an invalid type string supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: app/code/core/Mage/Core/Controller/Varien/Router/Standard.php - - message: "#^Negated boolean expression is always true\\.$#" count: 1 path: app/code/core/Mage/Core/Controller/Varien/Router/Standard.php - - - message: "#^Parameter \\#2 \\$modules of method Mage_Core_Controller_Varien_Router_Standard\\:\\:getModuleByName\\(\\) expects string, array given\\.$#" - count: 1 - path: app/code/core/Mage/Core/Controller/Varien/Router/Standard.php - - message: "#^Variable \\$action might not be defined\\.$#" count: 2 @@ -3400,16 +3330,6 @@ parameters: count: 1 path: app/code/core/Mage/Core/Model/Design/Fallback.php - - - message: "#^Binary operation \"\\.\" between non\\-falsy\\-string and array results in an error\\.$#" - count: 1 - path: app/code/core/Mage/Core/Model/Design/Package.php - - - - message: "#^Parameter \\#1 \\$file of method Mage_Core_Model_Design_Package\\:\\:_renderFilename\\(\\) expects array, string given\\.$#" - count: 2 - path: app/code/core/Mage/Core/Model/Design/Package.php - - message: "#^Property Mage_Core_Model_Design_Package\\:\\:\\$_store \\(int\\|Mage_Core_Model_Store\\|string\\) on left side of \\?\\? is not nullable\\.$#" count: 1 @@ -3545,11 +3465,6 @@ parameters: count: 1 path: app/code/core/Mage/Core/Model/Layout.php - - - message: "#^Method Mage_Core_Model_Layout_Update\\:\\:saveCache\\(\\) should return bool but returns Mage_Core_Model_App\\.$#" - count: 1 - path: app/code/core/Mage/Core/Model/Layout/Update.php - - message: "#^Parameter \\#3 \\$value of method Zend_Locale\\:\\:getTranslationList\\(\\) expects string\\|null, int given\\.$#" count: 1 @@ -4695,11 +4610,6 @@ parameters: count: 1 path: app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php - - - message: "#^Parameter \\#2 \\$elementId of method Mage_ImportExport_Block_Adminhtml_Import_Frame_Result\\:\\:addAction\\(\\) expects string, array\\ given\\.$#" - count: 2 - path: app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php - - message: "#^Parameter \\#3 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\\\|null given\\.$#" count: 1 @@ -5480,11 +5390,6 @@ parameters: count: 7 path: app/code/core/Mage/Reports/Model/Resource/Refunded/Collection.php - - - message: "#^Parameter \\#1 \\$select of method Mage_Reports_Model_Resource_Report_Abstract\\:\\:_makeConditionFromDateRangeSelect\\(\\) expects Varien_Db_Select, string\\|Zend_Db_Select given\\.$#" - count: 1 - path: app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php - - message: "#^Parameter \\#1 \\$datetime of method Mage_Reports_Model_Resource_Report_Collection\\:\\:timeShift\\(\\) expects string, int given\\.$#" count: 4 @@ -6220,11 +6125,6 @@ parameters: count: 2 path: app/code/core/Mage/SalesRule/Model/Validator.php - - - message: "#^Parameter \\#1 \\$product of method Mage_Tax_Helper_Data\\:\\:getPrice\\(\\) expects Mage_Catalog_Model_Product, Mage_Sales_Model_Quote_Item_Abstract given\\.$#" - count: 2 - path: app/code/core/Mage/SalesRule/Model/Validator.php - - message: "#^Parameter \\#2 \\$title of method Mage_Weee_Helper_Data\\:\\:setWeeeTaxesAppliedProperty\\(\\) expects string, null given\\.$#" count: 2 @@ -6280,11 +6180,6 @@ parameters: count: 1 path: app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php - - - message: "#^Parameter \\#1 \\$result of method Mage_Shipping_Model_Rate_Result\\:\\:append\\(\\) expects Mage_Shipping_Model_Rate_Result\\|Mage_Shipping_Model_Rate_Result_Abstract, Mage_Core_Model_Abstract given\\.$#" - count: 3 - path: app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php - - message: "#^Parameter \\#1 \\$hash of method Mage_Shipping_Helper_Data\\:\\:decodeTrackingHash\\(\\) expects string, array given\\.$#" count: 1 @@ -6390,11 +6285,6 @@ parameters: count: 1 path: app/code/core/Mage/Tax/Helper/Data.php - - - message: "#^Parameter \\#1 \\$product of method Mage_Tax_Helper_Data\\:\\:getPrice\\(\\) expects Mage_Catalog_Model_Product, Varien_Object given\\.$#" - count: 1 - path: app/code/core/Mage/Tax/Helper/Data.php - - message: "#^Parameter \\#1 \\$shippingAddress of method Mage_Tax_Model_Calculation\\:\\:getRateRequest\\(\\) expects Mage_Sales_Model_Quote_Address\\|false\\|null, Mage_Customer_Model_Address\\|null given\\.$#" count: 2 @@ -6550,31 +6440,11 @@ parameters: count: 2 path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php - - - message: "#^Method Mage_Usa_Model_Shipping_Carrier_Dhl\\:\\:_doRequest\\(\\) should return Mage_Shipping_Model_Rate_Result\\|Varien_Object but empty return statement found\\.$#" - count: 1 - path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php - - - - message: "#^Method Mage_Usa_Model_Shipping_Carrier_Dhl\\:\\:_getQuotes\\(\\) should return Mage_Shipping_Model_Rate_Result but returns Varien_Object\\.$#" - count: 1 - path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php - - message: "#^Method Mage_Usa_Model_Shipping_Carrier_Dhl\\:\\:_mapRequestToShipment\\(\\) should return null but return statement is missing\\.$#" count: 1 path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php - - - message: "#^Method Mage_Usa_Model_Shipping_Carrier_Dhl\\:\\:_parseXmlTrackingResponse\\(\\) should return null but return statement is missing\\.$#" - count: 1 - path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php - - - - message: "#^Method Mage_Usa_Model_Shipping_Carrier_Dhl\\:\\:setTrackingReqeust\\(\\) should return null but return statement is missing\\.$#" - count: 1 - path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php - - message: "#^Parameter \\#3 \\$value of function curl_setopt expects bool, int given\\.$#" count: 2 @@ -6735,11 +6605,6 @@ parameters: count: 2 path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php - - - message: "#^Method Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page\\:\\:drawText\\(\\) should return \\$this\\(Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page\\) but returns Zend_Pdf_Canvas_Interface\\.$#" - count: 1 - path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/Page.php - - message: "#^Call to an undefined method Zend_Pdf_Page\\:\\:drawLines\\(\\)\\.$#" count: 5 @@ -7065,21 +6930,11 @@ parameters: count: 1 path: app/code/core/Mage/Wishlist/Helper/Data.php - - - message: "#^Parameter \\#1 \\$item of method Mage_Wishlist_Model_Resource_Item_Option_Collection\\:\\:addItemFilter\\(\\) expects array\\|int, \\$this\\(Mage_Wishlist_Model_Item\\) given\\.$#" - count: 1 - path: app/code/core/Mage/Wishlist/Model/Item.php - - message: "#^Parameter \\#1 \\$message of class Mage_Core_Exception constructor expects string, null given\\.$#" count: 1 path: app/code/core/Mage/Wishlist/Model/Item.php - - - message: "#^Parameter \\#1 \\$option of method Mage_Wishlist_Model_Item\\:\\:addOption\\(\\) expects Mage_Wishlist_Model_Item_Option, array\\ given\\.$#" - count: 1 - path: app/code/core/Mage/Wishlist/Model/Item.php - - message: "#^Parameter \\#1 \\$collection of method Mage_Adminhtml_Helper_Sales\\:\\:applySalableProductTypesFilter\\(\\) expects Mage_Core_Model_Resource_Db_Collection_Abstract, Mage_Catalog_Model_Resource_Product_Collection given\\.$#" count: 1 diff --git a/phpunit.xml.dist b/.phpunit.dist.xml similarity index 100% rename from phpunit.xml.dist rename to .phpunit.dist.xml diff --git a/rector.php b/.rector.php similarity index 100% rename from rector.php rename to .rector.php diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php b/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php index 4a44102b852..5a462ab5e13 100644 --- a/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php +++ b/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -27,11 +27,11 @@ public function __construct() $resources = Mage::getModel('api/roles')->getResourcesList(); - $rules_set = Mage::getResourceModel('api/rules_collection')->getByRoles($rid)->load(); + $rules = Mage::getResourceModel('api/rules_collection')->getByRoles($rid)->load(); $selrids = []; - foreach ($rules_set->getItems() as $item) { + foreach ($rules->getItems() as $item) { if (array_key_exists(strtolower($item->getResource_id()), $resources) && $item->getApiPermission() == 'allow' ) { diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Tab/Userroles.php b/app/code/core/Mage/Adminhtml/Block/Api/Tab/Userroles.php index 378be70a9e6..b61c97a914f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Api/Tab/Userroles.php +++ b/app/code/core/Mage/Adminhtml/Block/Api/Tab/Userroles.php @@ -29,13 +29,13 @@ public function __construct() ->getCollection() ->load(); - $user_roles = Mage::getModel('api/roles') + $userRoles = Mage::getModel('api/roles') ->getUsersCollection() ->setUserFilter($uid) ->load(); $this->setTemplate('api/userroles.phtml') ->assign('roles', $roles) - ->assign('user_roles', $user_roles); + ->assign('user_roles', $userRoles); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Cache/Grid.php b/app/code/core/Mage/Adminhtml/Block/Cache/Grid.php index bd2b35b8235..1bf9eed2dc6 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cache/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Cache/Grid.php @@ -102,7 +102,6 @@ protected function _prepareColumns() * * @return string */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed public function decorateStatus($value, $row, $column, $isExport) { $class = ''; @@ -123,7 +122,6 @@ public function decorateStatus($value, $row, $column, $isExport) * * @return string */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function getRowUrl($row) { return ''; diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php index 50b835e8213..7e3cd91a019 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -235,37 +235,37 @@ public function getOptionValues() if ($option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) { $i = 0; $itemCount = 0; - foreach ($option->getValues() as $_value) { - /** @var Mage_Catalog_Model_Product_Option_Value $_value */ + foreach ($option->getValues() as $optionValue) { + /** @var Mage_Catalog_Model_Product_Option_Value $optionValue */ $value['optionValues'][$i] = [ - 'item_count' => max($itemCount, $_value->getOptionTypeId()), - 'option_id' => $_value->getOptionId(), - 'option_type_id' => $_value->getOptionTypeId(), - 'title' => $this->escapeHtml($_value->getTitle()), + 'item_count' => max($itemCount, $optionValue->getOptionTypeId()), + 'option_id' => $optionValue->getOptionId(), + 'option_type_id' => $optionValue->getOptionTypeId(), + 'title' => $this->escapeHtml($optionValue->getTitle()), 'price' => ($showPrice) - ? $this->getPriceValue($_value->getPrice(), $_value->getPriceType()) : '', - 'price_type' => ($showPrice) ? $_value->getPriceType() : 0, - 'sku' => $this->escapeHtml($_value->getSku()), - 'sort_order' => $_value->getSortOrder(), + ? $this->getPriceValue($optionValue->getPrice(), $optionValue->getPriceType()) : '', + 'price_type' => ($showPrice) ? $optionValue->getPriceType() : 0, + 'sku' => $this->escapeHtml($optionValue->getSku()), + 'sort_order' => $optionValue->getSortOrder(), ]; if ($this->getProduct()->getStoreId() != '0') { $value['optionValues'][$i]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml( - $_value->getOptionId(), + $optionValue->getOptionId(), 'title', - is_null($_value->getStoreTitle()), - $_value->getOptionTypeId() + is_null($optionValue->getStoreTitle()), + $optionValue->getOptionTypeId() ); - $value['optionValues'][$i]['scopeTitleDisabled'] = is_null($_value->getStoreTitle()) + $value['optionValues'][$i]['scopeTitleDisabled'] = is_null($optionValue->getStoreTitle()) ? 'disabled' : null; if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) { $value['optionValues'][$i]['checkboxScopePrice'] = $this->getCheckboxScopeHtml( - $_value->getOptionId(), + $optionValue->getOptionId(), 'price', - is_null($_value->getstorePrice()), - $_value->getOptionTypeId() + is_null($optionValue->getstorePrice()), + $optionValue->getOptionTypeId() ); - $value['optionValues'][$i]['scopePriceDisabled'] = is_null($_value->getStorePrice()) + $value['optionValues'][$i]['scopePriceDisabled'] = is_null($optionValue->getStorePrice()) ? 'disabled' : null; } } @@ -305,10 +305,10 @@ public function getOptionValues() * @param string $id * @param string $name * @param bool $checked - * @param string $select_id + * @param string $selectId * @return string */ - public function getCheckboxScopeHtml($id, $name, $checked = true, $select_id = '-1') + public function getCheckboxScopeHtml($id, $name, $checked = true, $selectId = '-1') { $checkedHtml = ''; if ($checked) { @@ -316,9 +316,9 @@ public function getCheckboxScopeHtml($id, $name, $checked = true, $select_id = ' } $selectNameHtml = ''; $selectIdHtml = ''; - if ($select_id != '-1') { - $selectNameHtml = '[values][' . $select_id . ']'; - $selectIdHtml = 'select_' . $select_id . '_'; + if ($selectId != '-1') { + $selectNameHtml = '[values][' . $selectId . ']'; + $selectIdHtml = 'select_' . $selectId . '_'; } $checkbox = 'getDataObject()->getMediaGallery(); - if (!count($media_gallery['images'])) { + $mediaGallery = $this->getDataObject()->getMediaGallery(); + if (!count($mediaGallery['images'])) { return true; } - return $media_gallery['images'][0]["{$attributeCode}_use_default"]; + return $mediaGallery['images'][0]["{$attributeCode}_use_default"]; } $defaultValue = $this->getDataObject()->getAttributeDefaultValue($attributeCode); 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 decfbf46129..444b4f409d5 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 @@ -246,16 +246,16 @@ function(v, elem){ $prefix = $form->getHtmlIdPrefix(); if ($sendEmail) { - $_disableStoreField = ''; + $disableStoreField = ''; if (!$isSingleMode) { - $_disableStoreField = "$('{$prefix}sendemail_store_id').disabled=(''==this.value || '0'==this.value);"; + $disableStoreField = "$('{$prefix}sendemail_store_id').disabled=(''==this.value || '0'==this.value);"; } $sendEmail->setAfterElementHtml( ''; } $selectHtml .= ''; diff --git a/app/code/core/Mage/Catalog/Helper/Product/Configuration.php b/app/code/core/Mage/Catalog/Helper/Product/Configuration.php index 8367dd73092..9f950dbe0da 100644 --- a/app/code/core/Mage/Catalog/Helper/Product/Configuration.php +++ b/app/code/core/Mage/Catalog/Helper/Product/Configuration.php @@ -221,19 +221,19 @@ public function getFormattedOptionValue($optionValue, $params = null) // Truncate standard view $result = []; if (is_array($optionValue)) { - $_truncatedValue = implode("\n", $optionValue); - $_truncatedValue = nl2br($_truncatedValue); - return ['value' => $_truncatedValue]; + $truncatedValue = implode("\n", $optionValue); + $truncatedValue = nl2br($truncatedValue); + return ['value' => $truncatedValue]; } else { if ($maxLength) { - $_truncatedValue = Mage::helper('core/string')->truncate($optionValue, $maxLength, ''); + $truncatedValue = Mage::helper('core/string')->truncate($optionValue, $maxLength, ''); } else { - $_truncatedValue = $optionValue; + $truncatedValue = $optionValue; } - $_truncatedValue = nl2br($_truncatedValue); + $truncatedValue = nl2br($truncatedValue); } - $result = ['value' => $_truncatedValue]; + $result = ['value' => $truncatedValue]; if ($maxLength && (Mage::helper('core/string')->strlen($optionValue) > $maxLength)) { $result['value'] = $result['value'] . $cutReplacer; diff --git a/app/code/core/Mage/Catalog/Helper/Product/View.php b/app/code/core/Mage/Catalog/Helper/Product/View.php index 9fdf9b0e4ce..9f6bd9513cc 100644 --- a/app/code/core/Mage/Catalog/Helper/Product/View.php +++ b/app/code/core/Mage/Catalog/Helper/Product/View.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Catalog * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -18,6 +18,7 @@ * * @category Mage * @package Mage_Catalog + * @SuppressWarnings(PHPMD.CamelCasePropertyName) */ class Mage_Catalog_Helper_Product_View extends Mage_Core_Helper_Abstract { diff --git a/app/code/core/Mage/Catalog/Model/Category/Api.php b/app/code/core/Mage/Catalog/Model/Category/Api.php index 5d24aa77acb..c44f97671b0 100644 --- a/app/code/core/Mage/Catalog/Model/Category/Api.php +++ b/app/code/core/Mage/Catalog/Model/Category/Api.php @@ -228,13 +228,13 @@ public function info($categoryId, $store = null, $attributes = null) */ public function create($parentId, $categoryData, $store = null) { - $parent_category = $this->_initCategory($parentId, $store); + $parentCategory = $this->_initCategory($parentId, $store); /** @var Mage_Catalog_Model_Category $category */ $category = Mage::getModel('catalog/category') ->setStoreId($this->_getStoreId($store)); - $category->addData(['path' => implode('/', $parent_category->getPathIds())]); + $category->addData(['path' => implode('/', $parentCategory->getPathIds())]); $category->setAttributeSetId($category->getDefaultAttributeSetId()); $useConfig = []; @@ -258,7 +258,7 @@ public function create($parentId, $categoryData, $store = null) } } - $category->setParentId($parent_category->getId()); + $category->setParentId($parentCategory->getId()); /** * Proceed with $useConfig set into category model for processing through validation @@ -345,15 +345,15 @@ public function update($categoryId, $categoryData, $store = null) public function move($categoryId, $parentId, $afterId = null) { $category = $this->_initCategory($categoryId); - $parent_category = $this->_initCategory($parentId); + $parentCategory = $this->_initCategory($parentId); // if $afterId is null - move category to the down - if ($afterId === null && $parent_category->hasChildren()) { - $parentChildren = $parent_category->getChildren(); - $afterId = array_pop(explode(',', $parentChildren)); + if ($afterId === null && $parentCategory->hasChildren()) { + $parentChildren = explode(',', $parentCategory->getChildren()); + $afterId = array_pop($parentChildren); } - if (str_starts_with($parent_category->getPath(), $category->getPath())) { + if (str_starts_with($parentCategory->getPath(), $category->getPath())) { $this->_fault('not_moved', 'Operation do not allow to move a parent category to any of children category'); } diff --git a/app/code/core/Mage/Catalog/Model/Category/Api/V2.php b/app/code/core/Mage/Catalog/Model/Category/Api/V2.php index af68bdf23f4..aafabd10eb5 100644 --- a/app/code/core/Mage/Catalog/Model/Category/Api/V2.php +++ b/app/code/core/Mage/Catalog/Model/Category/Api/V2.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Catalog * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -65,13 +65,13 @@ public function info($categoryId, $store = null, $attributes = null) */ public function create($parentId, $categoryData, $store = null) { - $parent_category = $this->_initCategory($parentId, $store); + $parentCategory = $this->_initCategory($parentId, $store); /** @var Mage_Catalog_Model_Category $category */ $category = Mage::getModel('catalog/category') ->setStoreId($this->_getStoreId($store)); - $category->addData(['path' => implode('/', $parent_category->getPathIds())]); + $category->addData(['path' => implode('/', $parentCategory->getPathIds())]); $category ->setAttributeSetId($category->getDefaultAttributeSetId()); @@ -86,7 +86,7 @@ public function create($parentId, $categoryData, $store = null) ); } } - $category->setParentId($parent_category->getId()); + $category->setParentId($parentCategory->getId()); try { $validate = $category->validate(); if ($validate !== true) { diff --git a/app/code/core/Mage/Catalog/Model/Category/Attribute/Backend/Image.php b/app/code/core/Mage/Catalog/Model/Category/Attribute/Backend/Image.php index 3e449fc9d25..a44b75dfc6d 100644 --- a/app/code/core/Mage/Catalog/Model/Category/Attribute/Backend/Image.php +++ b/app/code/core/Mage/Catalog/Model/Category/Attribute/Backend/Image.php @@ -30,6 +30,7 @@ public function getAllowedExtensions(): array * Save uploaded file and set its name to category attribute * @param Varien_Object $object * @return $this + * @SuppressWarnings(PHPMD.Superglobals) */ public function afterSave($object) { diff --git a/app/code/core/Mage/Catalog/Model/Product.php b/app/code/core/Mage/Catalog/Model/Product.php index 88f7d2d64f6..cf678f8bd47 100644 --- a/app/code/core/Mage/Catalog/Model/Product.php +++ b/app/code/core/Mage/Catalog/Model/Product.php @@ -662,7 +662,6 @@ public function getStoreIds() * @param bool $skipSuper Not used * @return array */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed public function getAttributes($groupId = null, $skipSuper = false) { /** @var Mage_Catalog_Model_Resource_Eav_Attribute[] $productAttributes */ diff --git a/app/code/core/Mage/Catalog/Model/Product/Api/V2.php b/app/code/core/Mage/Catalog/Model/Product/Api/V2.php index f57b63aebd5..96981e3c5d4 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Api/V2.php +++ b/app/code/core/Mage/Catalog/Model/Product/Api/V2.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Catalog * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -61,9 +61,9 @@ public function info($productId, $store = null, $attributes = null, $identifierT $_additionalAttributeCodes = []; if (!empty($attributes->additional_attributes)) { - foreach ($attributes->additional_attributes as $k => $_attributeCode) { - $allAttributes[] = $_attributeCode; - $_additionalAttributeCodes[] = $_attributeCode; + foreach ($attributes->additional_attributes as $attributeCode) { + $allAttributes[] = $attributeCode; + $_additionalAttributeCodes[] = $attributeCode; } } @@ -90,7 +90,7 @@ public function info($productId, $store = null, $attributes = null, $identifierT * @param string $type * @param int $set * @param string $sku - * @param array $productData + * @param array|stdClass $productData * @param string $store * @return int */ @@ -112,8 +112,8 @@ public function create($type, $set, $sku, $productData, $store = null) if (!property_exists($productData, 'stock_data')) { //Set default stock_data if not exist in product data - $_stockData = ['use_config_manage_stock' => 0]; - $product->setStockData($_stockData); + $stockData = ['use_config_manage_stock' => 0]; + $product->setStockData($stockData); } foreach ($product->getMediaAttributes() as $mediaAttribute) { @@ -151,7 +151,7 @@ public function create($type, $set, $sku, $productData, $store = null) * Update product data * * @param int|string $productId - * @param array $productData + * @param array|stdClass $productData * @param string|int $store * @param string|null $identifierType * @return bool @@ -227,7 +227,7 @@ public function multiUpdate($productIds, $productData, $store = null, $identifie * Set additional data before product saved * * @param Mage_Catalog_Model_Product $product - * @param array $productData + * @param array|stdClass $productData * @throws Mage_Api_Exception * @throws Mage_Core_Model_Store_Exception */ @@ -243,34 +243,35 @@ protected function _prepareDataForSave($product, $productData) if (property_exists($productData, 'additional_attributes')) { if (property_exists($productData->additional_attributes, 'single_data')) { foreach ($productData->additional_attributes->single_data as $_attribute) { - $_attrCode = $_attribute->key; - $productData->$_attrCode = $_attribute->value; + $attributeCode = $_attribute->key; + $productData->$attributeCode = $_attribute->value; } } if (property_exists($productData->additional_attributes, 'multi_data')) { foreach ($productData->additional_attributes->multi_data as $_attribute) { - $_attrCode = $_attribute->key; - $productData->$_attrCode = $_attribute->value; + $attributeCode = $_attribute->key; + $productData->$attributeCode = $_attribute->value; } } unset($productData->additional_attributes); } + // phpcs:ignore: Ecg.Performance.Loop.DataLoad foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) { - $_attrCode = $attribute->getAttributeCode(); + $attributeCode = $attribute->getAttributeCode(); //Unset data if object attribute has no value in current store if (Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID !== (int) $product->getStoreId() - && !$product->getExistsStoreValueFlag($_attrCode) + && !$product->getExistsStoreValueFlag($attributeCode) && !$attribute->isScopeGlobal() ) { - $product->setData($_attrCode, false); + $product->setData($attributeCode, false); } - if ($this->_isAllowedAttribute($attribute) && (isset($productData->$_attrCode))) { + if ($this->_isAllowedAttribute($attribute) && (isset($productData->$attributeCode))) { $product->setData( - $_attrCode, - $productData->$_attrCode + $attributeCode, + $productData->$attributeCode ); } } diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php index 05f90323f3f..ff0e102b2d0 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Catalog * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -259,9 +259,9 @@ public function info($attribute) 'label' => $model->getFrontendLabel() ] ]; - foreach ($model->getStoreLabels() as $store_id => $label) { + foreach ($model->getStoreLabels() as $storeId => $label) { $frontendLabels[] = [ - 'store_id' => $store_id, + 'store_id' => $storeId, 'label' => $label ]; } diff --git a/app/code/core/Mage/Catalog/Model/Product/Option.php b/app/code/core/Mage/Catalog/Model/Product/Option.php index f8a3743853a..6cc9acde54c 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Option.php +++ b/app/code/core/Mage/Catalog/Model/Product/Option.php @@ -34,11 +34,11 @@ * @method $this setIsRequire(int $value) * @method int getMaxCharacters() * @method $this setMaxCharacters(int $value) - * @method int getOptionId() - * @method $this setOptionId(int $value) + * @method int|null getOptionId() + * @method $this setOptionId(int|null $value) * @method string getPriceType() - * @method int getProductId() - * @method $this setProductId(int $value) + * @method string|null getProductId() + * @method $this setProductId(string|null $value) * @method string getSku() * @method $this setSku(string $value) * @method int getSortOrder() @@ -303,7 +303,9 @@ public function groupFactory($type) { $group = $this->getGroupByType($type); if (!empty($group)) { - return Mage::getModel('catalog/product_option_type_' . $group); + /** @var Mage_Catalog_Model_Product_Option_Type_Default $model */ + $model = Mage::getModel('catalog/product_option_type_' . $group); + return $model; } Mage::throwException(Mage::helper('catalog')->__('Wrong option type to get group instance.')); } @@ -332,6 +334,7 @@ public function saveOptions() $this->getValueInstance()->deleteValue($this->getId()); $this->deletePrices($this->getId()); $this->deleteTitles($this->getId()); + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $this->delete(); } } else { @@ -371,6 +374,7 @@ public function saveOptions() } } } + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $this->save(); } }//eof foreach() @@ -418,24 +422,24 @@ public function getPrice($flag = false) /** * Delete prices of option * - * @param int $option_id + * @param int|string $optionId * @return $this */ - public function deletePrices($option_id) + public function deletePrices($optionId) { - $this->getResource()->deletePrices($option_id); + $this->getResource()->deletePrices($optionId); return $this; } /** * Delete titles of option * - * @param int $option_id + * @param int|string $optionId * @return $this */ - public function deleteTitles($option_id) + public function deleteTitles($optionId) { - $this->getResource()->deleteTitles($option_id); + $this->getResource()->deleteTitles($optionId); return $this; } @@ -464,7 +468,7 @@ public function getProductOptionCollection(Mage_Catalog_Model_Product $product) /** * Get collection of values for current option * - * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Option_Value_Collection + * @return Mage_Catalog_Model_Resource_Product_Option_Value_Collection */ public function getValuesCollection() { @@ -476,13 +480,13 @@ public function getValuesCollection() * Get collection of values by given option ids * * @param array $optionIds - * @param int $store_id + * @param int $storeId * @return Mage_Catalog_Model_Resource_Product_Option_Value_Collection */ - public function getOptionValuesByOptionId($optionIds, $store_id) + public function getOptionValuesByOptionId($optionIds, $storeId) { return Mage::getModel('catalog/product_option_value') - ->getValuesByOption($optionIds, $this->getId(), $store_id); + ->getValuesByOption($optionIds, $this->getId(), $storeId); } /** @@ -495,11 +499,11 @@ public function prepareOptionForDuplicate() $this->setProductId(null); $this->setOptionId(null); $newOption = $this->__toArray(); - $_values = $this->getValues(); - if ($_values) { + $values = $this->getValues(); + if ($values) { $newValuesArray = []; - foreach ($_values as $_value) { - $newValuesArray[] = $_value->prepareValueForDuplicate(); + foreach ($values as $value) { + $newValuesArray[] = $value->prepareValueForDuplicate(); } $newOption['values'] = $newValuesArray; } diff --git a/app/code/core/Mage/Catalog/Model/Product/Option/Type/Default.php b/app/code/core/Mage/Catalog/Model/Product/Option/Type/Default.php index 23156e7cccf..101b3ce9d86 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Option/Type/Default.php +++ b/app/code/core/Mage/Catalog/Model/Product/Option/Type/Default.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Catalog * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -357,16 +357,16 @@ public function getOptionSku($optionValue, $skuDelimiter) public function getProductOptions() { if (!isset($this->_productOptions[$this->getProduct()->getId()])) { - foreach ($this->getProduct()->getOptions() as $_option) { - $this->_productOptions[$this->getProduct()->getId()][$_option->getTitle()] = ['option_id' => $_option->getId()]; - if ($_option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) { + foreach ($this->getProduct()->getOptions() as $option) { + $this->_productOptions[$this->getProduct()->getId()][$option->getTitle()] = ['option_id' => $option->getId()]; + if ($option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) { $optionValues = []; - foreach ($_option->getValues() as $_value) { - $optionValues[$_value->getTitle()] = $_value->getId(); + foreach ($option->getValues() as $value) { + $optionValues[$value->getTitle()] = $value->getId(); } - $this->_productOptions[$this->getProduct()->getId()][$_option->getTitle()]['values'] = $optionValues; + $this->_productOptions[$this->getProduct()->getId()][$option->getTitle()]['values'] = $optionValues; } else { - $this->_productOptions[$this->getProduct()->getId()][$_option->getTitle()]['values'] = []; + $this->_productOptions[$this->getProduct()->getId()][$option->getTitle()]['values'] = []; } } } diff --git a/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php b/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php index f093f091a8f..f874be327e6 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php +++ b/app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php @@ -153,6 +153,7 @@ public function validateUserValue($values) * * @return $this * @throws Mage_Core_Exception|Zend_File_Transfer_Exception + * @SuppressWarnings(PHPMD.Superglobals) */ protected function _validateUploadedFile() { @@ -792,14 +793,14 @@ protected function _getUploadMaxFilesize() /** * Return php.ini setting value in bytes * - * @param string $ini_key php.ini Var name + * @param string $option php.ini Var name * @return int Setting value * * @SuppressWarnings(PHPMD.ErrorControlOperator) */ - protected function _getBytesIniValue($ini_key) + protected function _getBytesIniValue($option) { - $_bytes = @ini_get($ini_key); + $_bytes = @ini_get($option); return ini_parse_quantity($_bytes); } diff --git a/app/code/core/Mage/Catalog/Model/Product/Option/Type/Select.php b/app/code/core/Mage/Catalog/Model/Product/Option/Type/Select.php index 03a574ef942..0cfed705890 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Option/Type/Select.php +++ b/app/code/core/Mage/Catalog/Model/Product/Option/Type/Select.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Catalog * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -113,8 +113,8 @@ public function getEditableOptionValue($optionValue) $option = $this->getOption(); $result = ''; if (!$this->_isSingleSelection()) { - foreach (explode(',', $optionValue) as $_value) { - if ($_result = $option->getValueById($_value)) { + foreach (explode(',', $optionValue) as $value) { + if ($_result = $option->getValueById($value)) { $result .= $_result->getTitle() . ', '; } else { if ($this->getListener()) { @@ -159,10 +159,10 @@ public function parseOptionValue($optionValue, $productOptionValues) { $_values = []; if (!$this->_isSingleSelection()) { - foreach (explode(',', $optionValue) as $_value) { - $_value = trim($_value); - if (array_key_exists($_value, $productOptionValues)) { - $_values[] = $productOptionValues[$_value]; + foreach (explode(',', $optionValue) as $value) { + $value = trim($value); + if (array_key_exists($value, $productOptionValues)) { + $_values[] = $productOptionValues[$value]; } } } elseif ($this->_isSingleSelection() && array_key_exists($optionValue, $productOptionValues)) { diff --git a/app/code/core/Mage/Catalog/Model/Product/Option/Value.php b/app/code/core/Mage/Catalog/Model/Product/Option/Value.php index 207b1e8866c..de90edc2bbd 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Option/Value.php +++ b/app/code/core/Mage/Catalog/Model/Product/Option/Value.php @@ -22,10 +22,10 @@ * @method Mage_Catalog_Model_Resource_Product_Option_Value_Collection getCollection() * @method Mage_Catalog_Model_Resource_Product_Option_Value _getResource() * @method Mage_Catalog_Model_Resource_Product_Option_Value getResource() - * @method int getOptionId() - * @method $this setOptionId(int $value) - * @method int getOptionTypeId() - * @method $this setOptionTypeId(int $value) + * @method int|null getOptionId() + * @method $this setOptionId(int|null $value) + * @method int|null getOptionTypeId() + * @method $this setOptionTypeId(int|null $value) * @method string getPriceType() * @method string getSku() * @method $this setSku(string $value) @@ -152,9 +152,11 @@ public function saveValues() if ($this->getData('is_delete') == '1') { if ($this->getId()) { $this->deleteValues($this->getId()); + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $this->delete(); } } else { + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $this->save(); } }//eof foreach() @@ -189,34 +191,34 @@ public function getValuesCollection(Mage_Catalog_Model_Product_Option $option) /** * @param array $optionIds - * @param int $option_id - * @param int $store_id + * @param int $optionId + * @param int $storeId * @return Mage_Catalog_Model_Resource_Product_Option_Value_Collection */ - public function getValuesByOption($optionIds, $option_id, $store_id) + public function getValuesByOption($optionIds, $optionId, $storeId) { return Mage::getResourceModel('catalog/product_option_value_collection') - ->addFieldToFilter('option_id', $option_id) - ->getValuesByOption($optionIds, $store_id); + ->addFieldToFilter('option_id', $optionId) + ->getValuesByOption($optionIds, $storeId); } /** - * @param int $option_id + * @param int|string $optionId * @return $this */ - public function deleteValue($option_id) + public function deleteValue($optionId) { - $this->getResource()->deleteValue($option_id); + $this->getResource()->deleteValue($optionId); return $this; } /** - * @param int $option_type_id + * @param int $optionTypeId * @return $this */ - public function deleteValues($option_type_id) + public function deleteValues($optionTypeId) { - $this->getResource()->deleteValues($option_type_id); + $this->getResource()->deleteValues($optionTypeId); return $this; } diff --git a/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php b/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php index 05e68872e2b..5c0d11fe6d4 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php +++ b/app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php @@ -236,7 +236,7 @@ public function getEditableAttributes($product = null) $editableAttributes = []; foreach ($this->getSetAttributes($product) as $attributeCode => $attribute) { if (!is_array($attribute->getApplyTo()) - || count($attribute->getApplyTo()) == 0 + || count($attribute->getApplyTo()) == 0 || in_array($this->getProduct($product)->getTypeId(), $attribute->getApplyTo()) ) { $editableAttributes[$attributeCode] = $attribute; @@ -268,7 +268,7 @@ public function getAttributeById($attributeId, $product = null) * Check is virtual product * * @param Mage_Catalog_Model_Product $product - * @return bool + * @return false */ public function isVirtual($product = null) { @@ -509,10 +509,10 @@ protected function _prepareOptions(Varien_Object $buyRequest, $product, $process { $transport = new stdClass(); $transport->options = []; - foreach ($this->getProduct($product)->getOptions() as $_option) { - /** @var Mage_Catalog_Model_Product_Option $_option */ - $group = $_option->groupFactory($_option->getType()) - ->setOption($_option) + foreach ($this->getProduct($product)->getOptions() as $option) { + /** @var Mage_Catalog_Model_Product_Option $option */ + $group = $option->groupFactory($option->getType()) + ->setOption($option) ->setProduct($this->getProduct($product)) ->setRequest($buyRequest) ->setProcessMode($processMode) @@ -520,7 +520,7 @@ protected function _prepareOptions(Varien_Object $buyRequest, $product, $process $preparedValue = $group->prepareForCart(); if ($preparedValue !== null) { - $transport->options[$_option->getId()] = $preparedValue; + $transport->options[$option->getId()] = $preparedValue; } } @@ -839,7 +839,7 @@ public function setStoreFilter($store = null, $product = null) * (applicable for complicated product types. As default returns false) * * @param Mage_Catalog_Model_Product|null $product - * @return bool false + * @return bool */ public function getForceChildItemQtyChanges($product = null) { @@ -976,7 +976,7 @@ public function checkProductConfiguration($product, $buyRequest) * * @param Mage_Catalog_Model_Product $product * @param int $visibility - * @return bool + * @return false */ public function isMapEnabledInOptions($product, $visibility = null) { diff --git a/app/code/core/Mage/Catalog/Model/Resource/Abstract.php b/app/code/core/Mage/Catalog/Model/Resource/Abstract.php index 63a484f9903..ef393267ed6 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Abstract.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Abstract.php @@ -713,10 +713,10 @@ public function getAttributeRawText($entityId, $attribute, $store) // Ensure we have an associative array of attribute => values $values = is_array($value) ? $value : array_combine($attribute, [$value]); - foreach ($values as $_attribute => &$_value) { + foreach ($values as $_attribute => &$optionText) { $_attribute = (clone $this->getAttribute($_attribute))->setStoreId($store); if ($_attribute->getSourceModel() || $_attribute->getFrontendInput() === 'select' || $_attribute->getFrontendInput() === 'multiselect') { - $_value = $_attribute->getSource()->getOptionText($_value); + $optionText = $_attribute->getSource()->getOptionText($optionText); } } diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category.php b/app/code/core/Mage/Catalog/Model/Resource/Category.php index 60a1cd35dc1..a211aeab077 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Category.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category.php @@ -598,7 +598,6 @@ public function getParentDesignCategory($category) ->addFieldToFilter('level', ['neq' => 0]) ->setOrder('level', 'DESC') ->load(); - // phpcs:ignore Ecg.Performance.GetFirstItem.Found return $collection->getFirstItem(); } diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php index 644eba73fa5..55fe5de5e4f 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php @@ -654,14 +654,14 @@ protected function _getStaticColumns() if (in_array($column['COLUMN_NAME'], $columnsToSkip)) { continue; } - $_is_unsigned = ''; + $isUnsigned = ''; $ddlType = $helper->getDdlTypeByColumnType($column['DATA_TYPE']); $column['DEFAULT'] = empty($column['DEFAULT']) ? $column['DEFAULT'] : trim($column['DEFAULT'], "' "); switch ($ddlType) { case Varien_Db_Ddl_Table::TYPE_SMALLINT: case Varien_Db_Ddl_Table::TYPE_INTEGER: case Varien_Db_Ddl_Table::TYPE_BIGINT: - $_is_unsigned = (bool)$column['UNSIGNED']; + $isUnsigned = (bool)$column['UNSIGNED']; if ($column['DEFAULT'] === '') { $column['DEFAULT'] = null; } @@ -675,26 +675,26 @@ protected function _getStaticColumns() // no break case Varien_Db_Ddl_Table::TYPE_DECIMAL: $options = $column['PRECISION'] . ',' . $column['SCALE']; - $_is_unsigned = null; + $isUnsigned = null; if ($column['DEFAULT'] === '') { $column['DEFAULT'] = null; } break; case Varien_Db_Ddl_Table::TYPE_TEXT: $options = $column['LENGTH']; - $_is_unsigned = null; + $isUnsigned = null; break; case Varien_Db_Ddl_Table::TYPE_TIMESTAMP: $options = null; - $_is_unsigned = null; + $isUnsigned = null; break; case Varien_Db_Ddl_Table::TYPE_DATETIME: - $_is_unsigned = null; + $isUnsigned = null; break; } $columns[$column['COLUMN_NAME']] = [ 'type' => [$ddlType, $options], - 'unsigned' => $_is_unsigned, + 'unsigned' => $isUnsigned, 'nullable' => $column['NULLABLE'], 'default' => $column['DEFAULT'] ?? false, 'comment' => $column['COLUMN_NAME'] @@ -807,10 +807,10 @@ protected function _getAttributes() * Return attribute values for given entities and store * * @param int|string|array $entityIds - * @param int $store_id + * @param int $storeId * @return array */ - protected function _getAttributeValues($entityIds, $store_id) + protected function _getAttributeValues($entityIds, $storeId) { if (!is_array($entityIds)) { $entityIds = [$entityIds]; @@ -829,7 +829,7 @@ protected function _getAttributeValues($entityIds, $store_id) 'datetime' ]; foreach ($attributesType as $type) { - foreach ($this->_getAttributeTypeValues($type, $entityIds, $store_id) as $row) { + foreach ($this->_getAttributeTypeValues($type, $entityIds, $storeId) as $row) { if (isset($attributes[$row['attribute_id']])) { $values[$row['entity_id']][$attributes[$row['attribute_id']]['attribute_code']] = $row['value']; } diff --git a/app/code/core/Mage/Catalog/Model/Resource/Collection/Abstract.php b/app/code/core/Mage/Catalog/Model/Resource/Collection/Abstract.php index 343403da8f9..27de8993bd6 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Collection/Abstract.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Collection/Abstract.php @@ -164,11 +164,11 @@ protected function _addLoadAttributesSelectValues($select, $table, $type) */ protected function _joinAttributeToSelect($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias) { - $store_id = $this->_joinAttributes[$fieldCode]['store_id'] ?? $this->getStoreId(); + $storeId = $this->_joinAttributes[$fieldCode]['store_id'] ?? $this->getStoreId(); $adapter = $this->getConnection(); - if ($store_id != $this->getDefaultStoreId() && !$attribute->isScopeGlobal()) { + if ($storeId != $this->getDefaultStoreId() && !$attribute->isScopeGlobal()) { /** * Add joining default value for not default store * if value for store is null - we use default value @@ -200,11 +200,11 @@ protected function _joinAttributeToSelect($method, $attribute, $tableAlias, $con $this->_joinAttributes[$fieldCode]['condition_alias'] = $fieldAlias; $this->_joinAttributes[$fieldCode]['attribute'] = $attribute; } else { - $store_id = $this->getDefaultStoreId(); + $storeId = $this->getDefaultStoreId(); } $condition[] = $adapter->quoteInto( $adapter->quoteColumnAs("$tableAlias.store_id", null) . ' = ?', - $store_id + $storeId ); return parent::_joinAttributeToSelect($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias); } diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product.php b/app/code/core/Mage/Catalog/Model/Resource/Product.php index 2e471cdfeb6..da7e036fbaf 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Product.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product.php @@ -630,7 +630,6 @@ public function getProductsSku(array $productIds) * @return array * @deprecated after 1.4.2.0 */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function getParentProductIds($object) { return []; diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Image.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Image.php index fe9ad304bae..8e37031a97a 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Image.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Image.php @@ -30,6 +30,7 @@ public function getAllowedExtensions(): array * Save uploaded file and set its name to product attribute * @param Varien_Object $object * @return $this + * @SuppressWarnings(PHPMD.Superglobals) */ public function afterSave($object) { diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Option.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Option.php index fbb0775758b..b63626ba1b0 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Product/Option.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Option.php @@ -286,7 +286,7 @@ protected function _saveValueTitles(Mage_Core_Model_Abstract $object) /** * Delete prices * - * @param int $optionId + * @param int|string $optionId * @return $this */ public function deletePrices($optionId) @@ -304,7 +304,7 @@ public function deletePrices($optionId) /** * Delete titles * - * @param int $optionId + * @param int|string $optionId * @return $this */ public function deleteTitles($optionId) diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Option/Value.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Option/Value.php index 45861835574..b66fa7ba0b2 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Product/Option/Value.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Option/Value.php @@ -214,7 +214,7 @@ protected function _saveValueTitles(Mage_Core_Model_Abstract $object) /** * Delete values by option id * - * @param int $optionId + * @param int|string $optionId * @return $this */ public function deleteValue($optionId) diff --git a/app/code/core/Mage/Catalog/Model/Resource/Url.php b/app/code/core/Mage/Catalog/Model/Resource/Url.php index 275d7e873c1..9608d34c7b2 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Url.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Url.php @@ -1306,16 +1306,16 @@ public function getRewriteByProductStore(array $products) * * @param string $requestPath * @param int $storeId - * @param array $_checkedPaths internal variable to prevent infinite loops. + * @param array $checkedPaths internal variable to prevent infinite loops. * @return string | bool */ - public function findFinalTargetPath($requestPath, $storeId, &$_checkedPaths = []) + public function findFinalTargetPath($requestPath, $storeId, &$checkedPaths = []) { - if (in_array($requestPath, $_checkedPaths)) { + if (in_array($requestPath, $checkedPaths)) { return false; } - $_checkedPaths[] = $requestPath; + $checkedPaths[] = $requestPath; $select = $this->_getWriteAdapter()->select() ->from($this->getMainTable(), ['target_path', 'id_path']) @@ -1323,7 +1323,7 @@ public function findFinalTargetPath($requestPath, $storeId, &$_checkedPaths = [] ->where('request_path = ?', $requestPath); if ($row = $this->_getWriteAdapter()->fetchRow($select)) { - $idPath = $this->findFinalTargetPath($row['target_path'], $storeId, $_checkedPaths); + $idPath = $this->findFinalTargetPath($row['target_path'], $storeId, $checkedPaths); if (!$idPath) { return $row['id_path']; } else { diff --git a/app/code/core/Mage/Catalog/controllers/ProductController.php b/app/code/core/Mage/Catalog/controllers/ProductController.php index 2a74964971b..cf8b317ff5d 100644 --- a/app/code/core/Mage/Catalog/controllers/ProductController.php +++ b/app/code/core/Mage/Catalog/controllers/ProductController.php @@ -101,6 +101,8 @@ protected function _applyCustomDesignSettings($object, $update) /** * Product view action + * + * @SuppressWarnings(PHPMD.Superglobals) */ public function viewAction() { @@ -137,6 +139,8 @@ public function viewAction() /** * View product gallery action + * + * @SuppressWarnings(PHPMD.Superglobals) */ public function galleryAction() { diff --git a/app/code/core/Mage/CatalogIndex/Model/Resource/Indexer/Abstract.php b/app/code/core/Mage/CatalogIndex/Model/Resource/Indexer/Abstract.php index e51345d0110..2e914ca6200 100644 --- a/app/code/core/Mage/CatalogIndex/Model/Resource/Indexer/Abstract.php +++ b/app/code/core/Mage/CatalogIndex/Model/Resource/Indexer/Abstract.php @@ -70,7 +70,6 @@ public function saveIndices(array $data, $storeId, $productId) * @param int $productId * @return $this */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed protected function _executeReplace($data, $storeId, $productId) { $this->beginTransaction(); diff --git a/app/code/core/Mage/CatalogInventory/Model/Observer.php b/app/code/core/Mage/CatalogInventory/Model/Observer.php index 51347cdbdb1..bd65b0c5c8b 100644 --- a/app/code/core/Mage/CatalogInventory/Model/Observer.php +++ b/app/code/core/Mage/CatalogInventory/Model/Observer.php @@ -849,7 +849,6 @@ public function cancelOrderItem($observer) * @param Varien_Event_Observer $observer * @return $this */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found public function updateItemsStockUponConfigChange($observer) { Mage::getResourceSingleton('cataloginventory/stock')->updateSetOutOfStock(); @@ -1036,7 +1035,6 @@ public function refundOrderItem($observer) * @param Varien_Event_Observer $observer * @throws Exception */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found public function reindexProductsMassAction($observer) { Mage::getSingleton('index/indexer')->indexEvents( diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Billing/Items.php b/app/code/core/Mage/Checkout/Block/Multishipping/Billing/Items.php index b8d559b9ff0..ac393bec6d9 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Billing/Items.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Billing/Items.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Checkout * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -59,9 +59,9 @@ public function getVirtualProductEditUrl() public function getVirtualQuoteItems() { $items = []; - foreach ($this->getQuote()->getItemsCollection() as $_item) { - if ($_item->getProduct()->getIsVirtual() && !$_item->getParentItemId()) { - $items[] = $_item; + foreach ($this->getQuote()->getItemsCollection() as $item) { + if ($item->getProduct()->getIsVirtual() && !$item->getParentItemId()) { + $items[] = $item; } } return $items; diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php b/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php index 24fcb0b6f89..8de9e04dd4d 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php @@ -262,12 +262,12 @@ public function getVirtualProductEditUrl() public function getVirtualItems() { $items = []; - foreach ($this->getBillingAddress()->getItemsCollection() as $_item) { - if ($_item->isDeleted()) { + foreach ($this->getBillingAddress()->getItemsCollection() as $item) { + if ($item->isDeleted()) { continue; } - if ($_item->getProduct()->getIsVirtual() && !$_item->getParentItemId()) { - $items[] = $_item; + if ($item->getProduct()->getIsVirtual() && !$item->getParentItemId()) { + $items[] = $item; } } return $items; diff --git a/app/code/core/Mage/Checkout/Helper/Data.php b/app/code/core/Mage/Checkout/Helper/Data.php index a8d3f212a83..1124faee77f 100644 --- a/app/code/core/Mage/Checkout/Helper/Data.php +++ b/app/code/core/Mage/Checkout/Helper/Data.php @@ -221,11 +221,11 @@ public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'one } $items = ''; - foreach ($checkout->getAllVisibleItems() as $_item) { - /** @var Mage_Sales_Model_Quote_Item $_item */ - $items .= $_item->getProduct()->getName() . ' x ' . $_item->getQty() . ' ' + foreach ($checkout->getAllVisibleItems() as $item) { + /** @var Mage_Sales_Model_Quote_Item $item */ + $items .= $item->getProduct()->getName() . ' x ' . $item->getQty() . ' ' . $checkout->getStoreCurrencyCode() . ' ' - . $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n"; + . $item->getProduct()->getFinalPrice($item->getQty()) . "\n"; } $total = $checkout->getStoreCurrencyCode() . ' ' . $checkout->getGrandTotal(); diff --git a/app/code/core/Mage/Checkout/Model/Type/Multishipping.php b/app/code/core/Mage/Checkout/Model/Type/Multishipping.php index fc51baf6825..f0df4d7ec44 100644 --- a/app/code/core/Mage/Checkout/Model/Type/Multishipping.php +++ b/app/code/core/Mage/Checkout/Model/Type/Multishipping.php @@ -128,6 +128,7 @@ public function getQuoteShippingAddressesItems() } $addressItem->setQty(1) ->setCustomerAddressId($address->getCustomerAddressId()) + // phpcs:ignore Ecg.Performance.Loop.ModelLSD ->save(); $items[] = $addressItem; } @@ -230,12 +231,12 @@ public function setShippingItemsInformation($info) * Delete all not virtual quote items which are not added to shipping address * MultishippingQty should be defined for each quote item when it processed with _addShippingItem */ - foreach ($quote->getAllItems() as $_item) { - if (!$_item->getProduct()->getIsVirtual() && - !$_item->getParentItem() && - !$_item->getMultishippingQty() + foreach ($quote->getAllItems() as $item) { + if (!$item->getProduct()->getIsVirtual() && + !$item->getParentItem() && + !$item->getMultishippingQty() ) { - $quote->removeItem($_item->getId()); + $quote->removeItem($item->getId()); } } @@ -247,18 +248,18 @@ public function setShippingItemsInformation($info) $quote->getBillingAddress()->importCustomerAddress($customerDefaultBilling); } - foreach ($quote->getAllItems() as $_item) { - if (!$_item->getProduct()->getIsVirtual()) { + foreach ($quote->getAllItems() as $item) { + if (!$item->getProduct()->getIsVirtual()) { continue; } - if (isset($itemsInfo[$_item->getId()]['qty'])) { - if ($qty = (int)$itemsInfo[$_item->getId()]['qty']) { - $_item->setQty($qty); - $quote->getBillingAddress()->addItem($_item); + if (isset($itemsInfo[$item->getId()]['qty'])) { + if ($qty = (int)$itemsInfo[$item->getId()]['qty']) { + $item->setQty($qty); + $quote->getBillingAddress()->addItem($item); } else { - $_item->setQty(0); - $quote->removeItem($_item->getId()); + $item->setQty(0); + $quote->removeItem($item->getId()); } } } @@ -509,6 +510,7 @@ public function createOrders() foreach ($orders as $order) { $order->place(); + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $order->save(); if ($order->getCanSendNewEmailFlag()) { $order->queueNewOrderEmail(); diff --git a/app/code/core/Mage/Cms/Controller/Router.php b/app/code/core/Mage/Cms/Controller/Router.php index 368afa71e33..a6c70563106 100644 --- a/app/code/core/Mage/Cms/Controller/Router.php +++ b/app/code/core/Mage/Cms/Controller/Router.php @@ -38,6 +38,7 @@ public function initControllerRouters($observer) * Validate and Match Cms Page and modify request * * @return bool + * @SuppressWarnings(PHPMD.ExitExpression) */ public function match(Zend_Controller_Request_Http $request) { @@ -45,7 +46,6 @@ public function match(Zend_Controller_Request_Http $request) Mage::app()->getFrontController()->getResponse() ->setRedirect(Mage::getUrl('install')) ->sendResponse(); - // phpcs:ignore: Ecg.Security.LanguageConstruct.ExitUsage exit; } diff --git a/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php b/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php index 08e514a593c..21d80cf1a56 100644 --- a/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php +++ b/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php @@ -70,7 +70,6 @@ public function getStorageRoot() if (!$this->_storageRoot) { $path = Mage::getConfig()->getOptions()->getMediaDir() . DS . Mage_Cms_Model_Wysiwyg_Config::IMAGE_DIRECTORY; - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found $this->_storageRoot = realpath($path); if (!$this->_storageRoot) { $this->_storageRoot = $path; @@ -108,7 +107,6 @@ public function getTreeNodeName() */ public function convertPathToId($path) { - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found $storageRoot = realpath($this->getStorageRoot()); $path = str_replace($storageRoot, '', $path); return $this->idEncode($path); @@ -123,7 +121,6 @@ public function convertPathToId($path) public function convertIdToPath($id) { $path = $this->idDecode($id); - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found $storageRoot = realpath($this->getStorageRoot()); if (!strstr($path, $storageRoot)) { $path = $storageRoot . DS . $path; @@ -212,9 +209,7 @@ public function getCurrentPath() $currentPath = $this->getStorageRoot(); $node = $this->_getRequest()->getParam($this->getTreeNodeName()); if ($node) { - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found $path = realpath($this->convertIdToPath($node)); - // phpcs:ignore: Ecg.Security.DiscouragedFunction.Discouraged if ($path && is_dir($path) && stripos($path, $currentPath) !== false) { $currentPath = $path; } @@ -240,7 +235,6 @@ public function getCurrentPath() public function getCurrentUrl() { if (!$this->_currentUrl) { - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found $mediaPath = realpath(Mage::getConfig()->getOptions()->getMediaDir()); $path = str_replace($mediaPath, '', $this->getCurrentPath()); $path = trim($path, DS); @@ -280,7 +274,6 @@ public function idEncode($string) public function idDecode($string) { $string = strtr($string, ':_-', '+/='); - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found return base64_decode($string); } diff --git a/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php b/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php index 3974734a8fd..bcad2e012d3 100644 --- a/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php +++ b/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php @@ -51,9 +51,7 @@ public function getDirsCollection($path) $subDirectories = Mage::getModel('core/file_storage_directory_database')->getSubdirectories($path); foreach ($subDirectories as $directory) { $fullPath = rtrim($path, DS) . DS . $directory['name']; - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found if (!file_exists($fullPath)) { - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found mkdir($fullPath, 0777, true); } } @@ -138,7 +136,6 @@ public function getFilesCollection($path, $type = null) $thumbUrl = Mage::getSingleton('adminhtml/url')->getUrl('*/*/thumbnail', ['file' => $item->getId()]); } - // phpcs:ignore: Generic.PHP.NoSilencedErrors.Discouraged $size = @getimagesize($item->getFilename()); if (is_array($size)) { @@ -183,14 +180,12 @@ public function createDirectory($name, $path) if (!preg_match(self::DIRECTORY_NAME_REGEXP, $name)) { Mage::throwException(Mage::helper('cms')->__('Invalid folder name. Please, use alphanumeric characters, underscores and dashes.')); } - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found, Ecg.Security.DiscouragedFunction.Discouraged if (!is_dir($path) || !is_writable($path)) { $path = $this->getHelper()->getStorageRoot(); } $newPath = $path . DS . $name; - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found if (file_exists($newPath)) { Mage::throwException(Mage::helper('cms')->__('A directory with the same name already exists. Please try another folder name.')); } @@ -231,7 +226,6 @@ public function deleteDirectory($path) $io->getFilteredPath($path) )); } - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found if (str_contains($pathCmp, chr(0)) || preg_match('#(^|[\\\\/])\.\.($|[\\\\/])#', $pathCmp) ) { @@ -304,7 +298,6 @@ public function uploadFile($targetPath, $type = null) $this->resizeFile($targetPath . DS . $uploader->getUploadedFileName(), true); } $result['cookie'] = [ - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found 'name' => session_name(), 'value' => $this->getSession()->getSessionId(), 'lifetime' => $this->getSession()->getCookieLifetime(), @@ -329,7 +322,6 @@ public function getThumbnailPath($filePath, $checkFile = false) if (str_starts_with($filePath, $mediaRootDir)) { $thumbPath = $this->getThumbnailRoot() . DS . substr($filePath, strlen($mediaRootDir)); - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found if (!$checkFile || is_readable($thumbPath)) { return $thumbPath; } @@ -350,7 +342,6 @@ public function getThumbnailUrl($filePath, $checkFile = false) $mediaRootDir = Mage::getConfig()->getOptions()->getMediaDir() . DS; if (str_starts_with($filePath, $mediaRootDir)) { $thumbSuffix = self::THUMBS_DIRECTORY_NAME . DS . substr($filePath, strlen($mediaRootDir)); - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found if (!$checkFile || is_readable($this->getHelper()->getStorageRoot() . $thumbSuffix)) { $randomIndex = '?rand=' . time(); $thumbUrl = $this->getHelper()->getBaseUrl() . Mage_Cms_Model_Wysiwyg_Config::IMAGE_DIRECTORY @@ -370,7 +361,6 @@ public function getThumbnailUrl($filePath, $checkFile = false) */ public function resizeFile($source, $keepRation = true) { - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found, Ecg.Security.DiscouragedFunction.Discouraged if (!is_file($source) || !is_readable($source)) { return false; } @@ -396,10 +386,8 @@ public function resizeFile($source, $keepRation = true) $image->resize($width, $height); $dest = $targetDir . DS - // phpcs:ignore: Ecg.Security.DiscouragedFunction.Discouraged . Mage_Core_Model_File_Uploader::getCorrectFileName(pathinfo($source, PATHINFO_BASENAME)); $image->save($dest); - // phpcs:ignore: Ecg.Security.DiscouragedFunction.Discouraged if (is_file($dest)) { return $dest; } @@ -433,7 +421,6 @@ public function getThumbsPath($filePath = false) $thumbnailDir = $this->getThumbnailRoot(); if ($filePath && str_starts_with($filePath, $mediaRootDir)) { - // phpcs:ignore: Ecg.Security.ForbiddenFunction.Found $thumbnailDir .= DS . dirname(substr($filePath, strlen($mediaRootDir))); } @@ -542,7 +529,6 @@ public function isImage($filename) if (!$this->hasData('_image_extensions')) { $this->setData('_image_extensions', $this->getAllowedExtensions('image')); } - // phpcs:ignore: Ecg.Security.DiscouragedFunction.Discouraged $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); return in_array($ext, $this->_getData('_image_extensions')); } diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php index bbe51af7ba6..0014d7f91df 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_ConfigurableSwatches * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2018-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2018-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -50,6 +50,7 @@ public function isEnabled() * * @param string $str * @return string + * @SuppressWarnings(PHPMD.ErrorControlOperator) */ public function getHyphenatedString($str) { diff --git a/app/code/core/Mage/Core/Block/Abstract.php b/app/code/core/Mage/Core/Block/Abstract.php index f1b433066bf..36e45263d6e 100644 --- a/app/code/core/Mage/Core/Block/Abstract.php +++ b/app/code/core/Mage/Core/Block/Abstract.php @@ -522,7 +522,6 @@ public function unsetCallChild($alias, $callback, $result, $params) } Mage::helper('core/security')->validateAgainstBlockMethodBlacklist($child, $callback, $params); - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if ($result == call_user_func_array([&$child, $callback], $params)) { $this->unsetChild($alias); } @@ -1173,11 +1172,13 @@ public function getModuleName() * Translate block sentence * * @return string + * + * @SuppressWarnings(PHPMD.CamelCaseMethodName) + * @SuppressWarnings(PHPMD.ShortMethodName) */ public function __() { $args = func_get_args(); - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->getModuleName()); array_unshift($args, $expr); return $this->_getApp()->getTranslator()->translate($args); @@ -1216,7 +1217,6 @@ public function escapeHtml($data, $allowedTags = null) */ public function escapeHtmlAsObject(string $data, ?array $allowedTags = null): Mage_Core_Model_Security_HtmlEscapedString { - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation return new Mage_Core_Model_Security_HtmlEscapedString($data, $allowedTags); } diff --git a/app/code/core/Mage/Core/Block/Profiler.php b/app/code/core/Mage/Core/Block/Profiler.php index 7849ae868d9..cd4e0efb4e4 100644 --- a/app/code/core/Mage/Core/Block/Profiler.php +++ b/app/code/core/Mage/Core/Block/Profiler.php @@ -21,6 +21,7 @@ class Mage_Core_Block_Profiler extends Mage_Core_Block_Abstract { /** * @return string + * @SuppressWarnings(PHPMD.DevelopmentCodeFragment) */ protected function _toHtml() { @@ -59,7 +60,6 @@ protected function _toHtml() } $out .= ''; $out .= '
';
-        // phpcs:ignore Ecg.Security.ForbiddenFunction.Found
         $out .= print_r(Varien_Profiler::getSqlProfiler(Mage::getSingleton('core/resource')->getConnection('core_write')), true);
         $out .= '
'; $out .= ''; diff --git a/app/code/core/Mage/Core/Block/Text/Tag/Css/Admin.php b/app/code/core/Mage/Core/Block/Text/Tag/Css/Admin.php index 47cd18472c8..2ebaca7f3d3 100644 --- a/app/code/core/Mage/Core/Block/Text/Tag/Css/Admin.php +++ b/app/code/core/Mage/Core/Block/Text/Tag/Css/Admin.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Core * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -23,6 +23,9 @@ */ class Mage_Core_Block_Text_Tag_Css_Admin extends Mage_Core_Block_Text_Tag_Css { + /** + * @SuppressWarnings(PHPMD.Superglobals) + */ protected function _construct() { parent::_construct(); diff --git a/app/code/core/Mage/Core/Block/Text/Tag/Debug.php b/app/code/core/Mage/Core/Block/Text/Tag/Debug.php index b9b9ea1b927..ce518221c8b 100644 --- a/app/code/core/Mage/Core/Block/Text/Tag/Debug.php +++ b/app/code/core/Mage/Core/Block/Text/Tag/Debug.php @@ -32,10 +32,10 @@ protected function _construct() /** * @param mixed $value * @return $this + * @SuppressWarnings(PHPMD.DevelopmentCodeFragment) */ public function setValue($value) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found return $this->setContents(print_r($value, true)); } } diff --git a/app/code/core/Mage/Core/Controller/Front/Action.php b/app/code/core/Mage/Core/Controller/Front/Action.php index 5f2a88ff592..5c6dd9bb077 100644 --- a/app/code/core/Mage/Core/Controller/Front/Action.php +++ b/app/code/core/Mage/Core/Controller/Front/Action.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Core * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -76,6 +76,8 @@ public function postDispatch() * Translate a phrase * * @return string + * @SuppressWarnings(PHPMD.CamelCaseMethodName) + * @SuppressWarnings(PHPMD.ShortMethodName) */ public function __() { @@ -94,6 +96,7 @@ public function __() * @param string $contentType * @param int $contentLength explicit content length, if strlen($content) isn't applicable * @return $this + * @SuppressWarnings(PHPMD.ExitExpression) */ protected function _prepareDownloadResponse( $fileName, diff --git a/app/code/core/Mage/Core/Controller/Request/Http.php b/app/code/core/Mage/Core/Controller/Request/Http.php index f3442146f75..bfef5b20459 100644 --- a/app/code/core/Mage/Core/Controller/Request/Http.php +++ b/app/code/core/Mage/Core/Controller/Request/Http.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Core * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -317,6 +317,9 @@ public function getScheme() * * @param bool $trimPort * @return false|string + * + * @SuppressWarnings(PHPMD.ExitExpression) + * @SuppressWarnings(PHPMD.Superglobals) */ public function getHttpHost($trimPort = true) { @@ -343,8 +346,8 @@ public function getHttpHost($trimPort = true) * * @param string|array $key * @param mixed $value - * * @return $this + * @SuppressWarnings(PHPMD.Superglobals) */ public function setPost($key, $value = null) { diff --git a/app/code/core/Mage/Core/Controller/Response/Http.php b/app/code/core/Mage/Core/Controller/Response/Http.php index 5989c238389..2bf05ecd511 100644 --- a/app/code/core/Mage/Core/Controller/Response/Http.php +++ b/app/code/core/Mage/Core/Controller/Response/Http.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Core * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -98,7 +98,8 @@ public function setRedirect($url, $code = 302) /** * Method send already collected headers and exit from script - * @return never + * @return void + * @SuppressWarnings(PHPMD.ExitExpression) */ public function sendHeadersAndExit() { diff --git a/app/code/core/Mage/Core/Controller/Varien/Action.php b/app/code/core/Mage/Core/Controller/Varien/Action.php index d0446f5e66a..0d4a9fbfce2 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Action.php +++ b/app/code/core/Mage/Core/Controller/Varien/Action.php @@ -286,7 +286,7 @@ public function addActionLayoutHandles() */ public function loadLayoutUpdates() { - $_profilerKey = self::PROFILER_KEY . '::' . $this->getFullActionName(); + $profilerKey = self::PROFILER_KEY . '::' . $this->getFullActionName(); // dispatch event for adding handles to layout update Mage::dispatchEvent( @@ -295,9 +295,9 @@ public function loadLayoutUpdates() ); // load layout updates by specified handles - Varien_Profiler::start("$_profilerKey::layout_load"); + Varien_Profiler::start("$profilerKey::layout_load"); $this->getLayout()->getUpdate()->load(); - Varien_Profiler::stop("$_profilerKey::layout_load"); + Varien_Profiler::stop("$profilerKey::layout_load"); return $this; } @@ -307,7 +307,7 @@ public function loadLayoutUpdates() */ public function generateLayoutXml() { - $_profilerKey = self::PROFILER_KEY . '::' . $this->getFullActionName(); + $profilerKey = self::PROFILER_KEY . '::' . $this->getFullActionName(); // dispatch event for adding text layouts if (!$this->getFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT)) { Mage::dispatchEvent( @@ -317,9 +317,9 @@ public function generateLayoutXml() } // generate xml from collected text updates - Varien_Profiler::start("$_profilerKey::layout_generate_xml"); + Varien_Profiler::start("$profilerKey::layout_generate_xml"); $this->getLayout()->generateXml(); - Varien_Profiler::stop("$_profilerKey::layout_generate_xml"); + Varien_Profiler::stop("$profilerKey::layout_generate_xml"); return $this; } @@ -329,7 +329,7 @@ public function generateLayoutXml() */ public function generateLayoutBlocks() { - $_profilerKey = self::PROFILER_KEY . '::' . $this->getFullActionName(); + $profilerKey = self::PROFILER_KEY . '::' . $this->getFullActionName(); // dispatch event for adding xml layout elements if (!$this->getFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT)) { Mage::dispatchEvent( @@ -339,9 +339,9 @@ public function generateLayoutBlocks() } // generate blocks from xml layout - Varien_Profiler::start("$_profilerKey::layout_generate_blocks"); + Varien_Profiler::start("$profilerKey::layout_generate_blocks"); $this->getLayout()->generateBlocks(); - Varien_Profiler::stop("$_profilerKey::layout_generate_blocks"); + Varien_Profiler::stop("$profilerKey::layout_generate_blocks"); if (!$this->getFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT)) { Mage::dispatchEvent( @@ -361,7 +361,7 @@ public function generateLayoutBlocks() */ public function renderLayout($output = '') { - $_profilerKey = self::PROFILER_KEY . '::' . $this->getFullActionName(); + $profilerKey = self::PROFILER_KEY . '::' . $this->getFullActionName(); if ($this->getFlag('', 'no-renderLayout')) { return; @@ -373,7 +373,7 @@ public function renderLayout($output = '') $this->_renderTitles(); - Varien_Profiler::start("$_profilerKey::layout_render"); + Varien_Profiler::start("$profilerKey::layout_render"); if ($output !== '') { $this->getLayout()->addOutputBlock($output); @@ -388,7 +388,7 @@ public function renderLayout($output = '') $output = $this->getLayout()->getOutput(); Mage::getSingleton('core/translate_inline')->processResponseBody($output); $this->getResponse()->appendBody($output); - Varien_Profiler::stop("$_profilerKey::layout_render"); + Varien_Profiler::stop("$profilerKey::layout_render"); return $this; } @@ -413,11 +413,11 @@ public function dispatch($action) * preDispatch() didn't change the action, so we can continue */ if (!$this->getFlag('', self::FLAG_NO_DISPATCH)) { - $_profilerKey = self::PROFILER_KEY . '::' . $this->getFullActionName(); + $profilerKey = self::PROFILER_KEY . '::' . $this->getFullActionName(); - Varien_Profiler::start($_profilerKey); + Varien_Profiler::start($profilerKey); $this->$actionMethodName(); - Varien_Profiler::stop($_profilerKey); + Varien_Profiler::stop($profilerKey); Varien_Profiler::start(self::PROFILER_KEY . '::postdispatch'); $this->postDispatch(); @@ -465,6 +465,7 @@ public function getActionMethodName($action) * Dispatch event before action * * @return void + * @SuppressWarnings(PHPMD.Superglobals) */ public function preDispatch() { @@ -1034,6 +1035,7 @@ protected function _filterDateTime($array, $dateFields) * @param string $contentType * @param int $contentLength explicit content length, if strlen($content) isn't applicable * @return $this + * @SuppressWarnings(PHPMD.ExitExpression) */ protected function _prepareDownloadResponse( $fileName, diff --git a/app/code/core/Mage/Core/Controller/Varien/Front.php b/app/code/core/Mage/Core/Controller/Varien/Front.php index f42f97363ac..eab15df9434 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Front.php +++ b/app/code/core/Mage/Core/Controller/Varien/Front.php @@ -149,6 +149,7 @@ public function init() Mage::dispatchEvent('controller_front_init_routers', ['front' => $this]); // Add default router at the last + // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $default = new Mage_Core_Controller_Varien_Router_Default(); $this->addRouter('default', $default); @@ -321,6 +322,7 @@ protected function _processRewriteUrl($url) * @param Mage_Core_Controller_Request_Http $request * * @SuppressWarnings(PHPMD.ErrorControlOperator) + * @SuppressWarnings(PHPMD.ExitExpression) */ protected function _checkBaseUrl($request) { diff --git a/app/code/core/Mage/Core/Controller/Varien/Router/Admin.php b/app/code/core/Mage/Core/Controller/Varien/Router/Admin.php index b5651fe07db..62ad4fa8396 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Router/Admin.php +++ b/app/code/core/Mage/Core/Controller/Varien/Router/Admin.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Core * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -56,6 +56,7 @@ protected function _beforeModuleMatch() * checking if we installed or not and doing redirect * * @return bool + * @SuppressWarnings(PHPMD.ExitExpression) */ protected function _afterModuleMatch() { diff --git a/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php b/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php index 392b3d0a989..d5ecc7b619e 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php +++ b/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php @@ -245,7 +245,7 @@ public function match(Zend_Controller_Request_Http $request) $request->setActionName($action); $request->setControllerModule($realModule); - // set parameters from pathinfo + // set parameters from path info for ($i = 3, $l = count($p); $i < $l; $i += 2) { $request->setParam($p[$i], isset($p[$i + 1]) ? urldecode($p[$i + 1]) : ''); } @@ -375,7 +375,7 @@ public function getModuleByFrontName($frontName) /** * @param string $moduleName - * @param string $modules + * @param array $modules * @return bool */ public function getModuleByName($moduleName, $modules) @@ -478,6 +478,7 @@ public function rewrite(array $p) * * @param Mage_Core_Controller_Request_Http $request * @param string $path + * @SuppressWarnings(PHPMD.ExitExpression) */ protected function _checkShouldBeSecure($request, $path = '') { diff --git a/app/code/core/Mage/Core/Helper/Abstract.php b/app/code/core/Mage/Core/Helper/Abstract.php index 27c15ea338d..5e00441743a 100644 --- a/app/code/core/Mage/Core/Helper/Abstract.php +++ b/app/code/core/Mage/Core/Helper/Abstract.php @@ -165,6 +165,8 @@ public function isModuleEnabled($moduleName = null) * Translate * * @return string + * @SuppressWarnings(PHPMD.CamelCaseMethodName) + * @SuppressWarnings(PHPMD.ShortMethodName) */ public function __() { diff --git a/app/code/core/Mage/Core/Helper/Data.php b/app/code/core/Mage/Core/Helper/Data.php index d32a3cd721a..1e005f8ab4b 100644 --- a/app/code/core/Mage/Core/Helper/Data.php +++ b/app/code/core/Mage/Core/Helper/Data.php @@ -384,14 +384,12 @@ public function removeAccents($string, $german = false) $replacements[$german] = []; foreach ($subst as $k => $v) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $replacements[$german][$k < 256 ? chr($k) : '&#' . $k . ';'] = $v; } } // convert string from default database format (UTF-8) // to encoding which replacement arrays made with (ISO-8859-1) - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged if ($s = @iconv('UTF-8', 'ISO-8859-1', $string)) { $string = $s; } @@ -785,18 +783,14 @@ public function mergeFiles( // check whether merger is required $shouldMerge = $mustMerge || !$targetFile; if (!$shouldMerge) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if (!file_exists($targetFile)) { $shouldMerge = true; } else { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $targetMtime = filemtime($targetFile); foreach ($srcFiles as $file) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if (!file_exists($file)) { // no translation intentionally Mage::logException(new Exception(sprintf('File %s not found.', $file))); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found } elseif (@filemtime($file) > $targetMtime) { $shouldMerge = true; break; @@ -807,10 +801,8 @@ public function mergeFiles( // merge contents into the file if ($shouldMerge) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if ($targetFile && !is_writable(dirname($targetFile))) { // no translation intentionally - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found throw new Exception(sprintf('Path %s is not writeable.', dirname($targetFile))); } @@ -821,7 +813,6 @@ public function mergeFiles( } if (!empty($srcFiles)) { foreach ($srcFiles as $key => $file) { - // phpcs:ignore Ecg.Security.DiscouragedFunction.Discouraged $fileExt = strtolower(pathinfo($file, PATHINFO_EXTENSION)); if (!in_array($fileExt, $extensionsFilter)) { unset($srcFiles[$key]); @@ -836,15 +827,12 @@ public function mergeFiles( $data = ''; foreach ($srcFiles as $file) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if (!file_exists($file)) { continue; } - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $contents = file_get_contents($file) . "\n"; // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if ($beforeMergeCallback && is_callable($beforeMergeCallback)) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $contents = call_user_func($beforeMergeCallback, $file, $contents); } $data .= $contents; @@ -854,7 +842,6 @@ public function mergeFiles( throw new Exception(sprintf("No content found in files:\n%s", implode("\n", $srcFiles))); } if ($targetFile) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found file_put_contents($targetFile, $data, LOCK_EX); } else { return $data; // no need to write to file, just return data @@ -910,7 +897,6 @@ public function getPublicFilesValidPath() public function checkLfiProtection($name) { if (preg_match('#\.\.[\\\/]#', $name)) { - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation throw new Mage_Core_Exception($this->__('Requested file may not include parent directory traversal ("../", "..\\" notation)')); } return true; diff --git a/app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php b/app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php index 3d4a293098d..54e4e5720bf 100644 --- a/app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php +++ b/app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php @@ -108,7 +108,7 @@ protected function getConfigKey(string $configKey): array ), 'trim' ); - list($_, $scope) = $configKeyParts; + list($unused, $scope) = $configKeyParts; return [$configKeyParts, $scope]; } diff --git a/app/code/core/Mage/Core/Helper/Http.php b/app/code/core/Mage/Core/Helper/Http.php index 00d3a33701b..f62acc54fbb 100644 --- a/app/code/core/Mage/Core/Helper/Http.php +++ b/app/code/core/Mage/Core/Helper/Http.php @@ -35,6 +35,7 @@ class Mage_Core_Helper_Http extends Mage_Core_Helper_Abstract * Validate and retrieve user and password from HTTP * @param array|null $headers * @return array + * @SuppressWarnings(PHPMD.Superglobals) */ public function authValidate($headers = null) { @@ -78,7 +79,8 @@ public function authValidate($headers = null) /** * Send auth failed Headers and exit * - * @return never + * @return void + * @SuppressWarnings(PHPMD.ExitExpression) */ public function authFailed() { @@ -113,6 +115,7 @@ public function getRemoteAddrHeaders() * * @param bool $ipToLong converting IP to long format * @return false|string IPv4|long + * @SuppressWarnings(PHPMD.Superglobals) */ public function getRemoteAddr($ipToLong = false) { diff --git a/app/code/core/Mage/Core/Helper/String.php b/app/code/core/Mage/Core/Helper/String.php index 680bd41e242..46196a2b374 100644 --- a/app/code/core/Mage/Core/Helper/String.php +++ b/app/code/core/Mage/Core/Helper/String.php @@ -156,6 +156,7 @@ public function strrev($str) * @param bool $trim * @param string $wordSeparatorRegex * @return array + * @SuppressWarnings(PHPMD.CamelCaseMethodName) */ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps public function str_split($str, $length = 1, $keepWords = false, $trim = false, $wordSeparatorRegex = '\s') diff --git a/app/code/core/Mage/Core/Model/Abstract.php b/app/code/core/Mage/Core/Model/Abstract.php index e0219c6c21e..5f299917b9a 100644 --- a/app/code/core/Mage/Core/Model/Abstract.php +++ b/app/code/core/Mage/Core/Model/Abstract.php @@ -474,8 +474,8 @@ public function getCacheIdTags() if ($this->getId() && $this->_cacheTag) { $tags = []; if (is_array($this->_cacheTag)) { - foreach ($this->_cacheTag as $_tag) { - $tags[] = $_tag . '_' . $this->getId(); + foreach ($this->_cacheTag as $tag) { + $tags[] = $tag . '_' . $this->getId(); } } else { $tags[] = $this->_cacheTag . '_' . $this->getId(); diff --git a/app/code/core/Mage/Core/Model/App.php b/app/code/core/Mage/Core/Model/App.php index 9f360bfe60f..d65a8c94d3d 100644 --- a/app/code/core/Mage/Core/Model/App.php +++ b/app/code/core/Mage/Core/Model/App.php @@ -364,9 +364,7 @@ public function run($params) } else { flush(); } - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if (session_status() === PHP_SESSION_ACTIVE) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found session_write_close(); } @@ -539,10 +537,10 @@ public function getCookie() * * @param string $type * @return $this + * @SuppressWarnings(PHPMD.Superglobals) */ protected function _checkGetStore($type) { - // phpcs:ignore Ecg.Security.Superglobal.SuperglobalUsageError if (empty($_GET)) { return $this; } @@ -550,12 +548,10 @@ protected function _checkGetStore($type) /** * @todo check XML_PATH_STORE_IN_URL */ - // phpcs:ignore Ecg.Security.Superglobal.SuperglobalUsageError if (!isset($_GET['___store'])) { return $this; } - // phpcs:ignore Ecg.Security.Superglobal.SuperglobalUsageError $store = $_GET['___store']; if (!isset($this->_stores[$store])) { return $this; @@ -657,7 +653,6 @@ protected function _initStores() $this->_isSingleStore = false; if ($this->_isSingleStoreAllowed) { - // phpcs:ignore Ecg.Performance.CollectionCount.Found $this->_isSingleStore = $storeCollection->count() < 3; } @@ -785,7 +780,6 @@ public function setCurrentStore($store) */ protected function _initFrontController() { - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $this->_frontController = new Mage_Core_Controller_Varien_Front(); Mage::register('controller', $this->_frontController); Varien_Profiler::start('mage::app::init_front_controller'); @@ -840,7 +834,6 @@ public function loadAreaPart($area, $part) public function getArea($code) { if (!isset($this->_areas[$code])) { - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $this->_areas[$code] = new Mage_Core_Model_App_Area($code, $this); } return $this->_areas[$code]; @@ -959,11 +952,11 @@ protected function _getDefaultStore() */ public function getDefaultStoreView() { - foreach ($this->getWebsites() as $_website) { - if ($_website->getIsDefault()) { - $_defaultStore = $this->getGroup($_website->getDefaultGroupId())->getDefaultStore(); - if ($_defaultStore) { - return $_defaultStore; + foreach ($this->getWebsites() as $website) { + if ($website->getIsDefault()) { + $defaultStore = $this->getGroup($website->getDefaultGroupId())->getDefaultStore(); + if ($defaultStore) { + return $defaultStore; } } } @@ -1272,9 +1265,7 @@ public function saveUseCache($data) */ public function cleanAllSessions() { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if (session_module_name() == 'files') { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $dir = session_save_path(); mageDelTree($dir); } @@ -1289,7 +1280,6 @@ public function cleanAllSessions() public function getRequest() { if (empty($this->_request)) { - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $this->_request = new Mage_Core_Controller_Request_Http(); } return $this->_request; @@ -1308,20 +1298,18 @@ public function setRequest(Mage_Core_Controller_Request_Http $request) /** * @return bool + * @SuppressWarnings(PHPMD.Superglobals) */ public function isCurrentlySecure() { - // phpcs:ignore Ecg.Security.Superglobal.SuperglobalUsageWarning if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') { return true; } - // phpcs:ignore Ecg.Security.Superglobal.SuperglobalUsageWarning if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { return true; } - // phpcs:ignore Ecg.Security.Superglobal.SuperglobalUsageWarning if (isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] == 443)) { return true; } @@ -1331,7 +1319,6 @@ public function isCurrentlySecure() if ($offloaderHeader) { $offloaderHeader = preg_replace('/[^A-Z]+/', '_', $offloaderHeader); $offloaderHeader = str_starts_with($offloaderHeader, 'HTTP_') ? $offloaderHeader : 'HTTP_' . $offloaderHeader; - // phpcs:ignore Ecg.Security.Superglobal.SuperglobalUsageWarning if (!empty($_SERVER[$offloaderHeader]) && $_SERVER[$offloaderHeader] !== 'http') { return true; } @@ -1349,7 +1336,6 @@ public function isCurrentlySecure() public function getResponse() { if (empty($this->_response)) { - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $this->_response = new Mage_Core_Controller_Response_Http(); $this->_response->headersSentThrowsException = Mage::$headersSentThrowsException; $this->_response->setHeader('Content-Type', 'text/html; charset=UTF-8'); @@ -1495,7 +1481,6 @@ public function getUpdateMode() */ public function throwStoreException($text = '') { - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation throw new Mage_Core_Model_Store_Exception($text); } diff --git a/app/code/core/Mage/Core/Model/Config.php b/app/code/core/Mage/Core/Model/Config.php index f30099f6bf6..2329f0501c7 100644 --- a/app/code/core/Mage/Core/Model/Config.php +++ b/app/code/core/Mage/Core/Model/Config.php @@ -258,9 +258,7 @@ class Mage_Core_Model_Config extends Mage_Core_Model_Config_Base public function __construct($sourceData = null) { $this->setCacheId('config_global'); - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $this->_options = new Mage_Core_Model_Config_Options($sourceData); - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $this->_prototype = new Mage_Core_Model_Config_Base(); $this->_cacheChecksum = null; parent::__construct($sourceData); @@ -341,7 +339,6 @@ public function init($options = []) public function loadBase() { $etcDir = $this->getOptions()->getEtcDir(); - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $files = glob($etcDir . DS . '*.xml'); $this->loadFile(current($files)); while ($file = next($files)) { @@ -477,7 +474,6 @@ protected function _canUseLocalModules() } if ($disableLocalModules === true) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found set_include_path( BP . DS . 'app' . DS . 'code' . DS . 'community' . PS . BP . DS . 'app' . DS . 'code' . DS . 'core' . PS . @@ -520,13 +516,13 @@ public function getCache() * * @return void * @throws Exception + * @SuppressWarnings(PHPMD.ExitExpression) */ public function getCacheSaveLock($waitTime = null, $ignoreFailure = false) { if (!Mage::app()->useCache('config')) { return; } - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $waitTime = $waitTime ?: (getenv('MAGE_CONFIG_CACHE_LOCK_WAIT') ?: (PHP_SAPI === 'cli' ? 60 : 3)); $connection = Mage::getSingleton('core/resource')->getConnection('core_write'); if (!$connection->fetchOne("SELECT GET_LOCK('core_config_cache_save_lock', ?)", [$waitTime])) { @@ -536,9 +532,7 @@ public function getCacheSaveLock($waitTime = null, $ignoreFailure = false) throw new Exception('Could not get lock on cache save operation.'); } else { Mage::log(sprintf('Failed to get cache save lock in %d seconds.', $waitTime), Zend_Log::NOTICE); - // phpcs:ignore Ecg.Security.IncludeFile.IncludeFileDetected require Mage::getBaseDir() . DS . 'errors' . DS . '503.php'; - // phpcs:ignore Ecg.Security.LanguageConstruct.ExitUsage die(); } } @@ -813,7 +807,6 @@ public function setNode($path, $value, $overwrite = true) protected function _getDeclaredModuleFiles() { $etcDir = $this->getOptions()->getEtcDir(); - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $moduleFiles = glob($etcDir . DS . 'modules' . DS . '*.xml'); if (!$moduleFiles) { @@ -827,7 +820,6 @@ protected function _getDeclaredModuleFiles() foreach ($moduleFiles as $v) { $name = explode(DIRECTORY_SEPARATOR, $v); - // phpcs:ignore Ecg.Performance.Loop.ArraySize $name = substr($name[count($name) - 1], 0, -4); if (array_key_exists($name, self::MAGE_MODULES)) { @@ -885,7 +877,6 @@ protected function _isAllowedModule($moduleName) * @param null $mergeConfig deprecated * @return $this|void */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass protected function _loadDeclaredModules($mergeConfig = null) { $moduleFiles = $this->_getDeclaredModuleFiles(); @@ -895,10 +886,8 @@ protected function _loadDeclaredModules($mergeConfig = null) Varien_Profiler::start('config/load-modules-declaration'); - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $unsortedConfig = new Mage_Core_Model_Config_Base(); $unsortedConfig->loadString(''); - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $fileConfig = new Mage_Core_Model_Config_Base(); // load modules declarations @@ -930,7 +919,6 @@ protected function _loadDeclaredModules($mergeConfig = null) $moduleDepends = $this->_sortModuleDepends($moduleDepends); // create sorted config - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $sortedConfig = new Mage_Core_Model_Config_Base(); $sortedConfig->loadString(''); @@ -1107,17 +1095,15 @@ public function getTempVarDir() * Get default server variables values * * @return array + * @SuppressWarnings(PHPMD.Superglobals) */ public function getDistroServerVars() { if (!$this->_distroServerVars) { - // phpcs:ignore Ecg.Security.Superglobal.SuperglobalUsageWarning if (isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['HTTP_HOST'])) { - // phpcs:ignore Ecg.Security.Superglobal.SuperglobalUsageWarning $secure = (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) || $_SERVER['SERVER_PORT'] == '443'; $scheme = ($secure ? 'https' : 'http') . '://' ; - // phpcs:ignore Ecg.Security.Superglobal.SuperglobalUsageWarning $hostArr = explode(':', $_SERVER['HTTP_HOST']); $host = $hostArr[0]; $port = isset( @@ -1334,7 +1320,6 @@ public function loadEventObservers($area) * @param array|string $args Module name if string * @return array */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function getPathVars($args = null) { $path = []; diff --git a/app/code/core/Mage/Core/Model/Config/Element.php b/app/code/core/Mage/Core/Model/Config/Element.php index 874746c32b1..498ec345d5d 100644 --- a/app/code/core/Mage/Core/Model/Config/Element.php +++ b/app/code/core/Mage/Core/Model/Config/Element.php @@ -25,6 +25,7 @@ class Mage_Core_Model_Config_Element extends Varien_Simplexml_Element * @param string $var * @param string|true $value * @return bool + * @SuppressWarnings(PHPMD.ShortMethodName) */ public function is($var, $value = true) { diff --git a/app/code/core/Mage/Core/Model/Config/Options.php b/app/code/core/Mage/Core/Model/Config/Options.php index 337b35abd1c..25256984127 100644 --- a/app/code/core/Mage/Core/Model/Config/Options.php +++ b/app/code/core/Mage/Core/Model/Config/Options.php @@ -1,4 +1,5 @@ _initMergerDir('js', true); - $result = (bool)$this->_initMergerDir('css', true) && $result; - return (bool)$this->_initMergerDir('css_secure', true) && $result; + $result = $this->_initMergerDir('css', true) && $result; + return $this->_initMergerDir('css_secure', true) && $result; } /** @@ -806,7 +815,6 @@ public function cleanMergedJsCss() */ protected function _initMergerDir($dirRelativeName, $cleanup = false) { - $mediaDir = Mage::getBaseDir('media'); try { $dir = Mage::getBaseDir('media') . DS . $dirRelativeName; if ($cleanup) { diff --git a/app/code/core/Mage/Core/Model/Email/Queue.php b/app/code/core/Mage/Core/Model/Email/Queue.php index 358324aaa5c..8b0018cb3ca 100644 --- a/app/code/core/Mage/Core/Model/Email/Queue.php +++ b/app/code/core/Mage/Core/Model/Email/Queue.php @@ -33,9 +33,9 @@ * @method string getMessageBodyHash() * @method string getMessageBody() * @method $this setMessageBody(string $value) - * @method $this setMessageBodyHash(array $value) - * @method array getMessageParameters() - * @method $this setMessageParameters(array $value) + * @method $this setMessageBodyHash(string $value) + * @method string getMessageParameters() + * @method $this setMessageParameters(string $value) * @method $this setProcessedAt(string $value) */ class Mage_Core_Model_Email_Queue extends Mage_Core_Model_Abstract @@ -118,8 +118,8 @@ public function addMessageToQueue() * @param array|string $emails * @param array|string|null $names * @param int $type - * * @return $this + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function addRecipients($emails, $names = null, $type = self::EMAIL_TYPE_TO) { @@ -242,7 +242,9 @@ public function send() unset($mailer); $message->setProcessedAt(Varien_Date::formatDate(true)); - $message->save(); // save() is throwing exception when recipient is not set + // save() is throwing exception when recipient is not set + // phpcs:ignore Ecg.Performance.Loop.ModelLSD + $message->save(); foreach ($message->getRecipients() as $recipient) { list($email, $name, $type) = $recipient; diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index eb46e4e4aca..16d22d9d332 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -228,8 +228,8 @@ protected function _generateBlock($node, $parent) } $blockName = (string)$node['name']; - $_profilerKey = 'BLOCK: ' . $blockName; - Varien_Profiler::start($_profilerKey); + $profilerKey = 'BLOCK: ' . $blockName; + Varien_Profiler::start($profilerKey); $block = $this->addBlock($className, $blockName); if (!$block) { @@ -270,7 +270,7 @@ protected function _generateBlock($node, $parent) $method = (string)$node['output']; $this->addOutputBlock($blockName, $method); } - Varien_Profiler::stop($_profilerKey); + Varien_Profiler::stop($profilerKey); return $this; } @@ -295,8 +295,8 @@ protected function _generateAction($node, $parent) $parentName = $parent->getBlockName(); } - $_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method; - Varien_Profiler::start($_profilerKey); + $profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method; + Varien_Profiler::start($profilerKey); if (!empty($parentName)) { $block = $this->getBlock($parentName); @@ -313,7 +313,6 @@ protected function _generateAction($node, $parent) $helperName = implode('/', $helperName); $arg = $arg->asArray(); unset($arg['@']); - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $args[$key] = call_user_func_array([Mage::helper($helperName), $helperMethod], $arg); } else { /** @@ -344,11 +343,10 @@ protected function _generateAction($node, $parent) Mage::helper('core/security')->validateAgainstBlockMethodBlacklist($block, $method, $args); $this->_translateLayoutNode($node, $args); - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found call_user_func_array([$block, $method], array_values($args)); } - Varien_Profiler::stop($_profilerKey); + Varien_Profiler::stop($profilerKey); return $this; } @@ -358,7 +356,6 @@ protected function _generateAction($node, $parent) * @param string[] $args * @throws Mage_Core_Exception */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed protected function validateAgainstBlacklist(Mage_Core_Block_Abstract $block, $method, array $args) { foreach ($this->invalidActions as $action) { @@ -394,7 +391,6 @@ protected function _translateLayoutNode($node, &$args) $argumentHierarchy = explode('.', $translatableArgumentName); $argumentStack = &$args; $canTranslate = true; - // phpcs:ignore Ecg.Performance.Loop.ArraySize while (is_array($argumentStack) && count($argumentStack) > 0) { $argumentName = array_shift($argumentHierarchy); if (isset($argumentStack[$argumentName])) { @@ -466,7 +462,7 @@ public function createBlock($type, $name = '', array $attributes = []) } $name = 'ANONYMOUS_' . count($this->_blocks); } elseif (isset($this->_blocks[$name]) && Mage::getIsDeveloperMode()) { - //Mage::throwException(Mage::helper('core')->__('Block with name "%s" already exists', $name)); + Mage::throwException(Mage::helper('core')->__('Block with name "%s" already exists', $name)); } $block->setType($type); diff --git a/app/code/core/Mage/Core/Model/Layout/Update.php b/app/code/core/Mage/Core/Model/Layout/Update.php index eecf7bd2655..4774cab4af6 100644 --- a/app/code/core/Mage/Core/Model/Layout/Update.php +++ b/app/code/core/Mage/Core/Model/Layout/Update.php @@ -225,7 +225,7 @@ public function loadCache() } /** - * @return bool + * @return Mage_Core_Model_App|false */ public function saveCache() { @@ -341,8 +341,8 @@ public function fetchFileLayoutUpdates() */ public function fetchPackageLayoutUpdates($handle) { - $_profilerKey = 'layout/package_update: ' . $handle; - Varien_Profiler::start($_profilerKey); + $profilerKey = 'layout/package_update: ' . $handle; + Varien_Profiler::start($profilerKey); if (empty($this->_packageLayout)) { $this->fetchFileLayoutUpdates(); } @@ -351,7 +351,7 @@ public function fetchPackageLayoutUpdates($handle) $this->fetchRecursiveUpdates($updateXml); $this->addUpdate($updateXml->innerXml()); } - Varien_Profiler::stop($_profilerKey); + Varien_Profiler::stop($profilerKey); return true; } @@ -362,11 +362,11 @@ public function fetchPackageLayoutUpdates($handle) */ public function fetchDbLayoutUpdates($handle) { - $_profilerKey = 'layout/db_update: ' . $handle; - Varien_Profiler::start($_profilerKey); + $profilerKey = 'layout/db_update: ' . $handle; + Varien_Profiler::start($profilerKey); $updateStr = $this->_getUpdateString($handle); if (!$updateStr) { - Varien_Profiler::stop($_profilerKey); + Varien_Profiler::stop($profilerKey); return false; } $updateStr = '' . $updateStr . ''; @@ -376,7 +376,7 @@ public function fetchDbLayoutUpdates($handle) $this->fetchRecursiveUpdates($updateXml); $this->addUpdate($updateXml->innerXml()); - Varien_Profiler::stop($_profilerKey); + Varien_Profiler::stop($profilerKey); return true; } diff --git a/app/code/core/Mage/Core/Model/Locale.php b/app/code/core/Mage/Core/Model/Locale.php index fa406119c67..17ab75e6284 100644 --- a/app/code/core/Mage/Core/Model/Locale.php +++ b/app/code/core/Mage/Core/Model/Locale.php @@ -598,6 +598,7 @@ public function storeTimeStamp($store = null) * * @param string $currency * @return Zend_Currency + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function currency($currency) { diff --git a/app/code/core/Mage/Core/Model/Resource/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Abstract.php index 49a31cd7252..7f65617944d 100644 --- a/app/code/core/Mage/Core/Model/Resource/Abstract.php +++ b/app/code/core/Mage/Core/Model/Resource/Abstract.php @@ -69,6 +69,7 @@ public function beginTransaction() * * @param callable $callback * @return $this + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function addCommitCallback($callback) { @@ -81,6 +82,7 @@ public function addCommitCallback($callback) * Commit resource transaction * * @return $this + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function commit() { @@ -93,7 +95,7 @@ public function commit() if (isset(self::$_commitCallbacks[$adapterKey])) { $callbacks = self::$_commitCallbacks[$adapterKey]; self::$_commitCallbacks[$adapterKey] = []; - foreach ($callbacks as $index => $callback) { + foreach ($callbacks as $callback) { call_user_func($callback); } } @@ -105,6 +107,7 @@ public function commit() * Roll back resource transaction * * @return $this + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function rollBack() { diff --git a/app/code/core/Mage/Core/Model/Resource/Email/Queue.php b/app/code/core/Mage/Core/Model/Resource/Email/Queue.php index 8732876bafe..1c0195426d7 100644 --- a/app/code/core/Mage/Core/Model/Resource/Email/Queue.php +++ b/app/code/core/Mage/Core/Model/Resource/Email/Queue.php @@ -78,6 +78,7 @@ public function wasEmailQueued(Mage_Core_Model_Email_Queue $queue) ->where('queue.event_type =? ', $queue->getEventType()) ->where('queue.message_body_hash =? ', md5($queue->getMessageBody())); + // phpcs:ignore Ecg.Performance.FetchAll.Found $existingRecipients = $readAdapter->fetchAll($select); if ($existingRecipients) { $newRecipients = $queue->getRecipients(); @@ -120,6 +121,7 @@ public function getRecipients($messageId) $select = $readAdapter->select() ->from($this->getTable('core/email_recipients'), ['recipient_email', 'recipient_name', 'email_type']) ->where('message_id =? ', $messageId); + // phpcs:ignore Ecg.Performance.FetchAll.Found $recipients = $readAdapter->fetchAll($select); $existingRecipients = []; if ($recipients) { diff --git a/app/code/core/Mage/Core/Model/Resource/Resource.php b/app/code/core/Mage/Core/Model/Resource/Resource.php index e41f73a9773..5ae3eab6fc9 100644 --- a/app/code/core/Mage/Core/Model/Resource/Resource.php +++ b/app/code/core/Mage/Core/Model/Resource/Resource.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Core * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -49,6 +49,7 @@ protected function _construct() * * @param string $needType Can be 'db' or 'data' * @return $this + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ protected function _loadVersionData($needType) { @@ -61,8 +62,9 @@ protected function _loadVersionData($needType) if ($this->_getReadAdapter()->isTableExists($this->getMainTable())) { $select = $this->_getReadAdapter()->select() ->from($this->getMainTable(), '*'); - $rowset = $this->_getReadAdapter()->fetchAll($select); - foreach ($rowset as $row) { + // phpcs:ignore Ecg.Performance.FetchAll.Found + $rowSet = $this->_getReadAdapter()->fetchAll($select); + foreach ($rowSet as $row) { self::$_versions[$row['code']] = $row['version']; if (array_key_exists('data_version', $row)) { if (is_null(self::$_dataVersions)) { @@ -82,6 +84,7 @@ protected function _loadVersionData($needType) * * @param string $resName * @return bool|string + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function getDbVersion($resName) { @@ -98,6 +101,7 @@ public function getDbVersion($resName) * @param string $resName * @param string $version * @return int + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function setDbVersion($resName, $version) { @@ -124,6 +128,7 @@ public function setDbVersion($resName, $version) * * @param string $resName * @return string|false + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function getDataVersion($resName) { @@ -142,6 +147,7 @@ public function getDataVersion($resName) * @param string $resName * @param string $version * @return $this + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function setDataVersion($resName, $version) { diff --git a/app/code/core/Mage/Core/Model/Resource/Session.php b/app/code/core/Mage/Core/Model/Resource/Session.php index 955be87dd10..1530c69956c 100644 --- a/app/code/core/Mage/Core/Model/Resource/Session.php +++ b/app/code/core/Mage/Core/Model/Resource/Session.php @@ -72,7 +72,7 @@ public function __construct() } /** - * Destrucor + * Destructor * */ public function __destruct() @@ -258,6 +258,7 @@ public function destroy($sessId) * * @param int $sessMaxLifeTime ignored * @return bool + * @SuppressWarnings(PHPMD.ShortMethodName) */ #[\ReturnTypeWillChange] public function gc($sessMaxLifeTime) diff --git a/app/code/core/Mage/Core/Model/Session/Abstract.php b/app/code/core/Mage/Core/Model/Session/Abstract.php index efbf672fd39..4926c85ba00 100644 --- a/app/code/core/Mage/Core/Model/Session/Abstract.php +++ b/app/code/core/Mage/Core/Model/Session/Abstract.php @@ -357,13 +357,14 @@ public function addUniqueMessages($messages) * Specify session identifier * * @inheritDoc + * @SuppressWarnings(PHPMD.Superglobals) */ public function setSessionId($id = null) { if (is_null($id) && $this->useSid()) { - $_queryParam = $this->getSessionIdQueryParam(); - if (isset($_GET[$_queryParam]) && Mage::getSingleton('core/url')->isOwnOriginUrl()) { - $id = $_GET[$_queryParam]; + $queryParam = $this->getSessionIdQueryParam(); + if (isset($_GET[$queryParam]) && Mage::getSingleton('core/url')->isOwnOriginUrl()) { + $id = $_GET[$queryParam]; } } @@ -390,8 +391,8 @@ public function getEncryptedSessionId() */ public function getSessionIdQueryParam() { - $_sessionName = $this->getSessionName(); - if ($_sessionName && $queryParam = (string)Mage::getConfig()->getNode($_sessionName . '/session/query_param')) { + $sessionName = $this->getSessionName(); + if ($sessionName && $queryParam = (string)Mage::getConfig()->getNode($sessionName . '/session/query_param')) { return $queryParam; } return self::SESSION_ID_QUERY_PARAM; @@ -424,6 +425,7 @@ public function getSkipSessionIdFlag() * * @param string $urlHost can be host or url * @return string {session_id_key}={session_id_encrypted} + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function getSessionIdForHost($urlHost) { @@ -561,6 +563,7 @@ public function renewSession() foreach (array_keys($sessionHosts) as $host) { // Delete cookies with the same name for parent domains if (strpos($currentCookieDomain, $host) > 0) { + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $this->getCookie()->delete($this->getSessionName(), null, $host); } } diff --git a/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php b/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php index 47e40c60ee2..f9feab235e3 100644 --- a/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php +++ b/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php @@ -49,6 +49,9 @@ class Mage_Core_Model_Session_Abstract_Varien extends Varien_Object * * @param string $sessionName * @return $this + * @throws Mage_Core_Model_Store_Exception + * @SuppressWarnings(PHPMD.Superglobals) + * @SuppressWarnings(PHPMD.ExitExpression) */ public function start($sessionName = null) { @@ -200,6 +203,7 @@ public function start($sessionName = null) foreach (array_keys($sessionHosts) as $host) { // Delete cookies with the same name for parent domains if (strpos($currentCookieDomain, $host) > 0) { + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $cookie->delete($this->getSessionName(), null, $host); } } @@ -265,6 +269,7 @@ public function revalidateCookie() * @param string $namespace * @param string $sessionName * @return $this + * @SuppressWarnings(PHPMD.Superglobals) */ public function init($namespace, $sessionName = null) { @@ -462,6 +467,7 @@ public function getValidateHttpUserAgentSkip() * * @throws Mage_Core_Model_Session_Exception * @return $this + * @SuppressWarnings(PHPMD.Superglobals) */ public function validate() { @@ -495,6 +501,7 @@ public function validate() * * @param int $timestamp * @return void + * @SuppressWarnings(PHPMD.Superglobals) */ public function setValidatorSessionRenewTimestamp($timestamp) { @@ -505,6 +512,7 @@ public function setValidatorSessionRenewTimestamp($timestamp) * Validate data * * @return bool + * @SuppressWarnings(PHPMD.Superglobals) */ protected function _validate() { @@ -564,6 +572,7 @@ protected function _validate() * Retrieve unique user data for validator * * @return array + * @SuppressWarnings(PHPMD.Superglobals) */ public function getValidatorData() { @@ -601,6 +610,7 @@ public function getValidatorData() /** * @return array + * @SuppressWarnings(PHPMD.Superglobals) */ public function getSessionValidatorData() { diff --git a/app/code/core/Mage/Core/Model/Store.php b/app/code/core/Mage/Core/Model/Store.php index 688f4e25ae9..5d66743c18e 100644 --- a/app/code/core/Mage/Core/Model/Store.php +++ b/app/code/core/Mage/Core/Model/Store.php @@ -538,6 +538,7 @@ public function processSubst($value) * Retrieve default base path * * @return string + * @SuppressWarnings(PHPMD.Superglobals) */ public function getDefaultBasePath() { @@ -627,6 +628,7 @@ public function getBaseUrl($type = self::URL_TYPE_LINK, $secure = null) * * @param string $url * @return string + * @SuppressWarnings(PHPMD.Superglobals) */ protected function _updatePathUseRewrites($url) { diff --git a/app/code/core/Mage/Core/Model/Translate.php b/app/code/core/Mage/Core/Model/Translate.php index 3ea3836aea8..7e810ac0cb2 100644 --- a/app/code/core/Mage/Core/Model/Translate.php +++ b/app/code/core/Mage/Core/Model/Translate.php @@ -383,6 +383,7 @@ public function getTranslate() * * @param array $args * @return string + * @SuppressWarnings(PHPMD.Superglobals) */ public function translate($args) { @@ -468,13 +469,15 @@ public function getTemplateFile($file, $type, $localeCode = null) $filePath = Mage::getBaseDir('locale') . DS . $localeCode . DS . 'template' . DS . $type . DS . $file; - if (!file_exists($filePath)) { // If no template specified for this locale, use store default + // If no template specified for this locale, use store default + if (!file_exists($filePath)) { $filePath = Mage::getBaseDir('locale') . DS . Mage::app()->getLocale()->getDefaultLocale() . DS . 'template' . DS . $type . DS . $file; } - if (!file_exists($filePath)) { // If no template specified as store default locale, use en_US + // If no template specified as store default locale, use en_US + if (!file_exists($filePath)) { $filePath = Mage::getBaseDir('locale') . DS . Mage_Core_Model_Locale::DEFAULT_LOCALE . DS . 'template' . DS . $type . DS . $file; diff --git a/app/code/core/Mage/Core/Model/Translate/Inline.php b/app/code/core/Mage/Core/Model/Translate/Inline.php index a15bf1c4b2c..c356d2ef766 100644 --- a/app/code/core/Mage/Core/Model/Translate/Inline.php +++ b/app/code/core/Mage/Core/Model/Translate/Inline.php @@ -241,9 +241,9 @@ protected function _insertInlineScriptsHtml() } $baseJsUrl = Mage::getBaseUrl('js'); - $url_prefix = Mage::app()->getStore()->isAdmin() ? 'adminhtml' : 'core'; + $urlPrefix = Mage::app()->getStore()->isAdmin() ? 'adminhtml' : 'core'; $ajaxUrl = Mage::getUrl( - $url_prefix . '/ajax/translate', + $urlPrefix . '/ajax/translate', ['_secure' => Mage::app()->getStore()->isCurrentlySecure()] ); $trigImg = Mage::getDesign()->getSkinUrl('images/fam_book_open.png'); @@ -504,6 +504,7 @@ protected function _translateTags(&$content, $tagsList, $formatCallback, $isNeed * @param int $from * @return false|int return false if end of tag is not found */ + // phpcs:ignore Ecg.PHP.PrivateClassMember.PrivateClassMemberError private function findEndOfTag($body, $tagName, $from) { $openTag = '<' . $tagName; diff --git a/app/code/core/Mage/Core/Model/Url.php b/app/code/core/Mage/Core/Model/Url.php index aa75dae645c..097127a9a6b 100644 --- a/app/code/core/Mage/Core/Model/Url.php +++ b/app/code/core/Mage/Core/Model/Url.php @@ -258,6 +258,7 @@ public function getDefaultActionName() * @param string $key * @param string|null $prefix * @return string + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function getConfigData($key, $prefix = null) { @@ -951,7 +952,7 @@ public function getFragment() * * @param string|null $routePath * @param array|null $routeParams - * @return string + * @return string */ public function getUrl($routePath = null, $routeParams = null) { diff --git a/app/code/core/Mage/Core/Model/Url/Rewrite.php b/app/code/core/Mage/Core/Model/Url/Rewrite.php index ff4c7be2c92..dd7757c304b 100644 --- a/app/code/core/Mage/Core/Model/Url/Rewrite.php +++ b/app/code/core/Mage/Core/Model/Url/Rewrite.php @@ -204,6 +204,7 @@ public function removeTag($tags) * @return bool * @throws Mage_Core_Model_Store_Exception * @deprecated since 1.7.0.2. Refactored and moved to Mage_Core_Controller_Request_Rewrite + * @SuppressWarnings(PHPMD.Superglobals) */ public function rewrite(?Zend_Controller_Request_Http $request = null, ?Zend_Controller_Response_Http $response = null) { @@ -310,6 +311,7 @@ public function rewrite(?Zend_Controller_Request_Http $request = null, ?Zend_Con * * @return bool|string * @deprecated since 1.7.0.2. Refactored and moved to Mage_Core_Controller_Request_Rewrite + * @SuppressWarnings(PHPMD.Superglobals) */ protected function _getQueryString() { @@ -346,6 +348,7 @@ public function getStoreId() * @param string $url * @param bool $isPermanent * @deprecated since 1.7.0.2. Refactored and moved to Mage_Core_Controller_Request_Rewrite + * @SuppressWarnings(PHPMD.ExitExpression) */ protected function _sendRedirectHeaders($url, $isPermanent = false) { diff --git a/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php b/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php index b3e07478949..a2313bf5255 100644 --- a/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php +++ b/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php @@ -280,6 +280,7 @@ protected function _getRequestCases() * * @param string $url * @param bool $isPermanent + * @SuppressWarnings(PHPMD.ExitExpression) */ protected function _sendRedirectHeaders($url, $isPermanent = false) { @@ -297,6 +298,7 @@ protected function _sendRedirectHeaders($url, $isPermanent = false) * Prepare and return QUERY_STRING * * @return bool|string + * @SuppressWarnings(PHPMD.Superglobals) */ protected function _getQueryString() { diff --git a/app/code/core/Mage/Core/functions.php b/app/code/core/Mage/Core/functions.php index 3adfd6f55ea..a25f79beb85 100644 --- a/app/code/core/Mage/Core/functions.php +++ b/app/code/core/Mage/Core/functions.php @@ -33,6 +33,7 @@ function destruct($object) * * @return string * @deprecated 1.3 + * @SuppressWarnings(PHPMD.ShortMethodName) */ function __() { @@ -294,7 +295,7 @@ function mageParseCsv($string, $delimiter = ',', $enclosure = '"', $escape = '\\ * * @SuppressWarnings(PHPMD.ErrorControlOperator) */ -function is_dir_writeable($dir) +function isDirWriteable($dir) { if (is_dir($dir) && is_writable($dir)) { if (stripos(PHP_OS, 'win') === 0) { @@ -314,3 +315,20 @@ function is_dir_writeable($dir) } return false; } + + +/** + * @param string $dir + * @return bool + * @deprecated avoid php_codesniffer error + * + * An error occurred during processing; checking has been aborted. The error message was: Undefined index: ^is_dir/i_writeab in + * /var/www/html/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php on line 228 + * The error originated in the Generic.PHP.ForbiddenFunctions sniff on line 228. (Internal.Exception) + * + * @see isDirWriteable() + */ +function is_dir_writeable($dir) +{ + return isDirWriteable($dir); +} diff --git a/app/code/core/Mage/Customer/Model/Address/Abstract.php b/app/code/core/Mage/Customer/Model/Address/Abstract.php index 1e0e511d303..3ac414a5660 100644 --- a/app/code/core/Mage/Customer/Model/Address/Abstract.php +++ b/app/code/core/Mage/Customer/Model/Address/Abstract.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Customer * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -333,6 +333,7 @@ public function getCountry() * Retrieve country model * * @return Mage_Directory_Model_Country + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function getCountryModel() { @@ -349,6 +350,7 @@ public function getCountryModel() * * @param int|null $region * @return Mage_Directory_Model_Country + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function getRegionModel($region = null) { @@ -467,8 +469,8 @@ protected function _basicCheck() $this->addError(Mage::helper('customer')->__('Please enter the telephone number.')); } - $_havingOptionalZip = Mage::helper('directory')->getCountriesWithOptionalZip(); - if (!in_array($this->getCountryId(), $_havingOptionalZip) + $havingOptionalZip = Mage::helper('directory')->getCountriesWithOptionalZip(); + if (!in_array($this->getCountryId(), $havingOptionalZip) && !Zend_Validate::is($this->getPostcode(), 'NotEmpty') ) { $this->addError(Mage::helper('customer')->__('Please enter the zip/postal code.')); diff --git a/app/code/core/Mage/Customer/Model/Customer.php b/app/code/core/Mage/Customer/Model/Customer.php index fac6296d381..cff14a60c72 100644 --- a/app/code/core/Mage/Customer/Model/Customer.php +++ b/app/code/core/Mage/Customer/Model/Customer.php @@ -31,11 +31,11 @@ * @method int getCustomerId() * @method $this setCustomerId(int|null $value) * - * @method int getDefaultBilling() - * @method $this setDefaultBilling(int $value) + * @method int|null getDefaultBilling() + * @method $this setDefaultBilling(int|null $value) * @method $this unsetDefaultBilling() - * @method int getDefaultShipping() - * @method $this setDefaultShipping(int $value) + * @method int|null getDefaultShipping() + * @method $this setDefaultShipping(int|null $value) * @method $this unsetDefaultShipping() * @method int getDisableAutoGroupChange() * @method string getDob() @@ -334,7 +334,6 @@ public function changePassword($newPassword) public function setPasswordCreatedAt($time) { $this->setData('password_created_at', $time); - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if (session_status() === PHP_SESSION_ACTIVE) { Mage::getSingleton('checkout/session')->setValidatorSessionRenewTimestamp($time); } diff --git a/app/code/core/Mage/Customer/Model/Customer/Api/V2.php b/app/code/core/Mage/Customer/Model/Customer/Api/V2.php index 570d2cb6342..e524c1bb2b8 100644 --- a/app/code/core/Mage/Customer/Model/Customer/Api/V2.php +++ b/app/code/core/Mage/Customer/Model/Customer/Api/V2.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Customer * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -30,8 +30,8 @@ class Mage_Customer_Model_Customer_Api_V2 extends Mage_Customer_Model_Customer_A */ protected function _prepareData($data) { - if (($_data = get_object_vars($data)) !== null) { - return parent::_prepareData($_data); + if (($objectVars = get_object_vars($data)) !== null) { + return parent::_prepareData($objectVars); } return []; } diff --git a/app/code/core/Mage/Customer/Model/Group.php b/app/code/core/Mage/Customer/Model/Group.php index 8d1ba82ecda..f8867fecfd6 100644 --- a/app/code/core/Mage/Customer/Model/Group.php +++ b/app/code/core/Mage/Customer/Model/Group.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Customer * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -89,6 +89,7 @@ public function getCode() /** * @param int|null $groupId * @return int + * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function getTaxClassId($groupId = null) { diff --git a/app/code/core/Mage/Dataflow/Model/Convert/Adapter/Http.php b/app/code/core/Mage/Dataflow/Model/Convert/Adapter/Http.php index 9e071963524..63496e85fb7 100644 --- a/app/code/core/Mage/Dataflow/Model/Convert/Adapter/Http.php +++ b/app/code/core/Mage/Dataflow/Model/Convert/Adapter/Http.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Dataflow * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -21,6 +21,10 @@ */ class Mage_Dataflow_Model_Convert_Adapter_Http extends Mage_Dataflow_Model_Convert_Adapter_Abstract { + /** + * @SuppressWarnings(PHPMD.ExitExpression) + * @SuppressWarnings(PHPMD.Superglobals) + */ public function load() { if (!$_FILES) { @@ -46,7 +50,12 @@ public function save() return $this; } - // experimental code + /** + * Experimental code + * + * @SuppressWarnings(PHPMD.ExitExpression) + * @SuppressWarnings(PHPMD.Superglobals) + */ public function loadFile() { if (!$_FILES) { diff --git a/app/code/core/Mage/Dataflow/Model/Convert/Iterator/Http.php b/app/code/core/Mage/Dataflow/Model/Convert/Iterator/Http.php index 1c98221d119..fc1ff3c363d 100644 --- a/app/code/core/Mage/Dataflow/Model/Convert/Iterator/Http.php +++ b/app/code/core/Mage/Dataflow/Model/Convert/Iterator/Http.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Dataflow * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -21,6 +21,10 @@ */ class Mage_Dataflow_Model_Convert_Iterator_Http extends Mage_Dataflow_Model_Convert_Adapter_Abstract { + /** + * @SuppressWarnings(PHPMD.ExitExpression) + * @SuppressWarnings(PHPMD.Superglobals) + */ public function load() { if (!$_FILES) { diff --git a/app/code/core/Mage/Dataflow/Model/Convert/Profile/Abstract.php b/app/code/core/Mage/Dataflow/Model/Convert/Profile/Abstract.php index 967536f4ca8..6d5fbe75cca 100644 --- a/app/code/core/Mage/Dataflow/Model/Convert/Profile/Abstract.php +++ b/app/code/core/Mage/Dataflow/Model/Convert/Profile/Abstract.php @@ -17,6 +17,7 @@ * * @category Mage * @package Mage_Dataflow + * @SuppressWarnings(PHPMD.CamelCasePropertyName) */ abstract class Mage_Dataflow_Model_Convert_Profile_Abstract implements Mage_Dataflow_Model_Convert_Profile_Interface { diff --git a/app/code/core/Mage/Dataflow/Model/Convert/Profile/Collection.php b/app/code/core/Mage/Dataflow/Model/Convert/Profile/Collection.php index b9927e8ad64..d45efefe6de 100644 --- a/app/code/core/Mage/Dataflow/Model/Convert/Profile/Collection.php +++ b/app/code/core/Mage/Dataflow/Model/Convert/Profile/Collection.php @@ -90,6 +90,9 @@ public function getClassNameByType($type) return $type; } + /** + * @SuppressWarnings(PHPMD.ErrorControlOperator) + */ public function importXml($xml) { if (is_string($xml)) { diff --git a/app/code/core/Mage/Dataflow/Model/Profile.php b/app/code/core/Mage/Dataflow/Model/Profile.php index 419e1ba4268..37b2678ade5 100644 --- a/app/code/core/Mage/Dataflow/Model/Profile.php +++ b/app/code/core/Mage/Dataflow/Model/Profile.php @@ -29,8 +29,8 @@ * @method $this setUpdatedAt(string $value) * @method string getActionsXml() * @method $this setActionsXml(string $value) - * @method string getGuiData() - * @method $this setGuiData(string $value) + * @method array|string getGuiData() + * @method $this setGuiData(array|string $value) * @method string getDirection() * @method $this setDirection(string $value) * @method string getEntityType() @@ -82,6 +82,9 @@ protected function _afterLoad() return parent::_afterLoad(); } + /** + * @SuppressWarnings(PHPMD.ErrorControlOperator) + */ protected function _beforeSave() { parent::_beforeSave(); @@ -136,6 +139,9 @@ protected function _beforeSave() return $this; } + /** + * @SuppressWarnings(PHPMD.Superglobals) + */ protected function _afterSave() { if ($this->getGuiData() && is_string($this->getGuiData())) { @@ -214,7 +220,7 @@ protected function _afterSave() } $colsAbsent = array_diff($attributes, $fileData); if ($colsAbsent) { - foreach ($newUploadedFilenames as $k => $v) { + foreach ($newUploadedFilenames as $v) { unlink($path . $v); } unlink($path . $uploadFile); diff --git a/app/code/core/Mage/Dataflow/Model/Session/Adapter/Http.php b/app/code/core/Mage/Dataflow/Model/Session/Adapter/Http.php index 971361a50fa..614010fd1d1 100644 --- a/app/code/core/Mage/Dataflow/Model/Session/Adapter/Http.php +++ b/app/code/core/Mage/Dataflow/Model/Session/Adapter/Http.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Dataflow * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -21,6 +21,10 @@ */ class Mage_Dataflow_Model_Session_Adapter_Http extends Mage_Dataflow_Model_Convert_Adapter_Abstract { + /** + * @SuppressWarnings(PHPMD.ExitExpression) + * @SuppressWarnings(PHPMD.Superglobals) + */ public function load() { if (!$_FILES) { diff --git a/app/code/core/Mage/Directory/Model/Currency/Import/Abstract.php b/app/code/core/Mage/Directory/Model/Currency/Import/Abstract.php index cfa52f5789d..c2a72a21ac1 100644 --- a/app/code/core/Mage/Directory/Model/Currency/Import/Abstract.php +++ b/app/code/core/Mage/Directory/Model/Currency/Import/Abstract.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Directory * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -84,6 +84,7 @@ public function importRates() /** * @return array + * @SuppressWarnings(PHPMD.ErrorControlOperator) */ public function fetchRates() { diff --git a/app/code/core/Mage/Directory/Model/Currency/Import/Currencyconverterapi.php b/app/code/core/Mage/Directory/Model/Currency/Import/Currencyconverterapi.php index e4898c30002..78ff979cbf5 100644 --- a/app/code/core/Mage/Directory/Model/Currency/Import/Currencyconverterapi.php +++ b/app/code/core/Mage/Directory/Model/Currency/Import/Currencyconverterapi.php @@ -96,6 +96,7 @@ public function fetchRates() * * @param string $currencyFrom * @return array + * @SuppressWarnings(PHPMD.ErrorControlOperator) */ protected function _convertBatch(array $data, $currencyFrom, array $currenciesTo) { diff --git a/app/code/core/Mage/Directory/Model/Currency/Import/Fixerio.php b/app/code/core/Mage/Directory/Model/Currency/Import/Fixerio.php index 3022812bc0b..8ebb54f61f2 100644 --- a/app/code/core/Mage/Directory/Model/Currency/Import/Fixerio.php +++ b/app/code/core/Mage/Directory/Model/Currency/Import/Fixerio.php @@ -96,6 +96,7 @@ public function fetchRates() * * @param string $currencyFrom * @return array + * @SuppressWarnings(PHPMD.ErrorControlOperator) */ protected function _convertBatch(array $data, $currencyFrom, array $currenciesTo) { diff --git a/app/code/core/Mage/Directory/Model/Resource/Country/Collection.php b/app/code/core/Mage/Directory/Model/Resource/Country/Collection.php index 3fc6da5a682..e53a459c031 100644 --- a/app/code/core/Mage/Directory/Model/Resource/Country/Collection.php +++ b/app/code/core/Mage/Directory/Model/Resource/Country/Collection.php @@ -87,8 +87,8 @@ public function addCountryCodeFilter($countryCode, $iso = ['iso3', 'iso2']) if (is_array($countryCode)) { if (is_array($iso)) { $whereOr = []; - foreach ($iso as $iso_curr) { - $whereOr[] = $this->_getConditionSql("{$iso_curr}_code", ['in' => $countryCode]); + foreach ($iso as $isoType) { + $whereOr[] = $this->_getConditionSql("{$isoType}_code", ['in' => $countryCode]); } $this->_select->where('(' . implode(') OR (', $whereOr) . ')'); } else { @@ -97,8 +97,8 @@ public function addCountryCodeFilter($countryCode, $iso = ['iso3', 'iso2']) } else { if (is_array($iso)) { $whereOr = []; - foreach ($iso as $iso_curr) { - $whereOr[] = $this->_getConditionSql("{$iso_curr}_code", $countryCode); + foreach ($iso as $isoType) { + $whereOr[] = $this->_getConditionSql("{$isoType}_code", $countryCode); } $this->_select->where('(' . implode(') OR (', $whereOr) . ')'); } else { diff --git a/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php b/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php index 4ffac400ffc..f2ca2aebdbc 100644 --- a/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php +++ b/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Downloadable * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -61,10 +61,10 @@ public function getProduct() public function getPurchasedSeparatelyAttribute() { if ($this->_purchasedSeparatelyAttribute === null) { - $_attributeCode = 'links_purchased_separately'; + $attributeCode = 'links_purchased_separately'; $attribute = Mage::getSingleton('eav/config') - ->getAttribute(Mage_Catalog_Model_Product::ENTITY, $_attributeCode); + ->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode); if (!($attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute)) { Mage::throwException('Attribute links_purchased_separately must be of type Mage_Catalog_Model_Resource_Eav_Attribute'); } diff --git a/app/code/core/Mage/Downloadable/Block/Customer/Products/List.php b/app/code/core/Mage/Downloadable/Block/Customer/Products/List.php index 2e63b136f27..44ca508452b 100644 --- a/app/code/core/Mage/Downloadable/Block/Customer/Products/List.php +++ b/app/code/core/Mage/Downloadable/Block/Customer/Products/List.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Downloadable * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -40,9 +40,9 @@ public function __construct() ->addOrder('created_at', 'desc'); $this->setPurchased($purchased); $purchasedIds = []; - /** @var Mage_Downloadable_Model_Link_Purchased_Item $_item */ - foreach ($purchased as $_item) { - $purchasedIds[] = $_item->getId(); + /** @var Mage_Downloadable_Model_Link_Purchased_Item $item */ + foreach ($purchased as $item) { + $purchasedIds[] = $item->getId(); } if (empty($purchasedIds)) { $purchasedIds = [null]; diff --git a/app/code/core/Mage/Downloadable/Helper/Download.php b/app/code/core/Mage/Downloadable/Helper/Download.php index edae6bc8619..75da0d57c80 100644 --- a/app/code/core/Mage/Downloadable/Helper/Download.php +++ b/app/code/core/Mage/Downloadable/Helper/Download.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Downloadable * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -214,6 +214,7 @@ public function getContentType() /** * @return bool|mixed|string * @throws Exception + * @SuppressWarnings(PHPMD.ErrorControlOperator) */ public function getFilename() { diff --git a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php index c2476279318..20b0bb9a77c 100644 --- a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php +++ b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Downloadable * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -100,9 +100,9 @@ public function draw() ]; // draw options value - $_printValue = $option['print_value'] ?? strip_tags($option['value']); + $printValue = $option['print_value'] ?? strip_tags($option['value']); $lines[][] = [ - 'text' => Mage::helper('core/string')->str_split($_printValue, 30, true, true), + 'text' => Mage::helper('core/string')->str_split($printValue, 30, true, true), 'feed' => 40 ]; } diff --git a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php index ba9a9724e09..7eda6d4e45c 100644 --- a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php +++ b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Downloadable * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -111,8 +111,8 @@ public function draw() ]; if ($option['value']) { - $_printValue = $option['print_value'] ?? strip_tags($option['value']); - $values = explode(', ', $_printValue); + $printValue = $option['print_value'] ?? strip_tags($option['value']); + $values = explode(', ', $printValue); foreach ($values as $value) { $lines[][] = [ 'text' => Mage::helper('core/string')->str_split($value, 30, true, true), diff --git a/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php b/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php index b0e86a22a5e..723694cf05e 100644 --- a/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php +++ b/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/Product/EditController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Downloadable * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -84,6 +84,7 @@ protected function _processDownload($resource, $resourceType) /** * Download link action * + * @SuppressWarnings(PHPMD.ExitExpression) */ public function linkAction() { diff --git a/app/code/core/Mage/Downloadable/controllers/DownloadController.php b/app/code/core/Mage/Downloadable/controllers/DownloadController.php index 4739bd0eba1..878c7cc2f91 100644 --- a/app/code/core/Mage/Downloadable/controllers/DownloadController.php +++ b/app/code/core/Mage/Downloadable/controllers/DownloadController.php @@ -82,6 +82,7 @@ protected function _processDownload($resource, $resourceType) /** * Download sample action * + * @SuppressWarnings(PHPMD.ExitExpression) */ public function sampleAction() { @@ -117,6 +118,7 @@ public function sampleAction() /** * Download link's sample action * + * @SuppressWarnings(PHPMD.ExitExpression) */ public function linkSampleAction() { @@ -151,6 +153,9 @@ public function linkSampleAction() /** * Download link action + * + * @return Mage_Core_Controller_Varien_Action|void + * @SuppressWarnings(PHPMD.ExitExpression) */ public function linkAction() { @@ -175,7 +180,7 @@ public function linkAction() Mage::getUrl('downloadable/customer/products/'), ['_secure' => true] ); - return ; + return; } $linkPurchased = Mage::getModel('downloadable/link_purchased')->load($linkPurchasedItem->getPurchasedId()); if ($linkPurchased->getCustomerId() != $customerId) { diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/File.php b/app/code/core/Mage/Eav/Model/Attribute/Data/File.php index 2c5814708a1..4eb7fa9b65e 100644 --- a/app/code/core/Mage/Eav/Model/Attribute/Data/File.php +++ b/app/code/core/Mage/Eav/Model/Attribute/Data/File.php @@ -32,6 +32,7 @@ class Mage_Eav_Model_Attribute_Data_File extends Mage_Eav_Model_Attribute_Data_A * Extract data from request and return value * * @return false|array|string + * @SuppressWarnings(PHPMD.Superglobals) */ public function extractValue(Zend_Controller_Request_Http $request) { diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Abstract.php index d83e627976e..03b4d1c530c 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Abstract.php @@ -635,7 +635,6 @@ public function walkAttributes($partMethod, array $args = []) } try { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $results[$attrCode] = call_user_func_array([$instance, $method], $args); } catch (Mage_Eav_Model_Entity_Attribute_Exception $e) { throw $e; @@ -657,7 +656,6 @@ public function walkAttributes($partMethod, array $args = []) * @param array $args array of arguments * @return bool */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed protected function _isCallableAttributeInstance($instance, $method, $args) { if (!is_object($instance) || !method_exists($instance, $method)) { @@ -1008,7 +1006,6 @@ protected function _prepareLoadSelect(array $selects) * @param mixed $rowId * @return Zend_Db_Select */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed protected function _getLoadRowSelect($object, $rowId) { return $this->_getReadAdapter()->select() @@ -1221,7 +1218,6 @@ protected function _collectSaveData($newObject) * @param mixed $v New value of the attribute. Can be used in subclasses. * @return bool */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed protected function _canUpdateAttribute(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $v, array &$origData) { return array_key_exists($attribute->getAttributeCode(), $origData); @@ -1394,7 +1390,6 @@ protected function _insertAttribute($object, $attribute, $value) * @param mixed $value * @return $this */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed protected function _updateAttribute($object, $attribute, $valueId, $value) { return $this->_saveAttribute($object, $attribute, $value); @@ -1489,7 +1484,6 @@ protected function _prepareValueForSave($value, Mage_Eav_Model_Entity_Attribute_ * @param array $info * @return $this */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed protected function _deleteAttributes($object, $table, $info) { $valueIds = []; diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php index b205c45eb37..82971ead7ee 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Eav * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2018-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2018-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -83,16 +83,16 @@ public function getOptionText($value) */ public function getOptionId($value) { - $bc_warning = false; + $bcWarning = false; foreach ($this->getAllOptions() as $option) { if (strcasecmp($option['label'], $value) == 0) { return $option['value']; } if ($option['value'] == $value) { - $bc_warning = true; + $bcWarning = true; } } - if ($bc_warning) { + if ($bcWarning) { Mage::log( 'Mage_Eav_Model_Entity_Attribute_Source_Abstract::getOptionId() no longer accepts option_id as param', Zend_Log::WARN diff --git a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php index ca051e96c18..ec43b35dea4 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php @@ -106,7 +106,6 @@ abstract class Mage_Eav_Model_Entity_Collection_Abstract extends Varien_Data_Col * * @param Mage_Core_Model_Resource_Abstract $resource */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function __construct($resource = null) { parent::__construct(); @@ -188,6 +187,7 @@ protected function _init($model, $entityModel = null) * @param Mage_Eav_Model_Entity_Abstract $entity * @throws Mage_Eav_Exception * @return $this + * @SuppressWarnings(PHPMD.DevelopmentCodeFragment) */ public function setEntity($entity) { @@ -196,7 +196,6 @@ public function setEntity($entity) } elseif (is_string($entity) || $entity instanceof Mage_Core_Model_Config_Element) { $this->_entity = Mage::getModel('eav/entity')->setType($entity); } else { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid entity supplied: %s', print_r($entity, true))); } return $this; diff --git a/app/code/core/Mage/Eav/Model/Entity/Setup.php b/app/code/core/Mage/Eav/Model/Entity/Setup.php index 7262f3d3ab3..d2376f8aa9b 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Setup.php +++ b/app/code/core/Mage/Eav/Model/Entity/Setup.php @@ -1237,8 +1237,6 @@ public function installEntities($entities = null) /** * @deprecated Missing unique indexes. To create custom EAV tables, refer to the core: - * @see app/code/core/Mage/Catalog/sql/catalog_setup/install-1.6.0.0.php - * @see app/code/core/Mage/Customer/sql/customer_setup/install-1.6.0.0.php * * Create entity tables * diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Frame/Result.php b/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Frame/Result.php index 8fb19666a3e..16e227a3dd4 100644 --- a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Frame/Result.php +++ b/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Frame/Result.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_ImportExport * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -51,7 +51,7 @@ class Mage_ImportExport_Block_Adminhtml_Import_Frame_Result extends Mage_Adminht * Add action for response. * * @param string $actionName - * @param string $elementId + * @param string|array $elementId * @param mixed $value OPTIONAL * @return $this */ diff --git a/app/code/core/Mage/ImportExport/Model/Import.php b/app/code/core/Mage/ImportExport/Model/Import.php index ca034c5e3bb..08ea81cbab4 100644 --- a/app/code/core/Mage/ImportExport/Model/Import.php +++ b/app/code/core/Mage/ImportExport/Model/Import.php @@ -381,6 +381,7 @@ public function expandSource() * * @throws Mage_Core_Exception * @return string Source file path + * @SuppressWarnings(PHPMD.ErrorControlOperator) */ public function uploadSource() { diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php index 96738d29d8d..5ec730fa412 100644 --- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php @@ -1674,6 +1674,8 @@ protected function _saveProductGroupPrices(array $groupPriceData) /** * Returns an object for upload a media files + * + * @SuppressWarnings(PHPMD.ErrorControlOperator) */ protected function _getUploader() { diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php index aa88d5e5df2..099cfff7de6 100644 --- a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php +++ b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php @@ -100,6 +100,8 @@ public function startAction() /** * Validate uploaded files action. + * + * @SuppressWarnings(PHPMD.Superglobals) */ public function validateAction() { diff --git a/app/code/core/Mage/Index/Model/Event.php b/app/code/core/Mage/Index/Model/Event.php index 094b6db0256..fde00268128 100644 --- a/app/code/core/Mage/Index/Model/Event.php +++ b/app/code/core/Mage/Index/Model/Event.php @@ -231,7 +231,6 @@ public function cleanNewData() * @param bool $useNamespace * @return array */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function getOldData($useNamespace = true) { return []; @@ -265,7 +264,6 @@ public function getNewData($useNamespace = true) * @return $this * @deprecated since 1.6.2.0 */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed public function addOldData($key, $value = null) { return $this; diff --git a/app/code/core/Mage/Index/Model/Lock.php b/app/code/core/Mage/Index/Model/Lock.php index 63fe92e85cb..66cc4601c15 100644 --- a/app/code/core/Mage/Index/Model/Lock.php +++ b/app/code/core/Mage/Index/Model/Lock.php @@ -63,7 +63,6 @@ class Mage_Index_Model_Lock protected function __construct() { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found register_shutdown_function([$this, 'shutdownReleaseLocks']); } @@ -153,7 +152,6 @@ protected function _setLockFile($lockName, $block = false) * @param bool $block * @return bool */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed protected function _setLockDb($lockName, $block = false) { if ($this->_getLockStorage()->setLock($lockName)) { @@ -285,19 +283,15 @@ protected function _getLockFile($lockName) if (!isset(self::$_lockFileResource[$lockName]) || self::$_lockFileResource[$lockName] === null) { $varDir = Mage::getConfig()->getVarDir('locks'); $file = $varDir . DS . $lockName . '.lock'; - // phpcs:ignore Ecg.Security.DiscouragedFunction.Discouraged if (is_file($file)) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found self::$_lockFileResource[$lockName] = fopen($file, 'w'); } else { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found self::$_lockFileResource[$lockName] = fopen($file, 'x'); } if (!self::$_lockFileResource[$lockName]) { self::$_lockFileResource[$lockName] = null; throw new Exception(sprintf('Unable to open lock file \'%s\': %s', $file, error_get_last())); } - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found fwrite(self::$_lockFileResource[$lockName], date('r')); } return self::$_lockFileResource[$lockName]; diff --git a/app/code/core/Mage/Install/Model/Installer/Console.php b/app/code/core/Mage/Install/Model/Installer/Console.php index f33ca1e4e5a..3b7050418d7 100644 --- a/app/code/core/Mage/Install/Model/Installer/Console.php +++ b/app/code/core/Mage/Install/Model/Installer/Console.php @@ -92,6 +92,7 @@ protected function _getOptions() * * @param array $args * @return bool + * @SuppressWarnings(PHPMD.Superglobals) */ public function setArgs($args = null) { diff --git a/app/code/core/Mage/Install/Model/Installer/Filesystem.php b/app/code/core/Mage/Install/Model/Installer/Filesystem.php index ad4ca5cabc9..76ff55efede 100644 --- a/app/code/core/Mage/Install/Model/Installer/Filesystem.php +++ b/app/code/core/Mage/Install/Model/Installer/Filesystem.php @@ -1,4 +1,5 @@ setLogoSrc($logo_src); - $this->setLogoAlt($logo_alt); + $this->setLogoSrc($logoSrc); + $this->setLogoAlt($logoAlt); return $this; } diff --git a/app/code/core/Mage/Page/Block/Template/Links.php b/app/code/core/Mage/Page/Block/Template/Links.php index 707c66d3228..a445f72bf1d 100644 --- a/app/code/core/Mage/Page/Block/Template/Links.php +++ b/app/code/core/Mage/Page/Block/Template/Links.php @@ -68,6 +68,7 @@ public function getLinks() * @param string $beforeText * @param string $afterText * @return $this + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function addLink( $label, diff --git a/app/code/core/Mage/Payment/Block/Info.php b/app/code/core/Mage/Payment/Block/Info.php index 8e29d4891e0..38b57a64544 100644 --- a/app/code/core/Mage/Payment/Block/Info.php +++ b/app/code/core/Mage/Payment/Block/Info.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Payment * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -114,8 +114,8 @@ public function getValueAsArray($value, $escapeHtml = false) $value = [$value]; } if ($escapeHtml) { - foreach ($value as $_key => $_val) { - $value[$_key] = $this->escapeHtml($_val); + foreach ($value as $key => $val) { + $value[$key] = $this->escapeHtml($val); } } return $value; diff --git a/app/code/core/Mage/Paypal/Block/Iframe.php b/app/code/core/Mage/Paypal/Block/Iframe.php index 76302e4baf7..f5279960f42 100644 --- a/app/code/core/Mage/Paypal/Block/Iframe.php +++ b/app/code/core/Mage/Paypal/Block/Iframe.php @@ -65,7 +65,6 @@ protected function _construct() $this->_paymentMethodCode = $paymentCode; $templatePath = str_replace('_', '', $paymentCode); $templateFile = "paypal/{$templatePath}/iframe.phtml"; - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if (file_exists(Mage::getDesign()->getTemplateFilename($templateFile))) { $this->setTemplate($templateFile); } else { diff --git a/app/code/core/Mage/Paypal/Model/Ipn.php b/app/code/core/Mage/Paypal/Model/Ipn.php index 29138652be6..19fbafc848b 100644 --- a/app/code/core/Mage/Paypal/Model/Ipn.php +++ b/app/code/core/Mage/Paypal/Model/Ipn.php @@ -171,6 +171,7 @@ protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter) * * @return Mage_Sales_Model_Order * @throws Exception + * @SuppressWarnings(PHPMD.ExitExpression) */ protected function _getOrder() { @@ -342,7 +343,7 @@ protected function _registerTransaction() $this->_registerPaymentCapture(true); break; - // the holded payment was denied on paypal side + // the held payment was denied on paypal side case Mage_Paypal_Model_Info::PAYMENTSTATUS_DENIED: $this->_registerPaymentDenial(); break; @@ -522,6 +523,7 @@ protected function _registerPaymentFailure() $this->_importPaymentInformation(); foreach ($this->_order->getInvoiceCollection() as $invoice) { + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $invoice->cancel()->save(); } diff --git a/app/code/core/Mage/Paypal/Model/Payflow/Request.php b/app/code/core/Mage/Paypal/Model/Payflow/Request.php index e480de42ee0..fdeb51b1332 100644 --- a/app/code/core/Mage/Paypal/Model/Payflow/Request.php +++ b/app/code/core/Mage/Paypal/Model/Payflow/Request.php @@ -28,6 +28,7 @@ class Mage_Paypal_Model_Payflow_Request extends Varien_Object * @param string $method * @param array $args * @return mixed + * @SuppressWarnings(PHPMD.DevelopmentCodeFragment) */ public function __call($method, $args) { @@ -48,7 +49,6 @@ public function __call($method, $args) case 'has': return isset($this->_data[$key]); } - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found throw new Varien_Exception('Invalid method ' . get_class($this) . '::' . $method . '(' . print_r($args, true) . ')'); } } diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Backend/Cert.php b/app/code/core/Mage/Paypal/Model/System/Config/Backend/Cert.php index eb6b301a39b..33429dc7e62 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Backend/Cert.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Backend/Cert.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Paypal * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -25,6 +25,7 @@ class Mage_Paypal_Model_System_Config_Backend_Cert extends Mage_Core_Model_Confi * Process additional data before save config * * @return $this + * @SuppressWarnings(PHPMD.Superglobals) */ protected function _beforeSave() { diff --git a/app/code/core/Mage/Paypal/controllers/IpnController.php b/app/code/core/Mage/Paypal/controllers/IpnController.php index 4c70473db3e..660c636b2c9 100644 --- a/app/code/core/Mage/Paypal/controllers/IpnController.php +++ b/app/code/core/Mage/Paypal/controllers/IpnController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Paypal * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -23,6 +23,8 @@ class Mage_Paypal_IpnController extends Mage_Core_Controller_Front_Action { /** * Instantiate IPN model and pass IPN request to it + * + * @SuppressWarnings(PHPMD.ExitExpression) */ public function indexAction() { diff --git a/app/code/core/Mage/Paypal/controllers/StandardController.php b/app/code/core/Mage/Paypal/controllers/StandardController.php index bb18926fc50..a9cbff2e884 100644 --- a/app/code/core/Mage/Paypal/controllers/StandardController.php +++ b/app/code/core/Mage/Paypal/controllers/StandardController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Paypal * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -33,14 +33,13 @@ class Mage_Paypal_StandardController extends Mage_Core_Controller_Front_Action */ public function getOrder() { - if ($this->_order == null) { - } return $this->_order; } /** * Send expire header to ajax response * + * @SuppressWarnings(PHPMD.ExitExpression) */ protected function _expireAjax() { @@ -51,7 +50,7 @@ protected function _expireAjax() } /** - * Get singleton with paypal strandard order transaction information + * Get singleton with PayPal standard order transaction information * * @return Mage_Paypal_Model_Standard */ diff --git a/app/code/core/Mage/Reports/Model/Product/Index/Compared.php b/app/code/core/Mage/Reports/Model/Product/Index/Compared.php index dd5cfd375b5..f1868bda0ca 100644 --- a/app/code/core/Mage/Reports/Model/Product/Index/Compared.php +++ b/app/code/core/Mage/Reports/Model/Product/Index/Compared.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Reports * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -56,8 +56,8 @@ public function getExcludeProductIds() $helper = Mage::helper('catalog/product_compare'); if ($helper->hasItems()) { - foreach ($helper->getItemCollection() as $_item) { - $productIds[] = $_item->getEntityId(); + foreach ($helper->getItemCollection() as $item) { + $productIds[] = $item->getEntityId(); } } diff --git a/app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php b/app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php index 09bc0225cf1..76226bcada6 100644 --- a/app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php +++ b/app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php @@ -170,6 +170,7 @@ protected function _getTableDateRangeSelect( $this->getStoreTZOffsetQuery([$alias => $table], $alias . '.' . $column, $from, $to) ) ) + // phpcs:ignore Ecg.Sql.SlowQuery.SlowSql ->distinct(true); if ($from !== null) { @@ -200,7 +201,7 @@ protected function _getTableDateRangeSelect( * from select statement with single date column * * - * @param Varien_Db_Select $select + * @param Zend_Db_Select|string $select * @param string $periodColumn * @return string|false */ @@ -255,6 +256,7 @@ protected function _makeConditionFromDateRangeSelect($select, $periodColumn) * @param string $alias * @param string $relatedAlias * @return Varien_Db_Select + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ protected function _getTableDateRangeRelatedSelect( $table, @@ -287,6 +289,7 @@ protected function _getTableDateRangeRelatedSelect( implode(' AND ', $joinConditionSql), [] ) + // phpcs:ignore Ecg.Sql.SlowQuery.SlowSql ->distinct(true); if ($from !== null) { diff --git a/app/code/core/Mage/Review/Model/Resource/Review.php b/app/code/core/Mage/Review/Model/Resource/Review.php index 777ddeea9ac..e479838d2c5 100644 --- a/app/code/core/Mage/Review/Model/Resource/Review.php +++ b/app/code/core/Mage/Review/Model/Resource/Review.php @@ -68,6 +68,7 @@ class Mage_Review_Model_Resource_Review extends Mage_Core_Model_Resource_Db_Abst * * @var array */ + // phpcs:ignore Ecg.PHP.PrivateClassMember.PrivateClassMemberError private $_deleteCache = []; /** @@ -229,8 +230,8 @@ protected function _beforeDelete(Mage_Core_Model_Abstract $object) */ public function afterDeleteCommit(Mage_Core_Model_Abstract $object) { - $read_adapter = $this->_getReadAdapter(); - $select = $read_adapter->select() + $readAdapter = $this->_getReadAdapter(); + $select = $readAdapter->select() ->from( $this->_reviewTable, [ @@ -239,8 +240,8 @@ public function afterDeleteCommit(Mage_Core_Model_Abstract $object) ) ->where('entity_id = ?', $object->getEntityId()) ->where('entity_pk_value = ?', $object->getEntityPkValue()); - $total_reviews = $read_adapter->fetchOne($select); - if ($total_reviews == 0) { + $totalReviews = $readAdapter->fetchOne($select); + if ($totalReviews == 0) { $this->_getWriteAdapter()->delete($this->_aggregateTable, [ 'entity_type = ?' => $object->getEntityId(), 'entity_pk_value = ?' => $object->getEntityPkValue() @@ -250,7 +251,7 @@ public function afterDeleteCommit(Mage_Core_Model_Abstract $object) $this->aggregate($object); - // reaggregate ratings, that depended on this review + // re-aggregate ratings, that depended on this review $this->_aggregateRatings( $this->_deleteCache['ratingIds'], $this->_deleteCache['entityPkValue'] diff --git a/app/code/core/Mage/Review/Model/Review.php b/app/code/core/Mage/Review/Model/Review.php index 4b0f05cfad9..6f98047d3ef 100644 --- a/app/code/core/Mage/Review/Model/Review.php +++ b/app/code/core/Mage/Review/Model/Review.php @@ -181,8 +181,8 @@ protected function _afterDeleteCommit() public function appendSummary($collection) { $entityIds = []; - foreach ($collection->getItems() as $_itemId => $_item) { - $entityIds[] = $_item->getId(); + foreach ($collection->getItems() as $item) { + $entityIds[] = $item->getId(); } if (!count($entityIds)) { @@ -194,10 +194,10 @@ public function appendSummary($collection) ->addStoreFilter(Mage::app()->getStore()->getId()) ->load(); - /** @var Mage_Review_Model_Review_Summary $_summary */ - foreach ($summaryData as $_summary) { - if (($_item = $collection->getItemById($_summary->getEntityPkValue()))) { - $_item->setRatingSummary($_summary); + /** @var Mage_Review_Model_Review_Summary $summary */ + foreach ($summaryData as $summary) { + if (($item = $collection->getItemById($summary->getEntityPkValue()))) { + $item->setRatingSummary($summary); } } diff --git a/app/code/core/Mage/Rss/Block/Catalog/Abstract.php b/app/code/core/Mage/Rss/Block/Catalog/Abstract.php index 06270f180e7..4a2221d1fe9 100644 --- a/app/code/core/Mage/Rss/Block/Catalog/Abstract.php +++ b/app/code/core/Mage/Rss/Block/Catalog/Abstract.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Rss * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -97,13 +97,13 @@ protected function _getPriceBlockTemplate($productTypeId) */ public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '') { - $type_id = $product->getTypeId(); + $typeId = $product->getTypeId(); if (Mage::helper('catalog')->canApplyMsrp($product)) { - $type_id = $this->_mapRenderer; + $typeId = $this->_mapRenderer; } - return $this->_getPriceBlock($type_id) - ->setTemplate($this->_getPriceBlockTemplate($type_id)) + return $this->_getPriceBlock($typeId) + ->setTemplate($this->_getPriceBlockTemplate($typeId)) ->setProduct($product) ->setDisplayMinimalPrice($displayMinimalPrice) ->setIdSuffix($idSuffix) diff --git a/app/code/core/Mage/Rss/Block/Catalog/Category.php b/app/code/core/Mage/Rss/Block/Catalog/Category.php index 705e476d55b..f689fbecd84 100644 --- a/app/code/core/Mage/Rss/Block/Catalog/Category.php +++ b/app/code/core/Mage/Rss/Block/Catalog/Category.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Rss * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2021-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2021-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -65,8 +65,9 @@ protected function _toHtml() $rssObj->_addHeader($data); - $_collection = $category->getCollection(); - $_collection->addAttributeToSelect('url_key') + /** @var Mage_Catalog_Model_Resource_Category_Collection $collection */ + $collection = $category->getCollection(); + $collection->addAttributeToSelect('url_key') ->addAttributeToSelect('name') ->addAttributeToSelect('is_anchor') ->addAttributeToFilter('is_active', 1) @@ -77,13 +78,13 @@ protected function _toHtml() $currentCategory = $layer->setCurrentCategory($category); $layer->prepareProductCollection($productCollection); - $productCollection->addCountToCategories($_collection); + $productCollection->addCountToCategories($collection); $category->getProductCollection()->setStoreId($storeId); /* - only load latest 50 products - */ - $_productCollection = $currentCategory + * only load latest 50 products + */ + $categoryProductCollection = $currentCategory ->getProductCollection() ->addAttributeToSort('updated_at', 'desc') ->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds()) @@ -91,10 +92,10 @@ protected function _toHtml() ->setPageSize(50) ; - if ($_productCollection->getSize() > 0) { + if ($categoryProductCollection->getSize() > 0) { $args = ['rssObj' => $rssObj]; - foreach ($_productCollection as $_product) { - $args['product'] = $_product; + foreach ($categoryProductCollection as $categoryProduct) { + $args['product'] = $categoryProduct; $this->addNewItemXmlCallback($args); } } diff --git a/app/code/core/Mage/Rss/Block/Catalog/Tag.php b/app/code/core/Mage/Rss/Block/Catalog/Tag.php index bf426b905c2..08d5b55bfa4 100644 --- a/app/code/core/Mage/Rss/Block/Catalog/Tag.php +++ b/app/code/core/Mage/Rss/Block/Catalog/Tag.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Rss * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2021-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2021-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -55,21 +55,21 @@ protected function _toHtml() ]; $rssObj->_addHeader($data); - $_collection = $tagModel->getEntityCollection() + $collection = $tagModel->getEntityCollection() ->addTagFilter($tagModel->getId()) ->addStoreFilter($storeId); - $_collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds()); + $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds()); $product = Mage::getModel('catalog/product'); /** @var Mage_Core_Model_Resource_Helper_Mysql4 $resourceHelper */ $resourceHelper = Mage::getResourceHelper('core'); Mage::getSingleton('core/resource_iterator')->walk( - $resourceHelper->getQueryUsingAnalyticFunction($_collection->getSelect()), + $resourceHelper->getQueryUsingAnalyticFunction($collection->getSelect()), [[$this, 'addTaggedItemXml']], ['rssObj' => $rssObj, 'product' => $product], - $_collection->getSelect()->getAdapter() + $collection->getSelect()->getAdapter() ); return $rssObj->createRssXml(); diff --git a/app/code/core/Mage/Sales/Block/Order/Item/Renderer/Default.php b/app/code/core/Mage/Sales/Block/Order/Item/Renderer/Default.php index 489c7f47838..bde105066a7 100644 --- a/app/code/core/Mage/Sales/Block/Order/Item/Renderer/Default.php +++ b/app/code/core/Mage/Sales/Block/Order/Item/Renderer/Default.php @@ -133,15 +133,15 @@ public function getFormatedOptionValue($optionValue) // truncate standard view $result = []; if (is_array($optionValue)) { - $_truncatedValue = implode("\n", $optionValue); - $_truncatedValue = nl2br($_truncatedValue); - return ['value' => $_truncatedValue]; + $truncatedValue = implode("\n", $optionValue); + $truncatedValue = nl2br($truncatedValue); + return ['value' => $truncatedValue]; } else { - $_truncatedValue = Mage::helper('core/string')->truncate($optionValue, 55, ''); - $_truncatedValue = nl2br($_truncatedValue); + $truncatedValue = Mage::helper('core/string')->truncate($optionValue, 55, ''); + $truncatedValue = nl2br($truncatedValue); } - $result = ['value' => $_truncatedValue]; + $result = ['value' => $truncatedValue]; if (Mage::helper('core/string')->strlen($optionValue) > 55) { $result['value'] = $result['value'] . ' ...'; diff --git a/app/code/core/Mage/Sales/Model/Entity/Sale/Collection.php b/app/code/core/Mage/Sales/Model/Entity/Sale/Collection.php index 118e596649f..4b2b06bea0c 100644 --- a/app/code/core/Mage/Sales/Model/Entity/Sale/Collection.php +++ b/app/code/core/Mage/Sales/Model/Entity/Sale/Collection.php @@ -135,7 +135,6 @@ public function load($printQuery = false, $logQuery = false) public function printLogQuery($printQuery = false, $logQuery = false, $sql = null) { if ($printQuery) { - // phpcs:ignore Ecg.Security.LanguageConstruct.DirectOutput echo is_null($sql) ? $this->getSelect()->__toString() : $sql; } diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php index b1a8efd37ec..900f67ba529 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php @@ -190,10 +190,10 @@ protected function insertAddress(&$page, $store = null) foreach (explode("\n", Mage::getStoreConfig('sales/identity/address', $store)) as $value) { if ($value !== '') { $value = preg_replace('/]*>/i', "\n", $value); - foreach (Mage::helper('core/string')->str_split($value, 45, true, true) as $_value) { + foreach (Mage::helper('core/string')->str_split($value, 45, true, true) as $str) { $page->drawText( - trim(strip_tags($_value)), - $this->getAlignRight($_value, 130, 440, $font, 10), + trim(strip_tags($str)), + $this->getAlignRight($str, 130, 440, $font, 10), $top, 'UTF-8' ); @@ -236,8 +236,8 @@ protected function _calcAddressHeight($address) foreach ($address as $value) { if ($value !== '') { $text = []; - foreach (Mage::helper('core/string')->str_split($value, 55, true, true) as $_value) { - $text[] = $_value; + foreach (Mage::helper('core/string')->str_split($value, 55, true, true) as $str) { + $text[] = $str; } foreach ($text as $part) { $y += 15; @@ -350,8 +350,8 @@ protected function insertOrder(&$page, $obj, $putOrderId = true) foreach ($billingAddress as $value) { if ($value !== '') { $text = []; - foreach (Mage::helper('core/string')->str_split($value, 45, true, true) as $_value) { - $text[] = $_value; + foreach (Mage::helper('core/string')->str_split($value, 45, true, true) as $str) { + $text[] = $str; } foreach ($text as $part) { $page->drawText(strip_tags(ltrim($part)), 35, $this->y, 'UTF-8'); @@ -368,8 +368,8 @@ protected function insertOrder(&$page, $obj, $putOrderId = true) foreach ($shippingAddress as $value) { if ($value !== '') { $text = []; - foreach (Mage::helper('core/string')->str_split($value, 45, true, true) as $_value) { - $text[] = $_value; + foreach (Mage::helper('core/string')->str_split($value, 45, true, true) as $str) { + $text[] = $str; } foreach ($text as $part) { $page->drawText(strip_tags(ltrim($part)), 285, $this->y, 'UTF-8'); @@ -410,8 +410,8 @@ protected function insertOrder(&$page, $obj, $putOrderId = true) if (trim($value) != '') { //Printing "Payment Method" lines $value = preg_replace('/]*>/i', "\n", $value); - foreach (Mage::helper('core/string')->str_split($value, 45, true, true) as $_value) { - $page->drawText(strip_tags(trim($_value)), $paymentLeft, $yPayments, 'UTF-8'); + foreach (Mage::helper('core/string')->str_split($value, 45, true, true) as $str) { + $page->drawText(strip_tags(trim($str)), $paymentLeft, $yPayments, 'UTF-8'); $yPayments -= 15; } } @@ -430,8 +430,8 @@ protected function insertOrder(&$page, $obj, $putOrderId = true) $methodStartY = $this->y; $this->y -= 15; - foreach (Mage::helper('core/string')->str_split($shippingMethod, 45, true, true) as $_value) { - $page->drawText(strip_tags(trim($_value)), 285, $this->y, 'UTF-8'); + foreach (Mage::helper('core/string')->str_split($shippingMethod, 45, true, true) as $str) { + $page->drawText(strip_tags(trim($str)), 285, $this->y, 'UTF-8'); $this->y -= 15; } @@ -461,9 +461,9 @@ protected function insertOrder(&$page, $obj, $putOrderId = true) $yShipments -= 20; $this->_setFontRegular($page, 8); foreach ($tracks as $track) { - $CarrierCode = $track->getCarrierCode(); - if ($CarrierCode != 'custom') { - $carrier = Mage::getSingleton('shipping/config')->getCarrierInstance($CarrierCode); + $carrierCode = $track->getCarrierCode(); + if ($carrierCode != 'custom') { + $carrier = Mage::getSingleton('shipping/config')->getCarrierInstance($carrierCode); $carrierTitle = $carrier->getConfigData('title'); } else { $carrierTitle = Mage::helper('sales')->__('Custom Value'); diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php index 516e283bf8e..ab26dab7ace 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Sales * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -99,9 +99,9 @@ public function draw() ]; // draw options value - $_printValue = $option['print_value'] ?? strip_tags($option['value']); + $printValue = $option['print_value'] ?? strip_tags($option['value']); $lines[][] = [ - 'text' => Mage::helper('core/string')->str_split($_printValue, 30, true, true), + 'text' => Mage::helper('core/string')->str_split($printValue, 30, true, true), 'feed' => 40 ]; } diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php index c56ce86c28e..6b9dba16555 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Sales * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -110,8 +110,8 @@ public function draw() ]; if ($option['value']) { - $_printValue = $option['print_value'] ?? strip_tags($option['value']); - $values = explode(', ', $_printValue); + $printValue = $option['print_value'] ?? strip_tags($option['value']); + $values = explode(', ', $printValue); foreach ($values as $value) { $lines[][] = [ 'text' => Mage::helper('core/string')->str_split($value, 30, true, true), diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php index 3877ca8ecfd..0eafd8921ec 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Sales * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -63,8 +63,8 @@ public function draw() // draw options value if ($option['value']) { - $_printValue = $option['print_value'] ?? strip_tags($option['value']); - $values = explode(', ', $_printValue); + $printValue = $option['print_value'] ?? strip_tags($option['value']); + $values = explode(', ', $printValue); foreach ($values as $value) { $lines[][] = [ 'text' => Mage::helper('core/string')->str_split($value, 50, true, true), diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php index f44d5977856..4b82e5f569c 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Sales * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -36,7 +36,7 @@ class Mage_Sales_Model_Order_Pdf_Total_Default extends Varien_Object * $index => array( * 'amount' => $amount, * 'label' => $label, - * 'font_size'=> $font_size + * 'font_size'=> $fontSize * ) * ) * @return array @@ -77,7 +77,7 @@ protected function _getSalesHelper() * $index => array( * 'amount' => $amount, * 'label' => $label, - * 'font_size'=> $font_size + * 'font_size'=> $fontSize * ) * ) * @return array @@ -98,7 +98,7 @@ public function getFullTaxInfo() } } else { $fullInfo = $this->_getFullRateInfo(); - $tax_info = []; + $taxInfo = []; if ($fullInfo) { foreach ($fullInfo as $info) { @@ -111,7 +111,7 @@ public function getFullTaxInfo() foreach ($info['rates'] as $rate) { $percent = $rate['percent'] ? ' (' . $rate['percent'] . '%)' : ''; - $tax_info[] = [ + $taxInfo[] = [ 'amount' => $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($_amount), 'label' => $this->_getTaxHelper()->__($rate['title']) . $percent . ':', 'font_size' => $fontSize @@ -119,7 +119,7 @@ public function getFullTaxInfo() } } } - $taxClassAmount = $tax_info; + $taxClassAmount = $taxInfo; } return $taxClassAmount; diff --git a/app/code/core/Mage/Sales/Model/Quote.php b/app/code/core/Mage/Sales/Model/Quote.php index 5e930e04ede..6ad5876b35d 100644 --- a/app/code/core/Mage/Sales/Model/Quote.php +++ b/app/code/core/Mage/Sales/Model/Quote.php @@ -798,7 +798,6 @@ public function addShippingAddress(Mage_Sales_Model_Quote_Address $address) * @param bool $useCache * @return Mage_Sales_Model_Resource_Quote_Item_Collection */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function getItemsCollection($useCache = true) { if ($this->hasItemsCollection()) { @@ -1124,7 +1123,6 @@ public function addProduct(Mage_Catalog_Model_Product $product, $request = null) * @return Mage_Sales_Model_Quote_Item * @throws Mage_Core_Model_Store_Exception */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed protected function _addCatalogProduct(Mage_Catalog_Model_Product $product, $qty = 1) { $newItem = false; @@ -1796,13 +1794,13 @@ public function isVirtual() { $isVirtual = true; $countItems = 0; - foreach ($this->getItemsCollection() as $_item) { - /** @var Mage_Sales_Model_Quote_Item $_item */ - if ($_item->isDeleted() || $_item->getParentItemId()) { + foreach ($this->getItemsCollection() as $item) { + /** @var Mage_Sales_Model_Quote_Item $item */ + if ($item->isDeleted() || $item->getParentItemId()) { continue; } $countItems++; - if (!$_item->getProduct()->getIsVirtual()) { + if (!$item->getProduct()->getIsVirtual()) { $isVirtual = false; break; } @@ -1828,11 +1826,11 @@ public function getIsVirtual() public function hasVirtualItems() { $hasVirtual = false; - foreach ($this->getItemsCollection() as $_item) { - if ($_item->getParentItemId()) { + foreach ($this->getItemsCollection() as $quoteItem) { + if ($quoteItem->getParentItemId()) { continue; } - if ($_item->getProduct()->isVirtual()) { + if ($quoteItem->getProduct()->isVirtual()) { $hasVirtual = true; } } diff --git a/app/code/core/Mage/Sales/Model/Resource/Quote.php b/app/code/core/Mage/Sales/Model/Resource/Quote.php index b4d24f99ad7..25a7be36b03 100644 --- a/app/code/core/Mage/Sales/Model/Resource/Quote.php +++ b/app/code/core/Mage/Sales/Model/Resource/Quote.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Sales * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2017-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2017-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -154,8 +154,8 @@ public function isOrderIncrementIdUsed($orderIncrementId) $select = $adapter->select(); $select->from($this->getTable('sales/order'), 'entity_id') ->where('increment_id = :increment_id'); - $entity_id = $adapter->fetchOne($select, $bind); - if ($entity_id > 0) { + $entityId = $adapter->fetchOne($select, $bind); + if ($entityId > 0) { return true; } diff --git a/app/code/core/Mage/Sales/controllers/DownloadController.php b/app/code/core/Mage/Sales/controllers/DownloadController.php index 7836421ba33..d2a8f304736 100644 --- a/app/code/core/Mage/Sales/controllers/DownloadController.php +++ b/app/code/core/Mage/Sales/controllers/DownloadController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Sales * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -147,6 +147,8 @@ public function downloadProfileCustomOptionAction() /** * Custom options download action + * + * @SuppressWarnings(PHPMD.ExitExpression) */ public function downloadCustomOptionAction() { diff --git a/app/code/core/Mage/SalesRule/Model/Observer.php b/app/code/core/Mage/SalesRule/Model/Observer.php index 76694397645..bc968b3a175 100644 --- a/app/code/core/Mage/SalesRule/Model/Observer.php +++ b/app/code/core/Mage/SalesRule/Model/Observer.php @@ -49,6 +49,7 @@ public function getValidator($event) * * @deprecated process call moved to total model * @param Varien_Event_Observer $observer + * @SuppressWarnings(PHPMD.CamelCaseMethodName) */ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps public function sales_quote_address_discount_item($observer) @@ -62,6 +63,7 @@ public function sales_quote_address_discount_item($observer) * * @param Varien_Event_Observer $observer * @return $this + * @SuppressWarnings(PHPMD.CamelCaseMethodName) */ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps public function sales_order_afterPlace($observer) @@ -87,9 +89,11 @@ public function sales_order_afterPlace($observer) continue; } $rule = Mage::getModel('salesrule/rule'); + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $rule->load($ruleId); if ($rule->getId()) { $rule->setTimesUsed($rule->getTimesUsed() + 1); + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $rule->save(); if ($customerId) { @@ -104,6 +108,7 @@ public function sales_order_afterPlace($observer) ->setRuleId($ruleId) ->setTimesUsed(1); } + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $ruleCustomer->save(); } } @@ -126,6 +131,7 @@ public function sales_order_afterPlace($observer) * Registered callback: called after an order payment is canceled * * @param Varien_Event_Observer $observer + * @SuppressWarnings(PHPMD.CamelCaseMethodName) */ // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps public function sales_order_paymentCancel($observer) @@ -203,6 +209,7 @@ protected function _checkSalesRulesAvailability($attributeCode) /** @var $rule->getConditions() Mage_SalesRule_Model_Rule_Condition_Combine */ $this->_removeAttributeFromConditions($rule->getConditions(), $attributeCode); $this->_removeAttributeFromConditions($rule->getActions(), $attributeCode); + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $rule->save(); $disabledRulesCount++; diff --git a/app/code/core/Mage/Shipping/Block/Tracking/Popup.php b/app/code/core/Mage/Shipping/Block/Tracking/Popup.php index e77e36c7243..693865ca398 100644 --- a/app/code/core/Mage/Shipping/Block/Tracking/Popup.php +++ b/app/code/core/Mage/Shipping/Block/Tracking/Popup.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Shipping * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -20,6 +20,8 @@ * @package Mage_Shipping * * @method string getProtectCode() + * + * @SuppressWarnings(PHPMD.CamelCasePropertyName) */ class Mage_Shipping_Block_Tracking_Popup extends Mage_Core_Block_Template { @@ -150,14 +152,14 @@ public function getTrackingInfoByOrder() $shipments = $order->getShipmentsCollection(); /** @var Mage_Sales_Model_Order_Shipment $shipment */ foreach ($shipments as $shipment) { - $increment_id = $shipment->getIncrementId(); + $incrementId = $shipment->getIncrementId(); $tracks = $shipment->getTracksCollection(); $trackingInfos = []; foreach ($tracks as $track) { $trackingInfos[] = $track->getNumberDetail(); } - $shipTrack[$increment_id] = $trackingInfos; + $shipTrack[$incrementId] = $trackingInfos; } } return $shipTrack; @@ -173,14 +175,14 @@ public function getTrackingInfoByShip() { $shipTrack = []; if ($shipment = $this->_initShipment()) { - $increment_id = $shipment->getIncrementId(); + $incrementId = $shipment->getIncrementId(); $tracks = $shipment->getTracksCollection(); $trackingInfos = []; foreach ($tracks as $track) { $trackingInfos[] = $track->getNumberDetail(); } - $shipTrack[$increment_id] = $trackingInfos; + $shipTrack[$incrementId] = $trackingInfos; } return $shipTrack; } diff --git a/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php b/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php index 2013719473b..c23a1ed6a12 100644 --- a/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php +++ b/app/code/core/Mage/Shipping/Model/Carrier/Abstract.php @@ -145,7 +145,6 @@ abstract public function collectRates(Mage_Shipping_Model_Rate_Request $request) * * @return Varien_Object */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function requestToShipment(Mage_Shipping_Model_Shipment_Request $request) { return new Varien_Object(); @@ -158,7 +157,6 @@ public function requestToShipment(Mage_Shipping_Model_Shipment_Request $request) * @param mixed $request * @return Varien_Object */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function returnOfShipment($request) { return new Varien_Object(); @@ -169,7 +167,6 @@ public function returnOfShipment($request) * * @return array */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function getContainerTypes(?Varien_Object $params = null) { return []; @@ -242,7 +239,6 @@ public function getCustomizableContainerTypes() * * @return array */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function getDeliveryConfirmationTypes(?Varien_Object $params = null) { return []; @@ -289,7 +285,6 @@ public function checkAvailableShipCountries(Mage_Shipping_Model_Rate_Request $re * * @return $this */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request) { return $this; @@ -539,7 +534,6 @@ public function isCityRequired() * @param string|null $countryId * @return false */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function isZipCodeRequired($countryId = null) { return false; @@ -594,7 +588,6 @@ public function getCarrierCode() * * @return array */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function getContentTypes(Varien_Object $params) { return []; diff --git a/app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php b/app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php index 1f1aabfde8a..0d01ec77439 100644 --- a/app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php +++ b/app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php @@ -13,11 +13,12 @@ * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/* +/** * Class Mage_Shipping_Model_Carrier_Tablerate * * @category Mage * @package Mage_Shipping + * @SuppressWarnings(PHPMD.CamelCasePropertyName) */ class Mage_Shipping_Model_Carrier_Tablerate extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface { @@ -133,6 +134,7 @@ public function collectRates(Mage_Shipping_Model_Rate_Request $request) $request->setPackageQty($oldQty); if (!empty($rate) && $rate['price'] >= 0) { + /** @var Mage_Shipping_Model_Rate_Result_Method $method */ $method = $this->_getModel('shipping/rate_result_method'); $method->setCarrier('tablerate'); @@ -162,6 +164,7 @@ public function collectRates(Mage_Shipping_Model_Rate_Request $request) $request->setPackageQty($freeQty); $rate = $this->getRate($request); if (!empty($rate) && $rate['price'] >= 0) { + /** @var Mage_Shipping_Model_Rate_Result_Method $method */ $method = $this->_getModel('shipping/rate_result_method'); $method->setCarrier('tablerate'); @@ -176,6 +179,7 @@ public function collectRates(Mage_Shipping_Model_Rate_Request $request) $result->append($method); } } else { + /** @var Mage_Shipping_Model_Rate_Result_Error $error */ $error = $this->_getModel('shipping/rate_result_error'); $error->setCarrier('tablerate'); $error->setCarrierTitle($this->getConfigData('title')); diff --git a/app/code/core/Mage/Shipping/Model/Info.php b/app/code/core/Mage/Shipping/Model/Info.php index 8b8b3dcd9e7..3b6fbfe8937 100644 --- a/app/code/core/Mage/Shipping/Model/Info.php +++ b/app/code/core/Mage/Shipping/Model/Info.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Shipping * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -116,14 +116,14 @@ public function getTrackingInfoByOrder() $shipments = $order->getShipmentsCollection(); /** @var Mage_Sales_Model_Order_Shipment $shipment */ foreach ($shipments as $shipment) { - $increment_id = $shipment->getIncrementId(); + $incrementId = $shipment->getIncrementId(); $tracks = $shipment->getTracksCollection(); $trackingInfos = []; foreach ($tracks as $track) { $trackingInfos[] = $track->getNumberDetail(); } - $shipTrack[$increment_id] = $trackingInfos; + $shipTrack[$incrementId] = $trackingInfos; } } $this->_trackingInfo = $shipTrack; @@ -140,14 +140,14 @@ public function getTrackingInfoByShip() $shipTrack = []; $shipment = $this->_initShipment(); if ($shipment) { - $increment_id = $shipment->getIncrementId(); + $incrementId = $shipment->getIncrementId(); $tracks = $shipment->getTracksCollection(); $trackingInfos = []; foreach ($tracks as $track) { $trackingInfos[] = $track->getNumberDetail(); } - $shipTrack[$increment_id] = $trackingInfos; + $shipTrack[$incrementId] = $trackingInfos; } $this->_trackingInfo = $shipTrack; return $this->_trackingInfo; diff --git a/app/code/core/Mage/Shipping/Model/Rate/Request.php b/app/code/core/Mage/Shipping/Model/Rate/Request.php index 1592088af8a..f6031e070b1 100644 --- a/app/code/core/Mage/Shipping/Model/Rate/Request.php +++ b/app/code/core/Mage/Shipping/Model/Rate/Request.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Shipping * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -57,8 +57,8 @@ * @method $this setBaseSubtotalInclTax(float $value) * * @method $this setCity(string $value) - * @method string getConditionName() - * @method $this setConditionName(array $value) + * @method string|array getConditionName() + * @method $this setConditionName(string|array $value) * @method $this setCountryId(string $value) * * @method string getDestCountryId() diff --git a/app/code/core/Mage/Shipping/Model/Rate/Result.php b/app/code/core/Mage/Shipping/Model/Rate/Result.php index 926f8979c63..22806e0901f 100644 --- a/app/code/core/Mage/Shipping/Model/Rate/Result.php +++ b/app/code/core/Mage/Shipping/Model/Rate/Result.php @@ -67,7 +67,7 @@ public function getError() /** * Add a rate to the result * - * @param Mage_Shipping_Model_Rate_Result_Abstract|Mage_Shipping_Model_Rate_Result $result + * @param Mage_Shipping_Model_Rate_Result_Error|Mage_Shipping_Model_Rate_Result_Abstract|Mage_Shipping_Model_Rate_Result $result * @return $this */ public function append($result) diff --git a/app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate.php b/app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate.php index 631225e1868..087516aedf1 100644 --- a/app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate.php +++ b/app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate.php @@ -178,6 +178,7 @@ public function getRate(Mage_Shipping_Model_Rate_Request $request) * * @throws Mage_Core_Exception * @return $this + * @SuppressWarnings(PHPMD.Superglobals) */ public function uploadAndImport(Varien_Object $object) { diff --git a/app/code/core/Mage/Tax/Helper/Data.php b/app/code/core/Mage/Tax/Helper/Data.php index 123eff45f85..d6dea6f5b05 100644 --- a/app/code/core/Mage/Tax/Helper/Data.php +++ b/app/code/core/Mage/Tax/Helper/Data.php @@ -463,7 +463,7 @@ protected function _getAllRatesByProductClass($store = null) /** * Get product price with all tax settings processing * - * @param Mage_Catalog_Model_Product $product + * @param Mage_Catalog_Model_Product|Varien_Object $product * @param float $price inputted product price * @param bool $includingTax return price include tax flag * @param null|Mage_Customer_Model_Address $shippingAddress @@ -1028,15 +1028,15 @@ public function getCalculatedTaxes($source) $price = $price - $item->getDiscountAmount() + $item->getHiddenTaxAmount(); $basePrice = $basePrice - $item->getBaseDiscountAmount() + $item->getBaseHiddenTaxAmount(); } - $tax_amount = $price * $percent / 100; - $base_tax_amount = $basePrice * $percent / 100; + $taxAmount = $price * $percent / 100; + $baseTaxAmount = $basePrice * $percent / 100; if (isset($taxClassAmount[$taxClassId])) { - $taxClassAmount[$taxClassId]['tax_amount'] += $tax_amount; - $taxClassAmount[$taxClassId]['base_tax_amount'] += $base_tax_amount; + $taxClassAmount[$taxClassId]['tax_amount'] += $taxAmount; + $taxClassAmount[$taxClassId]['base_tax_amount'] += $baseTaxAmount; } else { - $taxClassAmount[$taxClassId]['tax_amount'] = $tax_amount; - $taxClassAmount[$taxClassId]['base_tax_amount'] = $base_tax_amount; + $taxClassAmount[$taxClassId]['tax_amount'] = $taxAmount; + $taxClassAmount[$taxClassId]['base_tax_amount'] = $baseTaxAmount; $taxClassAmount[$taxClassId]['title'] = $tax['title']; $taxClassAmount[$taxClassId]['percent'] = $tax['percent']; } diff --git a/app/code/core/Mage/Tax/Model/Resource/Calculation.php b/app/code/core/Mage/Tax/Model/Resource/Calculation.php index 4d593b8dac6..a7572c7f64c 100644 --- a/app/code/core/Mage/Tax/Model/Resource/Calculation.php +++ b/app/code/core/Mage/Tax/Model/Resource/Calculation.php @@ -335,6 +335,7 @@ protected function _getRates($request) * @see ZF-7592 issue http://framework.zend.com/issues/browse/ZF-7592 */ if ($postcodeIsNumeric || $postcodeIsRange) { + // phpcs:ignore Ecg.Sql.SlowQuery.SlowSql $select = $this->_getReadAdapter()->select()->union( [ '(' . $select . ')', @@ -350,6 +351,7 @@ protected function _getRates($request) ->order('tax_postcode ' . Varien_Db_Select::SQL_DESC) ->order('value ' . Varien_Db_Select::SQL_DESC); + // phpcs:ignore Ecg.Performance.FetchAll.Found $this->_ratesCache[$cacheKey] = $this->_getReadAdapter()->fetchAll($select); } @@ -482,12 +484,14 @@ public function getRatesByCustomerTaxClass($customerTaxClass, $productTaxClass = 'state_table.region_id = main_table.tax_region_id', ['region_code' => 'state_table.code'] ) + // phpcs:ignore Ecg.Sql.SlowQuery.SlowSql ->distinct(true); - $CSP = $adapter->fetchAll($selectCSP); + // phpcs:ignore Ecg.Performance.FetchAll.Found + $csp = $adapter->fetchAll($selectCSP); $result = []; - foreach ($CSP as $one) { + foreach ($csp as $one) { $request = new Varien_Object(); $request->setCountryId($one['country']) ->setRegionId($one['region_id']) diff --git a/app/code/core/Mage/Tax/Model/Resource/Sales/Order/Tax/Item.php b/app/code/core/Mage/Tax/Model/Resource/Sales/Order/Tax/Item.php index 1fabfab6eaa..9ecf2a84af4 100644 --- a/app/code/core/Mage/Tax/Model/Resource/Sales/Order/Tax/Item.php +++ b/app/code/core/Mage/Tax/Model/Resource/Sales/Order/Tax/Item.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Tax * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -29,10 +29,10 @@ protected function _construct() /** * Get Tax Items with order tax information * - * @param int $item_id + * @param int $itemId * @return array */ - public function getTaxItemsByItemId($item_id) + public function getTaxItemsByItemId($itemId) { $adapter = $this->_getReadAdapter(); $select = $adapter->select() @@ -42,8 +42,9 @@ public function getTaxItemsByItemId($item_id) 'item.tax_id = tax.tax_id', ['title', 'percent', 'base_amount'] ) - ->where('item_id = ?', $item_id); + ->where('item_id = ?', $itemId); + // phpcs:ignore Ecg.Performance.FetchAll.Found return $adapter->fetchAll($select); } } diff --git a/app/code/core/Mage/Tax/Model/Sales/Pdf/Grandtotal.php b/app/code/core/Mage/Tax/Model/Sales/Pdf/Grandtotal.php index f888ab833a3..bfdf65f2bcf 100644 --- a/app/code/core/Mage/Tax/Model/Sales/Pdf/Grandtotal.php +++ b/app/code/core/Mage/Tax/Model/Sales/Pdf/Grandtotal.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Tax * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -25,7 +25,7 @@ class Mage_Tax_Model_Sales_Pdf_Grandtotal extends Mage_Sales_Model_Order_Pdf_Tot * $index => array( * 'amount' => $amount, * 'label' => $label, - * 'font_size'=> $font_size + * 'font_size'=> $fontSize * ) * ) * @return array diff --git a/app/code/core/Mage/Tax/Model/Sales/Pdf/Shipping.php b/app/code/core/Mage/Tax/Model/Sales/Pdf/Shipping.php index 4b9d2695812..c9f9fc41dc5 100644 --- a/app/code/core/Mage/Tax/Model/Sales/Pdf/Shipping.php +++ b/app/code/core/Mage/Tax/Model/Sales/Pdf/Shipping.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Tax * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -25,7 +25,7 @@ class Mage_Tax_Model_Sales_Pdf_Shipping extends Mage_Sales_Model_Order_Pdf_Total * $index => array( * 'amount' => $amount, * 'label' => $label, - * 'font_size'=> $font_size + * 'font_size'=> $fontSize * ) * ) * @return array diff --git a/app/code/core/Mage/Tax/Model/Sales/Pdf/Subtotal.php b/app/code/core/Mage/Tax/Model/Sales/Pdf/Subtotal.php index 4bb84d5b65a..ba15675cb85 100644 --- a/app/code/core/Mage/Tax/Model/Sales/Pdf/Subtotal.php +++ b/app/code/core/Mage/Tax/Model/Sales/Pdf/Subtotal.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Tax * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -27,7 +27,7 @@ class Mage_Tax_Model_Sales_Pdf_Subtotal extends Mage_Sales_Model_Order_Pdf_Total * $index => array( * 'amount' => $amount, * 'label' => $label, - * 'font_size'=> $font_size + * 'font_size'=> $fontSize * ) * ) * @return array diff --git a/app/code/core/Mage/Tax/Model/Sales/Pdf/Tax.php b/app/code/core/Mage/Tax/Model/Sales/Pdf/Tax.php index d9514ae24ed..f04a2b1c36c 100644 --- a/app/code/core/Mage/Tax/Model/Sales/Pdf/Tax.php +++ b/app/code/core/Mage/Tax/Model/Sales/Pdf/Tax.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Tax * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -25,7 +25,7 @@ class Mage_Tax_Model_Sales_Pdf_Tax extends Mage_Sales_Model_Order_Pdf_Total_Defa * $index => array( * 'amount' => $amount, * 'label' => $label, - * 'font_size'=> $font_size + * 'font_size'=> $fontSize * ) * ) * @return array diff --git a/app/code/core/Mage/Uploader/Model/Config/Abstract.php b/app/code/core/Mage/Uploader/Model/Config/Abstract.php index 0dd4156660a..3a0a6b2d746 100644 --- a/app/code/core/Mage/Uploader/Model/Config/Abstract.php +++ b/app/code/core/Mage/Uploader/Model/Config/Abstract.php @@ -39,6 +39,7 @@ protected function _getHelper() * @param array $args * @return bool|mixed|Varien_Object * @throws Varien_Exception + * @SuppressWarnings(PHPMD.DevelopmentCodeFragment) */ public function __call($method, $args) { @@ -56,7 +57,6 @@ public function __call($method, $args) case 'has': return isset($this->_data[$key]); } - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found throw new Varien_Exception('Invalid method ' . get_class($this) . '::' . $method . '(' . print_r($args, true) . ')'); } } diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php index a03f4d9ba3b..2244585cb9e 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php @@ -407,7 +407,7 @@ protected function _setFreeMethodRequest($freeMethod) /** * Get xml quotes * - * @return Mage_Core_Model_Abstract|Varien_Object + * @return Mage_Shipping_Model_Rate_Result|Varien_Object|null */ protected function _getXmlQuotes() { @@ -417,19 +417,19 @@ protected function _getXmlQuotes() /** * Do rate request and handle errors * - * @return Mage_Shipping_Model_Rate_Result|Varien_Object + * @return Mage_Shipping_Model_Rate_Result|Varien_Object|void */ protected function _doRequest() { - $r = $this->_rawRequest; + $rawRequest = $this->_rawRequest; $xml = new SimpleXMLElement(''); $xml->addAttribute('action', 'Request'); $xml->addAttribute('version', '1.1'); $requestor = $xml->addChild('Requestor'); - $requestor->addChild('ID', $r->getId()); - $requestor->addChild('Password', $r->getPassword()); + $requestor->addChild('ID', $rawRequest->getId()); + $requestor->addChild('Password', $rawRequest->getPassword()); $methods = explode(',', $this->getConfigData('allowed_methods')); $internationcode = $this->getCode('international_searvice'); @@ -437,59 +437,59 @@ protected function _doRequest() $shipDate = $this->_getShipDate(); - if ($r->hasService() && $r->getFreeMethodRequest()) { - if ($r->getDestCountryId() == self::USA_COUNTRY_ID) { + if ($rawRequest->hasService() && $rawRequest->getFreeMethodRequest()) { + if ($rawRequest->getDestCountryId() == self::USA_COUNTRY_ID) { $shipment = $xml->addChild('Shipment'); - $shipKey = $r->getShippingKey(); - $r->setShipDate($shipDate); + $shipKey = $rawRequest->getShippingKey(); + $rawRequest->setShipDate($shipDate); } else { $shipment = $xml->addChild('IntlShipment'); - $shipKey = $r->getShippingIntlKey(); - $r->setShipDate($this->_getShipDate(false)); + $shipKey = $rawRequest->getShippingIntlKey(); + $rawRequest->setShipDate($this->_getShipDate(false)); /* * For international shipment customs value must be posted */ $shippingDuty = $shipment->addChild('Dutiable'); - $shippingDuty->addChild('DutiableFlag', ($r->getDutiable() ? 'Y' : 'N')); - $shippingDuty->addChild('CustomsValue', $r->getValue()); + $shippingDuty->addChild('DutiableFlag', ($rawRequest->getDutiable() ? 'Y' : 'N')); + $shippingDuty->addChild('CustomsValue', $rawRequest->getValue()); $shippingDuty->addChild('IsSEDReqd', 'N'); } $hasShipCode = true; $this->_createShipmentXml($shipment, $shipKey); } else { - if ($r->getAction() == 'GenerateLabel') { - $methods = [$r->getService()]; + if ($rawRequest->getAction() == 'GenerateLabel') { + $methods = [$rawRequest->getService()]; } foreach ($methods as $method) { $shipment = false; if (array_key_exists($method, $this->getCode('special_express'))) { - $r->setService('E'); - $r->setExtendedService($this->getCode('special_express', $method)); + $rawRequest->setService('E'); + $rawRequest->setExtendedService($this->getCode('special_express', $method)); } else { - $r->setService($method); - $r->setExtendedService(null); + $rawRequest->setService($method); + $rawRequest->setExtendedService(null); } - if ($r->getDestCountryId() == self::USA_COUNTRY_ID && $method != $internationcode) { + if ($rawRequest->getDestCountryId() == self::USA_COUNTRY_ID && $method != $internationcode) { $shipment = $xml->addChild('Shipment'); - $shipKey = $r->getShippingKey(); - $r->setShipDate($shipDate); - } elseif ($r->getDestCountryId() != self::USA_COUNTRY_ID && $method == $internationcode) { + $shipKey = $rawRequest->getShippingKey(); + $rawRequest->setShipDate($shipDate); + } elseif ($rawRequest->getDestCountryId() != self::USA_COUNTRY_ID && $method == $internationcode) { $shipment = $xml->addChild('IntlShipment'); - $shipKey = $r->getShippingIntlKey(); - if ($r->getCustomsValue() != null && $r->getCustomsValue() != '') { - $customsValue = $r->getCustomsValue(); + $shipKey = $rawRequest->getShippingIntlKey(); + if ($rawRequest->getCustomsValue() != null && $rawRequest->getCustomsValue() != '') { + $customsValue = $rawRequest->getCustomsValue(); } else { - $customsValue = $r->getValue(); + $customsValue = $rawRequest->getValue(); } - $r->setShipDate($this->_getShipDate(false)); + $rawRequest->setShipDate($this->_getShipDate(false)); /* * For international shipment customs value must be posted */ $shippingDuty = $shipment->addChild('Dutiable'); - $shippingDuty->addChild('DutiableFlag', ($r->getDutiable() ? 'Y' : 'N')); + $shippingDuty->addChild('DutiableFlag', ($rawRequest->getDutiable() ? 'Y' : 'N')); $shippingDuty->addChild('CustomsValue', $customsValue); $shippingDuty->addChild('IsSEDReqd', 'N'); } @@ -544,53 +544,51 @@ protected function _doRequest() */ protected function _createShipmentXml($shipment, $shipKey) { - $r = $this->_rawRequest; - - $store = Mage::app()->getStore($r->getStoreId()); + $rawRequest = $this->_rawRequest; - $_haz = $this->getConfigFlag('hazardous_materials'); + $isHaz = $this->getConfigFlag('hazardous_materials'); - $_subtotal = $r->getValue(); - $_subtotalWithDiscount = $r->getValueWithDiscount(); + $subtotal = $rawRequest->getValue(); + $subtotalWithDiscount = $rawRequest->getValueWithDiscount(); - $_width = max(0, (float)$this->getConfigData('default_width')); - $_height = max(0, (float)$this->getConfigData('default_height')); - $_length = max(0, (float)$this->getConfigData('default_length')); + $width = max(0, (float)$this->getConfigData('default_width')); + $height = max(0, (float)$this->getConfigData('default_height')); + $length = max(0, (float)$this->getConfigData('default_length')); - $packageParams = $r->getPackageParams(); + $packageParams = $rawRequest->getPackageParams(); if ($packageParams) { - $_length = $packageParams->getLength(); - $_width = $packageParams->getWidth(); - $_height = $packageParams->getHeight(); + $length = $packageParams->getLength(); + $width = $packageParams->getWidth(); + $height = $packageParams->getHeight(); } - $_apEnabled = $this->getConfigFlag('additional_protection_enabled'); - $_apUseSubtotal = $this->getConfigData('additional_protection_use_subtotal'); - $_apConfigValue = max(0, (float)$this->getConfigData('additional_protection_value')); - $_apMinValue = max(0, (float)$this->getConfigData('additional_protection_min_value')); - $_apValueRounding = $this->getConfigData('additional_protection_rounding'); + $apEnabled = $this->getConfigFlag('additional_protection_enabled'); + $apUseSubtotal = $this->getConfigData('additional_protection_use_subtotal'); + $apConfigValue = max(0, (float)$this->getConfigData('additional_protection_value')); + $apMinValue = max(0, (float)$this->getConfigData('additional_protection_min_value')); + $apValueRounding = $this->getConfigData('additional_protection_rounding'); $apValue = 0; $apCode = self::ADDITIONAL_PROTECTION_NOT_REQUIRED; - if ($_apEnabled) { - if ($_apMinValue <= $_subtotal) { - switch ($_apUseSubtotal) { + if ($apEnabled) { + if ($apMinValue <= $subtotal) { + switch ($apUseSubtotal) { case self::ADDITIONAL_PROTECTION_VALUE_SUBTOTAL: - $apValue = $_subtotal; + $apValue = $subtotal; break; case self::ADDITIONAL_PROTECTION_VALUE_SUBTOTAL_WITH_DISCOUNT: - $apValue = $_subtotalWithDiscount; + $apValue = $subtotalWithDiscount; break; default: case self::ADDITIONAL_PROTECTION_VALUE_CONFIG: - $apValue = $_apConfigValue; + $apValue = $apConfigValue; break; } if ($apValue) { $apCode = self::ADDITIONAL_PROTECTION_ASSET; - switch ($_apValueRounding) { + switch ($apValueRounding) { case self::ADDITIONAL_PROTECTION_ROUNDING_CEIL: $apValue = ceil($apValue); break; @@ -606,7 +604,7 @@ protected function _createShipmentXml($shipment, $shipKey) } } - if ($r->getAction() == 'GenerateLabel') { + if ($rawRequest->getAction() == 'GenerateLabel') { $shipment->addAttribute('action', 'GenerateLabel'); } else { $shipment->addAttribute('action', 'RateEstimate'); @@ -615,49 +613,49 @@ protected function _createShipmentXml($shipment, $shipKey) $shippingCredentials = $shipment->addChild('ShippingCredentials'); $shippingCredentials->addChild('ShippingKey', $shipKey); - $shippingCredentials->addChild('AccountNbr', $r->getAccountNbr()); + $shippingCredentials->addChild('AccountNbr', $rawRequest->getAccountNbr()); $shipmentDetail = $shipment->addChild('ShipmentDetail'); - if ($r->getAction() == 'GenerateLabel') { + if ($rawRequest->getAction() == 'GenerateLabel') { if ($this->_request->getReferenceData()) { $referenceData = $this->_request->getReferenceData() . $this->_request->getPackageId(); } else { $referenceData = 'Order #' - . $r->getOrderShipment()->getOrder()->getIncrementId() + . $rawRequest->getOrderShipment()->getOrder()->getIncrementId() . ' P' - . $r->getPackageId(); + . $rawRequest->getPackageId(); } $shipmentDetail->addChild('ShipperReference', $referenceData); } - $shipmentDetail->addChild('ShipDate', $r->getShipDate()); - $shipmentDetail->addChild('Service')->addChild('Code', $r->getService()); - $shipmentDetail->addChild('ShipmentType')->addChild('Code', $r->getShipmentType()); - $shipmentDetail->addChild('Weight', $r->getWeight()); - $shipmentDetail->addChild('ContentDesc', $r->getContentDesc()); + $shipmentDetail->addChild('ShipDate', $rawRequest->getShipDate()); + $shipmentDetail->addChild('Service')->addChild('Code', $rawRequest->getService()); + $shipmentDetail->addChild('ShipmentType')->addChild('Code', $rawRequest->getShipmentType()); + $shipmentDetail->addChild('Weight', $rawRequest->getWeight()); + $shipmentDetail->addChild('ContentDesc', $rawRequest->getContentDesc()); $additionalProtection = $shipmentDetail->addChild('AdditionalProtection'); $additionalProtection->addChild('Code', $apCode); $additionalProtection->addChild('Value', floor($apValue)); - if ($_width || $_height || $_length) { + if ($width || $height || $length) { $dimensions = $shipmentDetail->addChild('Dimensions'); - $dimensions->addChild('Length', $_length); - $dimensions->addChild('Width', $_width); - $dimensions->addChild('Height', $_height); + $dimensions->addChild('Length', $length); + $dimensions->addChild('Width', $width); + $dimensions->addChild('Height', $height); } - if ($_haz || ($r->getExtendedService())) { + if ($isHaz || ($rawRequest->getExtendedService())) { $specialServices = $shipmentDetail->addChild('SpecialServices'); } - if ($_haz) { + if ($isHaz) { $hazardousMaterials = $specialServices->addChild('SpecialService'); $hazardousMaterials->addChild('Code', 'HAZ'); } - if ($r->getExtendedService()) { + if ($rawRequest->getExtendedService()) { $extendedService = $specialServices->addChild('SpecialService'); - $extendedService->addChild('Code', $r->getExtendedService()); + $extendedService->addChild('Code', $rawRequest->getExtendedService()); } /* @@ -666,52 +664,52 @@ protected function _createShipmentXml($shipment, $shipKey) * 3 = Third Party (if third party, need AccountNbr) */ $billing = $shipment->addChild('Billing'); - $billing->addChild('Party')->addChild('Code', $r->getIsGenerateLabelReturn() ? 'R' : 'S'); - $billing->addChild('DutyPaymentType', $r->getDutyPaymentType()); - if ($r->getIsGenerateLabelReturn()) { - $billing->addChild('AccountNbr', $r->getAccountNbr()); + $billing->addChild('Party')->addChild('Code', $rawRequest->getIsGenerateLabelReturn() ? 'R' : 'S'); + $billing->addChild('DutyPaymentType', $rawRequest->getDutyPaymentType()); + if ($rawRequest->getIsGenerateLabelReturn()) { + $billing->addChild('AccountNbr', $rawRequest->getAccountNbr()); } $sender = $shipment->addChild('Sender'); - $sender->addChild('SentBy', ($r->getOrigPersonName())); - $sender->addChild('PhoneNbr', $r->getOrigPhoneNumber()); - $sender->addChild('Email', $r->getOrigEmail()); + $sender->addChild('SentBy', ($rawRequest->getOrigPersonName())); + $sender->addChild('PhoneNbr', $rawRequest->getOrigPhoneNumber()); + $sender->addChild('Email', $rawRequest->getOrigEmail()); $senderAddress = $sender->addChild('Address'); - $senderAddress->addChild('Street', htmlspecialchars($r->getOrigStreet() ? $r->getOrigStreet() : 'N/A')); - $senderAddress->addChild('City', htmlspecialchars($r->getOrigCity())); - $senderAddress->addChild('State', htmlspecialchars($r->getOrigState())); - $senderAddress->addChild('CompanyName', htmlspecialchars($r->getOrigCompanyName())); + $senderAddress->addChild('Street', htmlspecialchars($rawRequest->getOrigStreet() ? $rawRequest->getOrigStreet() : 'N/A')); + $senderAddress->addChild('City', htmlspecialchars($rawRequest->getOrigCity())); + $senderAddress->addChild('State', htmlspecialchars($rawRequest->getOrigState())); + $senderAddress->addChild('CompanyName', htmlspecialchars($rawRequest->getOrigCompanyName())); /* * DHL xml service is using UK for united kingdom instead of GB which is a standard ISO country code */ - $senderAddress->addChild('Country', ($r->getOrigCountryId() == 'GB' ? 'UK' : $r->getOrigCountryId())); - $senderAddress->addChild('PostalCode', $r->getOrigPostal()); + $senderAddress->addChild('Country', ($rawRequest->getOrigCountryId() == 'GB' ? 'UK' : $rawRequest->getOrigCountryId())); + $senderAddress->addChild('PostalCode', $rawRequest->getOrigPostal()); $receiver = $shipment->addChild('Receiver'); - $receiver->addChild('AttnTo', $r->getDestPersonName()); - $receiver->addChild('PhoneNbr', $r->getDestPhoneNumber()); + $receiver->addChild('AttnTo', $rawRequest->getDestPersonName()); + $receiver->addChild('PhoneNbr', $rawRequest->getDestPhoneNumber()); $receiverAddress = $receiver->addChild('Address'); - $receiverAddress->addChild('Street', htmlspecialchars($r->getDestStreet() ? $r->getDestStreet() : 'N/A')); + $receiverAddress->addChild('Street', htmlspecialchars($rawRequest->getDestStreet() ? $rawRequest->getDestStreet() : 'N/A')); $receiverAddress->addChild( 'StreetLine2', - htmlspecialchars($r->getDestStreetLine2() ? $r->getDestStreetLine2() : 'N/A') + htmlspecialchars($rawRequest->getDestStreetLine2() ? $rawRequest->getDestStreetLine2() : 'N/A') ); - $receiverAddress->addChild('City', htmlspecialchars($r->getDestCity())); - $receiverAddress->addChild('State', htmlspecialchars($r->getDestState())); + $receiverAddress->addChild('City', htmlspecialchars($rawRequest->getDestCity())); + $receiverAddress->addChild('State', htmlspecialchars($rawRequest->getDestState())); $receiverAddress->addChild( 'CompanyName', - htmlspecialchars($r->getDestCompanyName() ? $r->getDestCompanyName() : 'N/A') + htmlspecialchars($rawRequest->getDestCompanyName() ? $rawRequest->getDestCompanyName() : 'N/A') ); /* * DHL xml service is using UK for united kingdom instead of GB which is a standard ISO country code */ - $receiverAddress->addChild('Country', ($r->getDestCountryId() == 'GB' ? 'UK' : $r->getDestCountryId())); - $receiverAddress->addChild('PostalCode', $r->getDestPostal()); + $receiverAddress->addChild('Country', ($rawRequest->getDestCountryId() == 'GB' ? 'UK' : $rawRequest->getDestCountryId())); + $receiverAddress->addChild('PostalCode', $rawRequest->getDestPostal()); - if ($r->getAction() == 'GenerateLabel') { + if ($rawRequest->getAction() == 'GenerateLabel') { $label = $shipment->addChild('ShipmentProcessingInstructions')->addChild('Label'); $label->addChild('ImageType', 'PNG'); } @@ -953,20 +951,18 @@ public function getTracking($trackings) /** * Set tracking request - * - * @return null */ protected function setTrackingReqeust() { - $r = new Varien_Object(); + $request = new Varien_Object(); - $id = $this->getConfigData('id'); - $r->setId($id); + $requestId = $this->getConfigData('id'); + $request->setId($requestId); $password = $this->getConfigData('password'); - $r->setPassword($password); + $request->setPassword($password); - $this->_rawTrackRequest = $r; + $this->_rawTrackRequest = $request; } /** @@ -1026,15 +1022,12 @@ protected function _getXMLTracking($trackings) * * @param array $trackings * @param string $response - * @return null */ protected function _parseXmlTrackingResponse($trackings, $response) { $errorTitle = Mage::helper('usa')->__('Unable to retrieve tracking'); $resultArr = []; $errorArr = []; - $trackingserror = []; - $tracknum = ''; if (strlen(trim($response)) > 0) { if (strpos(trim($response), 'glyphNumbersForCharacters($characters); $widths = $font->widthsForGlyphs($glyphs); - return (array_sum($widths) / $font->getUnitsPerEm()) * $font_size; + return (array_sum($widths) / $font->getUnitsPerEm()) * $fontSize; } /** @@ -86,7 +86,7 @@ public function getTextWidth($text, Zend_Pdf_Resource_Font $font, $font_size) * Defaults to current locale. * @param $align * @throws Zend_Pdf_Exception - * @return $this + * @return Zend_Pdf_Canvas_Interface */ public function drawText($text, $x, $y, $charEncoding = 'UTF-8', $align = self::ALIGN_LEFT) { diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/PageBuilder.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/PageBuilder.php index 97bffc3f0ac..bf7a99398d9 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/PageBuilder.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf/PageBuilder.php @@ -77,6 +77,7 @@ public function setPage(Zend_Pdf_Page $page) * * @param int $pt * @return int + * @SuppressWarnings(PHPMD.ShortMethodName) */ protected function _x($pt) { @@ -88,6 +89,7 @@ protected function _x($pt) * * @param int $pt * @return int + * @SuppressWarnings(PHPMD.ShortMethodName) */ protected function _y($pt) { @@ -210,7 +212,6 @@ public function addProductContentCode($code) * @param int $id * @return $this */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found public function addUnitId($id) { $this->_page->saveGS(); @@ -227,7 +228,6 @@ public function addUnitId($id) * @param $data * @return $this */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found public function addReferenceData($data) { $this->_page->saveGS(); diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php index b4981b4cda0..f586a20356c 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php @@ -915,8 +915,8 @@ protected function _parseXmlResponse($xmlResponse) $rate->setCarrier('ups'); $rate->setCarrierTitle($this->getConfigData('title')); $rate->setMethod($method); - $method_arr = $this->getShipmentByCode($method); - $rate->setMethodTitle($method_arr); + $methods = $this->getShipmentByCode($method); + $rate->setMethodTitle($methods); $rate->setCost($costArr[$method]); $rate->setPrice($price); $result->append($rate); @@ -954,16 +954,16 @@ public function getTracking($trackings) */ protected function setXMLAccessRequest() { - $userid = $this->getConfigData('username'); - $userid_pass = $this->getConfigData('password'); - $access_key = $this->getConfigData('access_license_number'); + $userId = $this->getConfigData('username'); + $userIdPass = $this->getConfigData('password'); + $accessKey = $this->getConfigData('access_license_number'); $this->_xmlAccessRequest = << - $access_key - $userid - $userid_pass + $accessKey + $userId + $userIdPass XMLAuth; } @@ -1710,7 +1710,6 @@ protected function _doShipmentRequestRest(Varien_Object $request): Varien_Object $result->setTrackingNumber($package->TrackingNumber); // ShippingLabel is not guaranteed to be set, but if it is, GraphicImage will be set. if (isset($package->ShippingLabel->GraphicImage)) { - // phpcs:ignore Ecg.Security.ForbiddenFunction $result->setShippingLabelContent(base64_decode($package->ShippingLabel->GraphicImage)); } } @@ -2312,6 +2311,7 @@ protected function _getRestQuotes() /** * Prepare shipping rate result based on response * @return Mage_Shipping_Model_Rate_Result + * @SuppressWarnings(PHPMD.ErrorControlOperator) */ protected function _parseRestResponse(string $rateResponse) { @@ -2483,6 +2483,7 @@ protected function setAPIAccessRequest() /** * Setting common request params for Rate Request */ + // phpcs:ignore Ecg.PHP.PrivateClassMember.PrivateClassMemberError private function setQuoteRequestData(Varien_Object $rowRequest): array { if (self::USA_COUNTRY_ID == $rowRequest->getDestCountry()) { @@ -2517,6 +2518,7 @@ private function setQuoteRequestData(Varien_Object $rowRequest): array return $params; } + // phpcs:ignore Ecg.PHP.PrivateClassMember.PrivateClassMemberError private function mapCurrencyCode(string $code): string { $currencyMapping = [ diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php index ef777f2d8cc..e25e22d7bb5 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php @@ -459,8 +459,8 @@ protected function _parseXmlResponse($response) if (is_object($xml->Package) && is_object($xml->Package->Postage)) { foreach ($xml->Package->Postage as $postage) { $serviceName = $this->_filterServiceName((string)$postage->MailService); - $_serviceCode = $this->getCode('method_to_code', $serviceName); - $serviceCode = $_serviceCode ? $_serviceCode : (string)$postage->attributes()->CLASSID; + $serviceCodeMethod = $this->getCode('method_to_code', $serviceName); + $serviceCode = $serviceCodeMethod ?: (string)$postage->attributes()->CLASSID; $serviceCodeToActualNameMap[$serviceCode] = $serviceName; if (in_array($serviceCode, $allowedMethods)) { $costArr[$serviceCode] = (string)$postage->Rate; diff --git a/app/code/core/Mage/Wishlist/Block/Abstract.php b/app/code/core/Mage/Wishlist/Block/Abstract.php index 194e6690988..81d4904b2f7 100644 --- a/app/code/core/Mage/Wishlist/Block/Abstract.php +++ b/app/code/core/Mage/Wishlist/Block/Abstract.php @@ -349,9 +349,9 @@ protected function _getItemPriceBlock($productType) */ public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '') { - $type_id = $product->getTypeId(); + $typeId = $product->getTypeId(); if (Mage::helper('catalog')->canApplyMsrp($product)) { - $realPriceHtml = $this->_preparePriceRenderer($type_id) + $realPriceHtml = $this->_preparePriceRenderer($typeId) ->setProduct($product) ->setDisplayMinimalPrice($displayMinimalPrice) ->setIdSuffix($idSuffix) @@ -359,10 +359,10 @@ public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = ->toHtml(); $product->setAddToCartUrl($this->getAddToCartUrl($product)); $product->setRealPriceHtml($realPriceHtml); - $type_id = $this->_mapRenderer; + $typeId = $this->_mapRenderer; } - return $this->_preparePriceRenderer($type_id) + return $this->_preparePriceRenderer($typeId) ->setProduct($product) ->setDisplayMinimalPrice($displayMinimalPrice) ->setIdSuffix($idSuffix) diff --git a/app/code/core/Mage/Wishlist/Model/Item.php b/app/code/core/Mage/Wishlist/Model/Item.php index 30827fcb017..ac45a85c7bd 100644 --- a/app/code/core/Mage/Wishlist/Model/Item.php +++ b/app/code/core/Mage/Wishlist/Model/Item.php @@ -182,10 +182,12 @@ protected function _saveItemOptions() { foreach ($this->_options as $index => $option) { if ($option->isDeleted()) { + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $option->delete(); unset($this->_options[$index]); unset($this->_optionsByCode[$option->getCode()]); } else { + // phpcs:ignore Ecg.Performance.Loop.ModelLSD $option->save(); } } @@ -460,9 +462,8 @@ public function mergeBuyRequest($buyRequest) public function setBuyRequest($buyRequest) { $buyRequest->setId($this->getId()); - - $_buyRequest = serialize($buyRequest->getData()); - $this->setData('buy_request', $_buyRequest); + $request = serialize($buyRequest->getData()); + $this->setData('buy_request', $request); return $this; } @@ -591,7 +592,7 @@ public function getOptionsByCode() /** * Add option to item * - * @param Mage_Wishlist_Model_Item_Option $option + * @param array|Mage_Wishlist_Model_Item_Option $option * @return $this */ public function addOption($option) diff --git a/app/code/core/Mage/Wishlist/Model/Resource/Item/Option/Collection.php b/app/code/core/Mage/Wishlist/Model/Resource/Item/Option/Collection.php index eacec3b2377..2bfff292ba3 100644 --- a/app/code/core/Mage/Wishlist/Model/Resource/Item/Option/Collection.php +++ b/app/code/core/Mage/Wishlist/Model/Resource/Item/Option/Collection.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Wishlist * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -74,7 +74,7 @@ protected function _afterLoad() /** * Apply quote item(s) filter to collection * - * @param int|array $item + * @param int|array|Mage_Wishlist_Model_Item $item * @return $this */ public function addItemFilter($item) diff --git a/app/code/core/Mage/Wishlist/Model/Wishlist.php b/app/code/core/Mage/Wishlist/Model/Wishlist.php index 24157fcbe01..886120cda28 100644 --- a/app/code/core/Mage/Wishlist/Model/Wishlist.php +++ b/app/code/core/Mage/Wishlist/Model/Wishlist.php @@ -188,9 +188,9 @@ protected function _afterSave() protected function _addCatalogProduct(Mage_Catalog_Model_Product $product, $qty = 1, $forciblySetQty = false) { $item = null; - foreach ($this->getItemCollection() as $_item) { - if ($_item->representProduct($product)) { - $item = $_item; + foreach ($this->getItemCollection() as $wishlistItem) { + if ($wishlistItem->representProduct($product)) { + $item = $wishlistItem; break; } } @@ -330,17 +330,17 @@ public function addNewItem($product, $buyRequest = null, $forciblySetQty = false ->load($productId); if ($buyRequest instanceof Varien_Object) { - $_buyRequest = $buyRequest; + $request = $buyRequest; } elseif (is_string($buyRequest)) { - $_buyRequest = new Varien_Object(unserialize($buyRequest, ['allowed_classes' => false])); + $request = new Varien_Object(unserialize($buyRequest, ['allowed_classes' => false])); } elseif (is_array($buyRequest)) { - $_buyRequest = new Varien_Object($buyRequest); + $request = new Varien_Object($buyRequest); } else { - $_buyRequest = new Varien_Object(); + $request = new Varien_Object(); } $cartCandidates = $product->getTypeInstance(true) - ->processConfiguration($_buyRequest, $product); + ->processConfiguration($request, $product); /** * Error message @@ -427,12 +427,12 @@ public function getSharedStoreIds($current = true) if ($current) { $this->_storeIds = $this->getStore()->getWebsite()->getStoreIds(); } else { - $_storeIds = []; + $storeIds = []; $stores = Mage::app()->getStores(); foreach ($stores as $store) { - $_storeIds[] = $store->getId(); + $storeIds[] = $store->getId(); } - $this->_storeIds = $_storeIds; + $this->_storeIds = $storeIds; } } return $this->_storeIds; @@ -556,13 +556,13 @@ public function updateItem($itemId, $buyRequest, $params = null) $buyRequest = Mage::helper('catalog/product')->addParamsToBuyRequest($buyRequest, $params); $product->setWishlistStoreId($item->getStoreId()); - $items = $this->getItemCollection(); + $wishlistItems = $this->getItemCollection(); $isForceSetQuantity = true; - foreach ($items as $_item) { - /** @var Mage_Wishlist_Model_Item $_item */ - if ($_item->getProductId() == $product->getId() - && $_item->representProduct($product) - && $_item->getId() != $item->getId() + foreach ($wishlistItems as $wishlistItem) { + /** @var Mage_Wishlist_Model_Item $wishlistItem */ + if ($wishlistItem->getProductId() == $product->getId() + && $wishlistItem->representProduct($product) + && $wishlistItem->getId() != $item->getId() ) { // We do not add new wishlist item, but updating the existing one $isForceSetQuantity = false; diff --git a/app/code/core/Mage/Wishlist/controllers/IndexController.php b/app/code/core/Mage/Wishlist/controllers/IndexController.php index 7b5495b0294..c44764dc562 100644 --- a/app/code/core/Mage/Wishlist/controllers/IndexController.php +++ b/app/code/core/Mage/Wishlist/controllers/IndexController.php @@ -680,11 +680,11 @@ public function sendAction() /*if share rss added rss feed to email template*/ if ($this->getRequest()->getParam('rss_url')) { - $rss_url = $this->getLayout() + $rssUrl = $this->getLayout() ->createBlock('wishlist/share_email_rss') ->setWishlistId($wishlist->getId()) ->toHtml(); - $message .= $rss_url; + $message .= $rssUrl; } $wishlistBlock = $this->getLayout()->createBlock('wishlist/share_email_items')->toHtml(); @@ -732,6 +732,7 @@ public function sendAction() /** * Custom options download action * @return void + * @SuppressWarnings(PHPMD.ExitExpression) */ public function downloadCustomOptionAction() { @@ -775,7 +776,6 @@ public function downloadCustomOptionAction() } catch (Exception $e) { $this->_forward('noRoute'); } - // phpcs:ignore Ecg.Security.LanguageConstruct.ExitUsage exit(0); } } diff --git a/app/design/adminhtml/default/default/template/catalog/product/price.phtml b/app/design/adminhtml/default/default/template/catalog/product/price.phtml index 881d57f15b2..7226d07cb75 100644 --- a/app/design/adminhtml/default/default/template/catalog/product/price.phtml +++ b/app/design/adminhtml/default/default/template/catalog/product/price.phtml @@ -33,6 +33,7 @@ $_product = $this->getProduct(); $_id = $_product->getId(); $_storeId = $_product->getStoreId(); + /** @var Mage_Core_Model_Website $_website */ $_website = Mage::app()->getStore($_storeId)->getWebsite(); $_weeeSeparator = ''; diff --git a/composer.json b/composer.json index c3e2699bb55..bedc06e2a6a 100644 --- a/composer.json +++ b/composer.json @@ -136,17 +136,23 @@ "scripts": { "php-cs-fixer:test": "vendor/bin/php-cs-fixer fix --dry-run --diff", "php-cs-fixer:fix": "vendor/bin/php-cs-fixer fix", + "phpcs": "vendor/bin/phpcs -s -p --standard=.phpcs.dist.xml,.phpcs.dist.php.xml --cache=.phpcs.result.cache --report=full,summary", + "phpcs:ecg": "vendor/bin/phpcs -s -p --standard=.phpcs.dist.ecg.xml --report=full,summary", + "phpmd": "vendor/bin/phpmd app/code/core/Mage text .phpmd.dist.xml --color --cache --baseline-file .phpmd.dist.baseline.xml", "phpstan": "XDEBUG_MODE=off php vendor/bin/phpstan analyze", "phpstan:baseline": "XDEBUG_MODE=off php vendor/bin/phpstan analyze -b .phpstan.dist.baseline.neon", - "phpunit:test": "XDEBUG_MODE=off php vendor/bin/phpunit --no-coverage --testdox", - "phpunit:coverage": "XDEBUG_MODE=coverage php vendor/bin/phpunit --testdox", - "phpunit:coverage-local": "XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-html build/coverage --testdox", - "rector:test": "vendor/bin/rector process --dry-run", - "rector:fix": "vendor/bin/rector process" + "phpunit:test": "XDEBUG_MODE=off php vendor/bin/phpunit --configuration .phpunit.dist.xml --no-coverage --testdox", + "phpunit:coverage": "XDEBUG_MODE=coverage php vendor/bin/phpunit --configuration .phpunit.dist.xml --testdox", + "phpunit:coverage-local": "XDEBUG_MODE=coverage php vendor/bin/phpunit --configuration .phpunit.dist.xml --coverage-html build/coverage --testdox", + "rector:test": "vendor/bin/rector process --config .rector.php --dry-run", + "rector:fix": "vendor/bin/rector --config .rector.php process" }, "scripts-descriptions": { "php-cs-fixer:test": "Run php-cs-fixer", "php-cs-fixer:fix": "Run php-cs-fixer and fix issues", + "phpcs": "Run phpcs", + "phpcs:ecg": "Run phcs with ECG standard", + "phpmd": "Run phpmd", "phpstan": "Run phpstan", "phpstan:baseline": "Run phpstan and update baseline", "phpunit:test": "Run PHPUnit", diff --git a/lib/Mage/HTTP/Client/Curl.php b/lib/Mage/HTTP/Client/Curl.php index f8387a44c6a..cd08fb3a30d 100644 --- a/lib/Mage/HTTP/Client/Curl.php +++ b/lib/Mage/HTTP/Client/Curl.php @@ -310,7 +310,7 @@ public function getCookiesFull() /** * Get response status code - * @see lib/Mage/HTTP/Mage_HTTP_Client#getStatus() + * @see Mage_HTTP_Client::getStatus() */ public function getStatus() { diff --git a/lib/Mage/HTTP/Client/Socket.php b/lib/Mage/HTTP/Client/Socket.php index 46eeea4ca8a..8a46efd8e98 100644 --- a/lib/Mage/HTTP/Client/Socket.php +++ b/lib/Mage/HTTP/Client/Socket.php @@ -422,7 +422,7 @@ protected function processRedirect() /** * Get response status code - * @see lib/Mage/HTTP/Mage_HTTP_Client#getStatus() + * @see Mage_HTTP_Client::getStatus() */ public function getStatus() { diff --git a/lib/Mage/System/Ftp.php b/lib/Mage/System/Ftp.php index 0563c90d4e7..f017febd40f 100644 --- a/lib/Mage/System/Ftp.php +++ b/lib/Mage/System/Ftp.php @@ -52,7 +52,6 @@ protected function checkConnected() public function mdkir($name) { $this->checkConnected(); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_mkdir($this->_conn, $name); } @@ -71,19 +70,14 @@ public function mkdirRecursive($path, $mode = 0777) $dir = explode('/', $path); $path = ''; $ret = true; - // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed,Ecg.Performance.Loop.ArraySize for ($i = 0; $i < count($dir); $i++) { $path .= '/' . $dir[$i]; - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found if (!@ftp_chdir($this->_conn, $path)) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found @ftp_chdir($this->_conn, '/'); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found if (!@ftp_mkdir($this->_conn, $path)) { $ret = false; break; } else { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found @ftp_chmod($this->_conn, $mode, $path); } } @@ -104,7 +98,6 @@ public function mkdirRecursive($path, $mode = 0777) public function login($login = 'anonymous', $password = 'test@gmail.com') { $this->checkConnected(); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found $res = @ftp_login($this->_conn, $login, $password); if (!$res) { throw new Exception('Invalid login credentials'); @@ -123,7 +116,6 @@ public function login($login = 'anonymous', $password = 'test@gmail.com') */ public function validateConnectionString($string) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found $data = @parse_url($string); if (false === $data) { throw new Exception("Connection string invalid: '{$string}'"); @@ -147,7 +139,6 @@ public function connect($string, $timeout = 900) $params = $this->validateConnectionString($string); $port = isset($params['port']) ? (int) $params['port'] : 21; - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $this->_conn = ftp_connect($params['host'], $port, $timeout); if (!$this->_conn) { @@ -179,7 +170,6 @@ public function connect($string, $timeout = 900) public function fput($remoteFile, $handle, $mode = FTP_BINARY, $startPos = 0) { $this->checkConnected(); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_fput($this->_conn, $remoteFile, $handle, $mode, $startPos); } @@ -195,7 +185,6 @@ public function fput($remoteFile, $handle, $mode = FTP_BINARY, $startPos = 0) public function put($remoteFile, $localFile, $mode = FTP_BINARY, $startPos = 0) { $this->checkConnected(); - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found return ftp_put($this->_conn, $remoteFile, $localFile, $mode, $startPos); } @@ -232,7 +221,6 @@ public function getcwd() public function raw($cmd) { $this->checkConnected(); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_raw($this->_conn, $cmd); } @@ -252,21 +240,17 @@ public function upload($remote, $local, $dirMode = 0777, $ftpMode = FTP_BINARY) { $this->checkConnected(); - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if (!file_exists($local)) { throw new Exception("Local file doesn't exist: {$local}"); } - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if (!is_readable($local)) { throw new Exception("Local file is not readable: {$local}"); } - // phpcs:ignore Ecg.Security.DiscouragedFunction.Discouraged if (is_dir($local)) { throw new Exception("Directory given instead of file: {$local}"); } $globalPathMode = substr($remote, 0, 1) == '/'; - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $dirname = dirname($remote); $cwd = $this->getcwd(); if (false === $cwd) { @@ -311,7 +295,6 @@ public function download($remote, $local, $ftpMode = FTP_BINARY) public function pasv($pasv) { $this->checkConnected(); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_pasv($this->_conn, (bool) $pasv); } @@ -325,7 +308,6 @@ public function pasv($pasv) public function close() { if ($this->_conn) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found @ftp_close($this->_conn); } } @@ -342,7 +324,6 @@ public function close() public function chmod($mode, $remoteFile) { $this->checkConnected(); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_chmod($this->_conn, $mode, $remoteFile); } @@ -357,7 +338,6 @@ public function chmod($mode, $remoteFile) public function chdir($dir) { $this->checkConnected(); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_chdir($this->_conn, $dir); } @@ -371,7 +351,6 @@ public function chdir($dir) public function cdup() { $this->checkConnected(); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_cdup($this->_conn); } @@ -390,7 +369,6 @@ public function get($localFile, $remoteFile, $fileMode = FTP_BINARY, $resumeOffs { $remoteFile = $this->correctFilePath($remoteFile); $this->checkConnected(); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_get($this->_conn, $localFile, $remoteFile, $fileMode, $resumeOffset); } @@ -406,7 +384,6 @@ public function nlist($dir = '/') { $this->checkConnected(); $dir = $this->correctFilePath($dir); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_nlist($this->_conn, $dir); } @@ -423,7 +400,6 @@ public function rawlist($dir = '/', $recursive = false) { $this->checkConnected(); $dir = $this->correctFilePath($dir); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_rawlist($this->_conn, $dir, $recursive); } @@ -466,9 +442,7 @@ public function fileExists($path, $excludeIfIsDir = true) $path = $this->correctFilePath($path); $globalPathMode = substr($path, 0, 1) == '/'; - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $file = basename($path); - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $dir = $globalPathMode ? dirname($path) : $this->getcwd() . '/' . $path; $data = $this->ls($dir); foreach ($data as $row) { @@ -547,7 +521,6 @@ public function delete($file) { $this->checkConnected(); $file = $this->correctFilePath($file); - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_delete($this->_conn, $file); } } diff --git a/lib/Mage/Xml/Generator.php b/lib/Mage/Xml/Generator.php index 5a4705ff76f..f56858ed7cd 100644 --- a/lib/Mage/Xml/Generator.php +++ b/lib/Mage/Xml/Generator.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Xml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2021-2022 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2021-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ class Mage_Xml_Generator @@ -33,7 +33,7 @@ public function getDom() } /** - * @return DOMElement + * @return DOMDocument */ protected function _getCurrentDom() { @@ -59,38 +59,38 @@ public function arrayToXml($content) if (!$content || !count($content)) { return $this; } - foreach ($content as $_key => $_item) { + foreach ($content as $key => $item) { try { - $node = $this->getDom()->createElement($_key); + $node = $this->getDom()->createElement($key); } catch (DOMException $e) { // echo $e->getMessage(); - var_dump($_item); + var_dump($item); die; } $parentNode->appendChild($node); - if (is_array($_item) && isset($_item['_attribute'])) { - if (is_array($_item['_value'])) { - if (isset($_item['_value'][0])) { - foreach ($_item['_value'] as $_k => $_v) { - $this->_setCurrentDom($node)->arrayToXml($_v); + if (is_array($item) && isset($item['_attribute'])) { + if (is_array($item['_value'])) { + if (isset($item['_value'][0])) { + foreach ($item['_value'] as $value) { + $this->_setCurrentDom($node)->arrayToXml($value); } } else { - $this->_setCurrentDom($node)->arrayToXml($_item['_value']); + $this->_setCurrentDom($node)->arrayToXml($item['_value']); } } else { - $child = $this->getDom()->createTextNode($_item['_value']); + $child = $this->getDom()->createTextNode($item['_value']); $node->appendChild($child); } - foreach ($_item['_attribute'] as $_attributeKey => $_attributeValue) { + foreach ($item['_attribute'] as $_attributeKey => $_attributeValue) { $node->setAttribute($_attributeKey, $_attributeValue); } - } elseif (is_string($_item)) { - $text = $this->getDom()->createTextNode($_item); + } elseif (is_string($item)) { + $text = $this->getDom()->createTextNode($item); $node->appendChild($text); - } elseif (is_array($_item) && !isset($_item[0])) { - $this->_setCurrentDom($node)->arrayToXml($_item); - } elseif (is_array($_item) && isset($_item[0])) { - foreach ($_item as $k => $v) { + } elseif (is_array($item) && !isset($item[0])) { + $this->_setCurrentDom($node)->arrayToXml($item); + } elseif (is_array($item) && isset($item[0])) { + foreach ($item as $k => $v) { $this->_setCurrentDom($node)->arrayToXml($v); } } diff --git a/lib/Varien/Data/Collection/Db.php b/lib/Varien/Data/Collection/Db.php index 6f15aa43fa6..667fc5d0e7b 100644 --- a/lib/Varien/Data/Collection/Db.php +++ b/lib/Varien/Data/Collection/Db.php @@ -748,7 +748,6 @@ public function loadData($printQuery = false, $logQuery = false) public function printLogQuery($printQuery = false, $logQuery = false, $sql = null) { if ($printQuery) { - // phpcs:ignore Ecg.Security.LanguageConstruct.DirectOutput echo is_null($sql) ? $this->getSelect()->__toString() : $sql; } diff --git a/lib/Varien/Data/Form/Abstract.php b/lib/Varien/Data/Form/Abstract.php index b4fe9a24ff5..db11e9a63c9 100644 --- a/lib/Varien/Data/Form/Abstract.php +++ b/lib/Varien/Data/Form/Abstract.php @@ -184,7 +184,6 @@ public function addColumn($elementId, $config) /** * @return array */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function __toArray(array $arrAttributes = []) { $res = []; diff --git a/lib/Varien/Db/Adapter/Interface.php b/lib/Varien/Db/Adapter/Interface.php index 5bf27b79714..949d2724283 100644 --- a/lib/Varien/Db/Adapter/Interface.php +++ b/lib/Varien/Db/Adapter/Interface.php @@ -828,7 +828,7 @@ public function getGreatestSql(array $data); /** * Add time values (intervals) to a date value * - * @see INTERVAL_* constants for $unit + * @see INTERVAL_ constants for $unit * * @param Zend_Db_Expr|string $date quoted field name or SQL statement * @param int $interval @@ -840,7 +840,7 @@ public function getDateAddSql($date, $interval, $unit); /** * Subtract time values (intervals) to a date value * - * @see INTERVAL_* constants for $unit + * @see INTERVAL_ constants for $unit * * @param Zend_Db_Expr|string $date quoted field name or SQL statement * @param int|string $interval @@ -896,7 +896,7 @@ public function getStandardDeviationSql($expressionField); /** * Extract part of a date * - * @see INTERVAL_* constants for $unit + * @see INTERVAL_ constants for $unit * * @param Zend_Db_Expr|string $date quoted field name or SQL statement * @param string $unit diff --git a/lib/Varien/Db/Adapter/Pdo/Mysql.php b/lib/Varien/Db/Adapter/Pdo/Mysql.php index de5a6f10f6d..4cebd7249e9 100644 --- a/lib/Varien/Db/Adapter/Pdo/Mysql.php +++ b/lib/Varien/Db/Adapter/Pdo/Mysql.php @@ -3298,7 +3298,7 @@ protected function _getIntervalUnitSql($interval, $unit) /** * Add time values (intervals) to a date value * - * @see INTERVAL_* constants for $unit + * @see INTERVAL_ constants for $unit * * @param Zend_Db_Expr|string $date quoted field name or SQL statement * @param int $interval @@ -3314,7 +3314,7 @@ public function getDateAddSql($date, $interval, $unit) /** * Subtract time values (intervals) to a date value * - * @see INTERVAL_* constants for $expr + * @see INTERVAL_ constants for $expr * * @param Zend_Db_Expr|string $date quoted field name or SQL statement * @param int|string $interval @@ -3390,7 +3390,7 @@ public function getStandardDeviationSql($expressionField) /** * Extract part of a date * - * @see INTERVAL_* constants for $unit + * @see INTERVAL_ constants for $unit * * @param Zend_Db_Expr|string $date quoted field name or SQL statement * @param string $unit diff --git a/lib/Varien/Db/Ddl/Table.php b/lib/Varien/Db/Ddl/Table.php index 2d2aa21a074..5e9f5105ff3 100644 --- a/lib/Varien/Db/Ddl/Table.php +++ b/lib/Varien/Db/Ddl/Table.php @@ -538,7 +538,6 @@ public function addIndex($indexName, $fields, $options = []) * Retrieve array of table columns * * @param bool $normalized - * @see $this->_columns * @return array */ public function getColumns($normalized = true) @@ -553,7 +552,6 @@ public function getColumns($normalized = true) * Set column, formatted according to DDL Table format, into columns structure * * @param array $column - * @see $this->_columns * @return Varien_Db_Ddl_Table */ public function setColumn($column) @@ -566,7 +564,6 @@ public function setColumn($column) /** * Retrieve array of table indexes * - * @see $this->_indexes * @return array */ public function getIndexes() @@ -577,7 +574,6 @@ public function getIndexes() /** * Retrieve array of table foreign keys * - * @see $this->_foreignKeys * @return array */ public function getForeignKeys() diff --git a/lib/Varien/Event/Observer.php b/lib/Varien/Event/Observer.php index 1b4ed1c2bed..c69e8c82c44 100644 --- a/lib/Varien/Event/Observer.php +++ b/lib/Varien/Event/Observer.php @@ -45,10 +45,10 @@ public function dispatch(Varien_Event $event) $callback = $this->getCallback(); $this->setEvent($event); - $_profilerKey = 'OBSERVER: ' . (is_object($callback[0]) ? get_class($callback[0]) : (string)$callback[0]) . ' -> ' . $callback[1]; - Varien_Profiler::start($_profilerKey); + $profilerKey = 'OBSERVER: ' . (is_object($callback[0]) ? get_class($callback[0]) : (string)$callback[0]) . ' -> ' . $callback[1]; + Varien_Profiler::start($profilerKey); call_user_func($callback, $this); - Varien_Profiler::stop($_profilerKey); + Varien_Profiler::stop($profilerKey); return $this; } diff --git a/lib/Varien/Io/Ftp.php b/lib/Varien/Io/Ftp.php index 1797c1e4e9a..613874c81d6 100644 --- a/lib/Varien/Io/Ftp.php +++ b/lib/Varien/Io/Ftp.php @@ -100,10 +100,8 @@ public function open(array $args = []) $this->_config = $args; if (empty($this->_config['ssl'])) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found $this->_conn = @ftp_connect($this->_config['host'], $this->_config['port'], $this->_config['timeout']); } else { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found $this->_conn = @ftp_ssl_connect($this->_config['host'], $this->_config['port'], $this->_config['timeout']); } if (!$this->_conn) { @@ -111,7 +109,6 @@ public function open(array $args = []) throw new Varien_Io_Exception('Could not establish FTP connection, invalid host or port'); } - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found if (!@ftp_login($this->_conn, $this->_config['user'], $this->_config['password'])) { $this->_error = self::ERROR_INVALID_LOGIN; $this->close(); @@ -119,7 +116,6 @@ public function open(array $args = []) } if (!empty($this->_config['path'])) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found if (!@ftp_chdir($this->_conn, $this->_config['path'])) { $this->_error = self::ERROR_INVALID_PATH; $this->close(); @@ -128,7 +124,6 @@ public function open(array $args = []) } if (!empty($this->_config['passive'])) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found if (!@ftp_pasv($this->_conn, true)) { $this->_error = self::ERROR_INVALID_MODE; $this->close(); @@ -148,7 +143,6 @@ public function open(array $args = []) */ public function close() { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_close($this->_conn); } @@ -163,10 +157,8 @@ public function close() * * @SuppressWarnings(PHPMD.ErrorControlOperator) */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed public function mkdir($dir, $mode = 0777, $recursive = true) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_mkdir($this->_conn, $dir); } @@ -178,10 +170,8 @@ public function mkdir($dir, $mode = 0777, $recursive = true) * * @SuppressWarnings(PHPMD.ErrorControlOperator) */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed public function rmdir($dir, $recursive = false) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_rmdir($this->_conn, $dir); } @@ -194,7 +184,6 @@ public function rmdir($dir, $recursive = false) */ public function pwd() { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_pwd($this->_conn); } @@ -208,7 +197,6 @@ public function pwd() */ public function cd($dir) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_chdir($this->_conn, $dir); } @@ -222,7 +210,6 @@ public function cd($dir) public function read($filename, $dest = null) { if (is_string($dest)) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $result = ftp_get($this->_conn, $dest, $filename, $this->_config['file_mode']); } else { if (is_resource($dest)) { @@ -234,13 +221,11 @@ public function read($filename, $dest = null) return false; } - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $result = ftp_fget($this->_conn, $stream, $filename, $this->_config['file_mode']); if (is_null($dest)) { fseek($stream, 0); $result = ''; - // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed,Ecg.Security.ForbiddenFunction.Found for ($result = ''; $s = fread($stream, 4096); $result .= $s); fclose($stream); } @@ -257,12 +242,9 @@ public function read($filename, $dest = null) * * @SuppressWarnings(PHPMD.ErrorControlOperator) */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed public function write($filename, $src, $mode = null) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found if (is_string($src) && is_readable($src)) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_put($this->_conn, $filename, $src, $this->_config['file_mode']); } else { if (is_string($src)) { @@ -276,7 +258,6 @@ public function write($filename, $src, $mode = null) return false; } - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $result = ftp_fput($this->_conn, $filename, $stream, $this->_config['file_mode']); if (is_string($src)) { fclose($stream); @@ -295,7 +276,6 @@ public function write($filename, $src, $mode = null) */ public function rm($filename) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_delete($this->_conn, $filename); } @@ -310,7 +290,6 @@ public function rm($filename) */ public function mv($src, $dest) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_rename($this->_conn, $src, $dest); } @@ -325,17 +304,14 @@ public function mv($src, $dest) */ public function chmod($filename, $mode) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found return @ftp_chmod($this->_conn, $mode, $filename); } /** * @SuppressWarnings(PHPMD.ErrorControlOperator) */ - // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass public function ls($grep = null) { - // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged,Ecg.Security.ForbiddenFunction.Found $ls = @ftp_nlist($this->_conn, '.'); $list = []; @@ -352,7 +328,6 @@ public function ls($grep = null) protected function _tmpFilename($new = false) { if ($new || !$this->_tmpFilename) { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $this->_tmpFilename = tempnam(md5(uniqid(rand(), true)), ''); } return $this->_tmpFilename; diff --git a/lib/Varien/Object.php b/lib/Varien/Object.php index 9a4540b077a..0e830507575 100644 --- a/lib/Varien/Object.php +++ b/lib/Varien/Object.php @@ -638,7 +638,6 @@ public function __call($method, $args) return isset($this->_data[$key]); } throw new Varien_Exception( - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found 'Invalid method ' . get_class($this) . '::' . $method . '(' . print_r($args, true) . ')' ); } diff --git a/tests/unit/Base/XmlFileLoadingTest.php b/tests/unit/Base/XmlFileLoadingTest.php index 7bd1f3cd941..5131a5ddca1 100644 --- a/tests/unit/Base/XmlFileLoadingTest.php +++ b/tests/unit/Base/XmlFileLoadingTest.php @@ -55,7 +55,6 @@ public function testXmlReaderIsValid(string $filepath): void */ public function provideXmlFiles(): array { - // phpcs:ignore Ecg.Security.ForbiddenFunction.Found $root = realpath(__DIR__ . '/../../../') . '/'; return [ diff --git a/tests/unit/Mage/Core/Model/Security/HtmlEscapedStringTest.php b/tests/unit/Mage/Core/Model/Security/HtmlEscapedStringTest.php index f6148f44e0d..d762310675e 100644 --- a/tests/unit/Mage/Core/Model/Security/HtmlEscapedStringTest.php +++ b/tests/unit/Mage/Core/Model/Security/HtmlEscapedStringTest.php @@ -35,7 +35,6 @@ class HtmlEscapedStringTest extends TestCase */ public function testToSting(string $expectedResult, string $string, ?array $allowedTags): void { - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $this->subject = new Mage_Core_Model_Security_HtmlEscapedString($string, $allowedTags); $this->assertSame($expectedResult, $this->subject->__toString()); } @@ -48,7 +47,6 @@ public function testToSting(string $expectedResult, string $string, ?array $allo */ public function testGetUnescapedValue(string $expectedResult, string $string, ?array $allowedTags): void { - // phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation $this->subject = new Mage_Core_Model_Security_HtmlEscapedString($string, $allowedTags); $this->assertSame($expectedResult, $this->subject->getUnescapedValue()); }