Skip to content

[Issue] Cleanup: don't use void return value from method calls. #39524

Open
@m2-assistant

Description

This issue is automatically created based on existing pull request: #39516: Cleanup: don't use void return value from method calls.


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)

Metadata

Assignees

Type

No type

Projects

  • Status

    Ready for Development

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions