Skip to content

code refactor, php8.x adjustmentts, param types, etc #39868

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

Open
wants to merge 4 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

jakwinkler
Copy link

@jakwinkler jakwinkler commented Apr 26, 2025

Description (*)

Just some type fixes + upgrade to php8.x
Needs to be tested and validated properly, as some method properties still do not match in core.

I've made this fix due to this code:

   $items = $this->optionManagement->getItems(
         Product::ENTITY,
         $attributeCode
   );

as it suppose to be an integer, but string has to be passed as the $1 parameter

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] code refactor, php8.x adjustmentts, param types, etc #39875: code refactor, php8.x adjustmentts, param types, etc

Copy link

m2-assistant bot commented Apr 26, 2025

Hi @jakwinkler. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@jakwinkler
Copy link
Author

@magento run all tests

1 similar comment
@jakwinkler
Copy link
Author

@magento run all tests

@jakwinkler
Copy link
Author

@magento run all tests

@engcom-Hotel
Copy link
Contributor

@magento create issue

@ihor-sviziev
Copy link
Contributor

@jakwinkler, I do agree with these changes in general, but they most likely will break anyone who extended from these interfaces or classes.
Usually it takes too much time for approve such changes, but we can wait

Copy link

@Copilot 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 updates several Magento EAV classes and interfaces to use PHP 8 type declarations and return types, and adjusts docblocks for consistency.

  • Added scalar and union type hints to methods (e.g., string, int, string|int, array, bool)
  • Updated return type declarations across repository and management classes/interfaces
  • Refined docblocks and imports to match new signatures

Reviewed Changes

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

File Description
app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php Added parameter and return type hints; adjusted docblocks
app/code/Magento/Eav/Model/AttributeRepository.php Introduced method return types and scalar type hints; imports
app/code/Magento/Eav/Api/AttributeRepositoryInterface.php Updated interface method signatures with type hints and return types
app/code/Magento/Eav/Api/AttributeOptionManagementInterface.php Added scalar and union types in method signatures and docblocks
Comments suppressed due to low confidence (1)

app/code/Magento/Eav/Api/AttributeOptionManagementInterface.php:40

  • The getItems method may throw NoSuchEntityException when the attribute does not exist (via loadAttribute). Consider adding @throws NoSuchEntityException to the docblock for completeness.
     * @throws \Magento\Framework\Exception\NoSuchEntityException

@@ -226,7 +228,7 @@ public function getItems($entityType, $attributeCode)
* @return void
* @throws NoSuchEntityException
*/
protected function validateOption($attribute, $optionId)
protected function validateOption(EavAttributeInterface $attribute, int $optionId): void
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

The public delete method accepts string|int $optionId but validateOption is declared to accept only int, which may lead to type mismatches under strict mode. Consider updating validateOption to accept string|int and cast to int internally, or enforce int at the public API boundary.

Copilot uses AI. Check for mistakes.

@ihor-sviziev
Copy link
Contributor

@jakwinkler, please review the comments from Copilot and let us know if you would like anything to be fixed based on them. If no, I'll review the pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P3 May be fixed according to the position in the backlog. Progress: review
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

[Issue] code refactor, php8.x adjustmentts, param types, etc
3 participants