Skip to content

phpstan: variable.implicitArray (1)#5551

Open
sreichel wants to merge 2 commits intoOpenMage:mainfrom
sreichel:phpstan/mixid-1
Open

phpstan: variable.implicitArray (1)#5551
sreichel wants to merge 2 commits intoOpenMage:mainfrom
sreichel:phpstan/mixid-1

Conversation

@sreichel
Copy link
Copy Markdown
Contributor

Description (*)

Minor phpstan fixes.

Copilot AI review requested due to automatic review settings April 29, 2026 00:13
@sreichel sreichel added the chore label Apr 29, 2026
@github-actions github-actions Bot added Component: PayPal Relates to Mage_Paypal Component: Core Relates to Mage_Core Component: Catalog Relates to Mage_Catalog Component: Cms Relates to Mage_Cms Component: Checkout Relates to Mage_Checkout Component: lib/Varien Relates to lib/Varien Component: Sales Relates to Mage_Sales Template : base Relates to base template Component: Adminhtml Relates to Mage_Adminhtml Component: Page Relates to Mage_Page Component: CurrencySymbol Relates to Mage_CurrencySymbol Component: Newsletter Relates to Mage_Newsletter Component: Downloadable Relates to Mage_Downloadable Component: Bundle Relates to Mage_Bundle Component: CatalogIndex Relates to Mage_CatalogIndex Component: Paygate Relates to Mage_Paygate Component: lib/* Relates to lib/* labels Apr 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR applies minor PHPStan-driven fixes by eliminating implicit array creation and a few related baseline suppressions across core, lib, and template code.

Changes:

  • Initialize variables as arrays before assigning offsets to satisfy variable.implicitArray.
  • Harden Varien_Object::_addFullNames() against non-array _data to avoid invalid array operations.
  • Remove PHPStan baseline entries/files that are no longer needed after the fixes (including class name case ignore).

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/Varien/Object.php Adds array-type guards before sync-field mapping to avoid invalid array operations.
lib/Varien/Io/File.php Initializes $owner/$group/$world arrays before offset assignment in permission parsing.
app/design/frontend/base/default/template/paypal/payment/redirect.phtml Updates docblock class references to correct case used in codebase and removes related baseline need.
app/code/core/Mage/Sales/Model/Order/Pdf/Shipment.php Initializes $lines before nested offset usage in header rendering.
app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php Initializes $lines before nested offset usage in header rendering.
app/code/core/Mage/Sales/Model/Order/Pdf/Creditmemo.php Initializes $lines before nested offset usage in header rendering.
app/code/core/Mage/Paygate/controllers/Authorizenet/PaymentController.php Initializes $result before setting result keys in cancel action.
app/code/core/Mage/Paygate/controllers/Adminhtml/Paygate/Authorizenet/PaymentController.php Initializes $result before setting result keys in cancel action.
app/code/core/Mage/Page/Block/Html/Toplinks.php Initializes $toplinkInfo before populating it.
app/code/core/Mage/Newsletter/Model/Resource/Subscriber.php Initializes $data before populating update payload.
app/code/core/Mage/Downloadable/Model/Resource/Link.php Initializes $dataToInsert before population.
app/code/core/Mage/CurrencySymbol/Model/System/Currencysymbol.php Initializes $value before writing nested option structure.
app/code/core/Mage/Core/Model/File/Validator/AvailablePath.php Initializes $options before setting file_mask.
app/code/core/Mage/Cms/Model/Resource/Page/Collection.php Initializes $data before setting value/label.
app/code/core/Mage/Checkout/controllers/OnepageController.php Initializes $result early for consistent array usage.
app/code/core/Mage/CatalogIndex/Model/Resource/Indexer/Minimalprice.php Initializes $conditions before appending SQL conditions.
app/code/core/Mage/CatalogIndex/Model/Resource/Indexer/Abstract.php Initializes $conditions before appending SQL conditions.
app/code/core/Mage/CatalogIndex/Model/Indexer/Minimalprice.php Initializes $data and $search arrays before offset assignment.
app/code/core/Mage/Catalog/Model/Resource/Product.php Initializes $updateCond before appending conditions.
app/code/core/Mage/Catalog/Model/Product/Image.php Initializes $path prior to usage to satisfy PHPStan (see review nit).
app/code/core/Mage/Catalog/Model/Layer/Filter/Item.php Initializes $params before setting URL generation flags.
app/code/core/Mage/Catalog/Block/Layer/State.php Initializes $params before setting URL generation flags.
app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php Ensures $defaultValues is always defined and reorders a couple initializations.
app/code/core/Mage/Adminhtml/controllers/TagController.php Initializes $data before offset assignment; tightens return docblock.
app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php Initializes $params before use.
app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Form.php Initializes $data before building URL params.
app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php Initializes $data before building URL params; removes stray whitespace line.
app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Action.php Initializes $actions before conditional pushes.
app/code/core/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg/Content.php Initializes $config before nested offset assignment.
.phpstan.dist.baselines/variable.undefined.php Removes baseline entry now fixed in bundle JSON config logic.
.phpstan.dist.baselines/variable.implicitArray.php Removes many no-longer-needed ignores after explicit array initialization.
.phpstan.dist.baselines/offsetAccess.notFound.php Removes baseline entry now handled by guards in Varien_Object.
.phpstan.dist.baselines/empty.notAllowed.php Updates ignore count after reducing one empty() usage.
.phpstan.dist.baselines/class.nameCase.php Removes obsolete baseline file (now fixed in template docblock).
.phpstan.dist.baselines/argument.type.php Removes obsolete baseline entry after guarding array usage in Varien_Object.
.phpstan.dist.baselines/_loader.php Stops loading the removed class.nameCase baseline file.

Comment thread app/code/core/Mage/Catalog/Model/Product/Image.php
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
10.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@sreichel sreichel requested a review from Hanmac April 29, 2026 00:24
Comment on lines +56 to +61
$params = [];
$params['_current'] = true;
$params['_use_rewrite'] = true;
$params['_query'] = $filterState;
$params['_escape'] = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to have $params = [ ... ]?

with [ ... ] being a Multiline Array?

Or better return Mage::getUrl('*/*/*', [ ... ]);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will be to much work.

Lets keep it simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Component: Adminhtml Relates to Mage_Adminhtml Component: Bundle Relates to Mage_Bundle Component: Catalog Relates to Mage_Catalog Component: CatalogIndex Relates to Mage_CatalogIndex Component: Checkout Relates to Mage_Checkout Component: Cms Relates to Mage_Cms Component: Core Relates to Mage_Core Component: CurrencySymbol Relates to Mage_CurrencySymbol Component: Downloadable Relates to Mage_Downloadable Component: lib/Varien Relates to lib/Varien Component: lib/* Relates to lib/* Component: Newsletter Relates to Mage_Newsletter Component: Page Relates to Mage_Page Component: Paygate Relates to Mage_Paygate Component: PayPal Relates to Mage_Paypal Component: Sales Relates to Mage_Sales Template : base Relates to base template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants