Skip to content

Conversation

@sreichel
Copy link
Contributor

@sreichel sreichel commented Nov 7, 2025

  • replace empty/isset checks with is_null
  • updated docblocks
  • renamed some vars to follow parent method

[OK] Baseline generated with 1292 errors.

@sreichel sreichel added the chore label Nov 7, 2025
Copilot AI review requested due to automatic review settings November 7, 2025 04:42
@github-actions github-actions bot added Component: Core Relates to Mage_Core Component: Catalog Relates to Mage_Catalog Component: Reports Relates to Mage_Reports Component: Checkout Relates to Mage_Checkout Component: lib/Varien Relates to lib/Varien Component: Sales Relates to Mage_Sales Component: Usa Relates to Mage_Usa Component: Customer Relates to Mage_Customer Component: Eav Relates to Mage_Eav Component: Adminhtml Relates to Mage_Adminhtml Component: Captcha Relates to Mage_Captcha Component: Admin Relates to Mage_Admin Component: Shipping Relates to Mage_Shipping Component: Rule Relates to Mage_Rule Component: CatalogSearch Relates to Mage_CatalogSearch Component: Install Relates to Mage_Install Component: lib/* Relates to lib/* phpstan labels Nov 7, 2025
Copy link
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 improves type safety and code quality by converting empty() checks to is_null() checks where properties are explicitly nullable, updating docblock types to include null, adding missing @throws annotations, and simplifying various code patterns. These changes resolve numerous PHPStan errors as evidenced by the removed entries in the baseline file.

Key changes:

  • Replaced empty() with is_null() for property initialization checks across 20+ files
  • Updated docblock type hints to include null for properties that can be null
  • Added missing @throws annotations to methods that can throw exceptions
  • Simplified logic by removing redundant conditions and unused variables

Reviewed Changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/Varien/Io/Sftp.php Added use statement, improved docblocks, removed return value from disconnect() call
lib/Varien/Data/Form/Abstract.php Changed empty() to is_null() for $_elements check
app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php Updated return type to include null, removed unused $info variable
app/code/core/Mage/Shipping/Model/Shipping.php Changed empty() to is_null() for $_result check
app/code/core/Mage/Shipping/Model/Carrier/Abstract.php Updated docblock type to include null
app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php Removed unused variables and isset() check
app/code/core/Mage/Sales/Model/Quote.php Added type hint comment for $message variable
app/code/core/Mage/Sales/Model/Order/Shipment.php Changed empty() to is_null() for collection checks
app/code/core/Mage/Sales/Model/Order/Creditmemo.php Changed empty() to is_null() for $_items check
app/code/core/Mage/Rule/Model/Condition/Abstract.php Updated docblock types to include null
app/code/core/Mage/Rule/Model/Abstract.php Changed empty() to is_null() for $_conditions check
app/code/core/Mage/Reports/Model/Resource/Entity/Summary/Collection/Abstract.php Changed empty() to is_null() for $_entityCollection check
app/code/core/Mage/Install/Model/Installer/Db/Abstract.php Changed isset() to is_null() for $_connection check
app/code/core/Mage/Eav/Model/Entity/Type.php Changed empty() to is_null() for $_sets check
app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php Changed empty() to is_null() for $_entity check, added @throws
app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php Changed empty() to is_null() for backend/frontend/source checks, added @throws
app/code/core/Mage/Eav/Model/Entity/Abstract.php Changed empty() to is_null() for $_type check, added @throws
app/code/core/Mage/Customer/Helper/Data.php Updated docblock class names, changed empty() to is_null()
app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php Initialized $_resource to null, simplified field selection logic, updated getResource() check
app/code/core/Mage/Core/Model/Mysql4/Design/Theme/Collection.php Added unused parameters to load() method signature
app/code/core/Mage/Core/Model/Design/Package.php Updated docblock type to include null
app/code/core/Mage/Core/Model/Design/Fallback.php Updated docblock types, added @throws annotations
app/code/core/Mage/Core/Model/App.php Changed empty() to is_null() for request/response checks
app/code/core/Mage/Core/Model/Abstract.php Updated docblock type, added multiple @throws annotations
app/code/core/Mage/Checkout/Model/Type/Onepage.php Updated docblock type to include null
app/code/core/Mage/CatalogSearch/Helper/Data.php Changed isset() to is_null() for $_queryText check
app/code/core/Mage/Catalog/Model/Url.php Updated docblock type, added @throws annotations
app/code/core/Mage/Catalog/Model/Resource/Config.php Updated docblock type, removed extra spaces, added @throws
app/code/core/Mage/Catalog/Model/Resource/Category.php Updated docblock types to include null
app/code/core/Mage/Captcha/Model/Zend.php Changed empty() to is_null() for $_helper check
app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php Added @throws, renamed $e to $exception, removed isset checks, moved comment
app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php Added @throws, renamed $e to $exception, changed isset() to simple condition
app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php Added @throws, renamed $e to $exception, changed isset() to simple condition
app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php Changed isset() to !is_null()
app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Main.php Added string casts for integer constant values
app/code/core/Mage/Admin/Model/Resource/Roles.php Renamed $role to $object parameter, added proper type hints and @throws
.phpstan.dist.baseline.neon Removed 132 resolved PHPStan errors

@sreichel
Copy link
Contributor Author

sreichel commented Nov 7, 2025

Merged. Looks safe. Tested. Tests pass.

@sreichel sreichel merged commit dc4841c into OpenMage:main Nov 7, 2025
20 checks passed
@sreichel sreichel deleted the phpstan/falsy-empty branch November 7, 2025 05:02
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 7, 2025

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

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

Labels

chore Component: Admin Relates to Mage_Admin Component: Adminhtml Relates to Mage_Adminhtml Component: Captcha Relates to Mage_Captcha Component: Catalog Relates to Mage_Catalog Component: CatalogSearch Relates to Mage_CatalogSearch Component: Checkout Relates to Mage_Checkout Component: Core Relates to Mage_Core Component: Customer Relates to Mage_Customer Component: Eav Relates to Mage_Eav Component: Install Relates to Mage_Install Component: lib/Varien Relates to lib/Varien Component: lib/* Relates to lib/* Component: Reports Relates to Mage_Reports Component: Rule Relates to Mage_Rule Component: Sales Relates to Mage_Sales Component: Shipping Relates to Mage_Shipping Component: Usa Relates to Mage_Usa phpstan

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant