Skip to content
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

[PHPDOC] Fix bad phpdoc \Magento\Sales\Model\Order\Email\Container\Template::$id property #39150

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

Conversation

dimitriBouteille
Copy link

@dimitriBouteille dimitriBouteille commented Sep 10, 2024

Description (*)

This PR fix the bad phpdoc for \Magento\Sales\Model\Order\Email\Container\Template::$id, actually $id is type int but in reality is string.

Capture d’écran du 2024-09-10 10-56-41

For example, with PHPSTAN is very complicated to setup the project with level 5 or higher :(

Capture d’écran du 2024-09-10 10-58-47

Workaround

Add @phpstan-ignore-next-line before call setTemplateId :(

Capture d’écran du 2024-09-10 11-00-08

Related Pull Requests

None

Fixed Issues (if relevant)

None

Manual testing scenarios (*)

Setup PHPSTAN with level 5 or higher and run check.

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] Fix bad \Magento\Sales\Model\Order\Email\Container\Template::$id property #39151: Fix bad \Magento\Sales\Model\Order\Email\Container\Template::$id property

Copy link

m2-assistant bot commented Sep 10, 2024

Hi @dimitriBouteille. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.

Add the comment under your pull request to deploy test or vanilla Magento instance:
  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ 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.

@dimitriBouteille
Copy link
Author

@magento run all tests

@engcom-Hotel
Copy link
Contributor

@magento create issue

@engcom-Hotel engcom-Hotel added the Priority: P3 May be fixed according to the position in the backlog. label Sep 10, 2024
@dimitriBouteille dimitriBouteille changed the title Fix bad \Magento\Sales\Model\Order\Email\Container\Template::$id property Fix bad phpdoc \Magento\Sales\Model\Order\Email\Container\Template::$id property Sep 10, 2024
@dimitriBouteille dimitriBouteille changed the title Fix bad phpdoc \Magento\Sales\Model\Order\Email\Container\Template::$id property [PHPDOC] Fix bad phpdoc \Magento\Sales\Model\Order\Email\Container\Template::$id property Sep 11, 2024
@orlangur orlangur self-assigned this Oct 11, 2024
@orlangur
Copy link
Contributor

Hi @dimitriBouteille! Is there some ongoing big effort at the moment to adopt PhpStan at certain level or something?

Generally, everywhere in Magento int in PHPDoc always assumes numeric string as well, please check #26930 (review) which we raised before on this. We can make some decision on how we're going to deal with this in general but changing PHPDoc at some random place is definitely not a way to do.

@dimitriBouteille
Copy link
Author

Hi @orlangur Thanks for your feedback :)

Today, if I want to set up PHPStan with level 5 (even worth testing a higher level) it is very complicated because the Magento code is not clean, a good part of the PHPDoc is not correct ...

The best solution to implement PHPStan today is to go through bitExpert/phpstan-magento and add several ignores in PHPStan. Ignoring rules is stupid, especially when the goal is to ensure the quality of the code.

Capture d’écran du 2024-10-14 15-39-35

I know that Magento has been around for a while and typing with PHP was complicated, but now with the arrival of PHP 8.x, we should still improve the typing. The idea is to improve PHPDoc because less cumbersome than modifying the code by adding the strict type (e.g : returns type, arguments type, ...).

Decisions made some time ago are one thing, but knowing how to evolve with your time to improve the code is better ❤️

Finally, I’m not sure that adding int from everywhere is a better solution than doing a real typing as I propose with these different PR: https://github.com/magento/magento2/pulls?q=is%3Aopen+is%3Apr+author%3AdimitriBouteille+phpdoc

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
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Fix bad \Magento\Sales\Model\Order\Email\Container\Template::$id property
3 participants