Skip to content

Conversation

@ajbonner
Copy link
Contributor

@ajbonner ajbonner commented Dec 8, 2025

Description (*)

In Mage_Checkout_OnepageController the return docblock for _initInvoice() shows it returning the Mage_Sales_Model_Service_Order when it's returning $invoice which is the return value of Mage_Sales_Model_Service_Order::prepareInvoice(array $qtys = []): Mage_Sales_Model_Order_Invoice.

So this PR updates the return type docblock and the @var annotation to reflect the correct type. No executable code changes other than docs.

Manual testing scenarios (*)

  1. Open app/code/core/Mage/Checkout/controllers/OnepageController.php
  2. Navigate to \Mage_Checkout_OnepageController::_initInvoice (line 551)
  3. Trace line 559 to the prepareInvoice() invocation and compare types returned by that method vs the @var annotation on line 558. $invoice is then returned which is an Mage_Sales_Model_Order_Invoice not a Mage_Sales_Model_Service_Order

Contribution checklist (*)

  • [*] Pull request has a meaningful description of its purpose
  • [* ] All commits are accompanied by meaningful commit messages
  • [*] All automated tests passed successfully (all builds are green)

@github-actions github-actions bot added the Component: Checkout Relates to Mage_Checkout label Dec 8, 2025
@ajbonner
Copy link
Contributor Author

ajbonner commented Dec 8, 2025

Looking at the PHPStan output, this seems to fix one of the baseline errors as well, so the baseline would need to be updated to remove the fixed failing check.

Error: Ignored error pattern "Call to an undefined method Mage_Sales_Model_Service_Order::register()." (method.notFound) in path /home/runner/work/magento-lts/magento-lts/app/code/core/Mage/Checkout/controllers/OnepageController.php was not matched in reported errors.

register() is not found because PHPStan was looking at Mage_Sales_Model_Service_Order rather than Mage_Sales_Model_Order_Invoice

In fixing the annotations for Mage_Sales_Model_Order_Invoice,
PHPStan can now correctly find the register() method.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 8, 2025

@sreichel sreichel added the chore label Dec 8, 2025
@sreichel sreichel merged commit ecc8775 into OpenMage:main Dec 8, 2025
21 checks passed
@sreichel
Copy link
Contributor

sreichel commented Dec 8, 2025

Thanks.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants