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

Cleanup: don't use void return value from method calls. #39516

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

Conversation

hostep
Copy link
Contributor

@hostep hostep commented Dec 31, 2024

Description (*)

This is just some minor cleanup. Sometimes we called methods that didn't return anything (void) and then used that result value. Which is really not needed.

Found issues while running phpstan on level 0 on the entire codebase:

$ vendor/bin/phpstan analyse -c ./dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/phpstan.neon --level=0 . | grep -B3 'is used'
 20783/20783 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

  Line   app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  84     Result of method Magento\Downloadable\Model\Product\TypeHandler\AbstractTypeHandler::clear() (void) is used.
--
 ------ -------------------------------------------------------------------------------------------------------
  Line   app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group.php
 ------ -------------------------------------------------------------------------------------------------------
  164    Result of method Magento\Framework\Model\ResourceModel\Db\AbstractDb::saveNewObject() (void) is used.
  181    Result of method Magento\Framework\Model\ResourceModel\Db\AbstractDb::updateObject() (void) is used.
--
 ------ ----------------------------------------------------------------------------------------
  Line   app/code/Magento/Store/Block/Store/Switcher.php
 ------ ----------------------------------------------------------------------------------------
  70     Result of method Magento\Framework\View\Element\Template::_construct() (void) is used.
--
 ------ ----------------------------------------------------------------------------------
  Line   lib/internal/Magento/Framework/HTTP/Client/Socket.php
 ------ ----------------------------------------------------------------------------------
  423    Result of method Magento\Framework\HTTP\Client\Socket::doError() (void) is used.
  470    Result of method Magento\Framework\HTTP\Client\Socket::doError() (void) is used.

This is my ongoing effort on getting the entire Magento codebase clean so running phpstan on level 0 no longer gives any errors anymore (after this PR, we have about ~440 issues to go still ...)

Also see magento/magento2-page-builder#881

Related Pull Requests

magento/magento2-page-builder#881

Fixed Issues (if relevant)

N/A

Manual testing scenarios (*)

  1. In theory, nothing should change at runtime by the changes introduced here, not sure what needs to be tested except for the phpstan check ...
  2. If you do want to test the output of PHPstan, maybe best run it on app/code/Magento/Downloadable, app/code/Magento/Eav, app/code/Magento/Store & lib/internal/Magento/Framework/HTTP/ directories only, as running it on the entire codebase might take a very long time (multiple hours sometimes, depending on how strong your machine is) ...

Questions or comments

Check the first commit to see the real changes, the second commit deals with fixing static test failures.

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)

Copy link

m2-assistant bot commented Dec 31, 2024

Hi @hostep. 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.

@hostep
Copy link
Contributor Author

hostep commented Dec 31, 2024

@magento run all tests

@hostep hostep force-pushed the fixed-returning-from-method-that-doesnt-return branch from bb90c4c to 7774d4a Compare January 2, 2025 20:00
@hostep
Copy link
Contributor Author

hostep commented Jan 2, 2025

@magento run all tests

@hostep
Copy link
Contributor Author

hostep commented Jan 2, 2025

@magento run Static Tests, Integration Tests

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

Successfully merging this pull request may close these issues.

1 participant