-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fix incorrect return type for getOptionByCode method #39389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.4-develop
Are you sure you want to change the base?
Fix incorrect return type for getOptionByCode method #39389
Conversation
Hi @ihor-sviziev. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
@magento run all tests |
@magento create issue |
@magento run Static Tests |
@engcom-Hotel fixed |
As per this, moving it to review again. |
@magento run all tests |
@magento run all tests |
Manual testing is not required here, as this PR is updating return type of a method in doc block . Currently the build is failing hence moving it to Extended Testing. |
@magento run Functional Tests B2B, Functional Tests CE, Semantic Version Checker, WebAPI Tests |
@magento run Functional Tests EE |
Raised internal approval JIRA for the SVC failure. Moving this PR to Pending Approval now. We will proceed ahead on this once will get all the required approvals. ![]() |
There was a problem hiding this 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 pull request fixes an incorrect PHPDoc return type for the getOptionByCode method in the ItemInterface and its implementations, helping to reduce confusion and potential bugs during development.
- Updated PHPDoc in getOptionByCode to use union types (e.g. OptionInterface|null)
- Updated corresponding file in Quote module and standardized use statements in the Catalog module
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
app/code/Magento/Quote/Model/Quote/Item.php | Corrected PHPDoc return type in getOptionByCode for clarity. |
app/code/Magento/Catalog/Model/Product/Configuration/Item/ItemInterface.php | Updated PHPDoc comments and use statements for accurate type declarations. |
Description (*)
I've noticed that
\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::getOptionByCode
return type is defined as object all the time:magento2/app/code/Magento/Catalog/Model/Product/Configuration/Item/ItemInterface.php
Lines 24 to 30 in b2ce2a3
However, this interface implements 3 classes, and each of them returns object OR null, so it's a bug in the method definition on interface:
magento2/app/code/Magento/Quote/Model/Quote/Address/Item.php
Lines 200 to 210 in 6729b6e
magento2/app/code/Magento/Quote/Model/Quote/Item.php
Lines 726 to 738 in 2afe92f
magento2/app/code/Magento/Wishlist/Model/Item.php
Lines 697 to 709 in 795b2c6
This pull request fixes incorrect phpdoc block, which leads to confusion, which leads to bugs during development
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)
Resolved issues: