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

Improved type hints and declarations for \Magento\Quote\Model\Quote\Address\Total #9986

Merged
merged 4 commits into from
Jun 28, 2017
Merged

Improved type hints and declarations for \Magento\Quote\Model\Quote\Address\Total #9986

merged 4 commits into from
Jun 28, 2017

Conversation

schmengler
Copy link
Contributor

@schmengler schmengler commented Jun 19, 2017

This PR adds some proper type hints and docblocks related to the quote total.

Description

  • For better IDE support, Quote::getTotals() now has a return type of Total[] instead of array (via docblock). I traced down the called methods to verify the type and added missing type hints on the way.

  • The TotalFactory has been updated to return Total by default (previously there was no default value, so BC is ensured). The factory is used like a default generated factory in TotalsReader but needed to pass the class name to create(). This violates the POLA. Also,
    the return type hint is adjusted now (Total is no subtype of
    Total\AbstractTotal)

  • TotalReader::$baseTotalAmounts and TotalReader::$totalAmounts are now initialized as empty arrays. TotalReader::getAllTotalAmounts() did not return an array if no totals have been added.

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)
  • All automated tests passed successfully (all builds on Travis CI are green)

The factory is used like a default generated factory in TotalsReader but
needed to pass the class name to create(). This violates the POLA. Also,
the return type hint is adjusted now (Total is no subtype of
Total\AbstractTotal)
Otherwise getAllTotalAmounts() does not return an array if no totals
have been added. Same goes for $baseTotalAmounts
@davidalger davidalger self-assigned this Jun 20, 2017
@davidalger davidalger added this to the June 2017 milestone Jun 20, 2017
@davidalger davidalger self-requested a review June 20, 2017 19:12
@magento-team magento-team merged commit 99a4d69 into magento:develop Jun 28, 2017
magento-team pushed a commit that referenced this pull request Jun 28, 2017
…e\Model\Quote\Address\Total #9986

 - fixed static tests
magento-team pushed a commit that referenced this pull request Jun 28, 2017
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.

3 participants