Skip to content

Should getQty() return int/float or string? #18094

@sreichel

Description

@sreichel

Summary

  • Magento 2.2-dev/2.3-dev
  • PHP7.1 (strict)

PHPDocs blocks say getQty() should return float/int, but in most cases it returns a string. This is no problem until I use strict type declaration for my own extensions and trust in annotations.

Examples

Magento\Catalog\Model\Product

    /**
     * Get quantity for product
     *
     * @return float
     */
    public function getQty()
    {
        return $this->getData('qty');
    }

I'd expect to get a float returned, but you'll get a string ...

Proposed solution

  1. how to fix?
    a. cast to float in getters?
    b. cast to float in setters?

  2. where to fix?
    a. fix step by step?
    b. fix all occurrence?

Please let me know, how to fix before i create PRs.

Metadata

Metadata

Assignees

Labels

Component: CatalogFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions