Skip to content

Advice wanted about best practice #339

Description

@LauHypershop

Hi,

An issue I run into occasionally is that it's pretty common in Magento for a concrete class to implement a lot of methods not covered by its interface.

For example, we're usually pretty confident that a Product class is going to have a getData() method, and the \Magento\Catalog\Model\Product uses it fairly extensively. But the \Magento\Catalog\Api\Data\ProductInterface doesn't list that method. Any time you fetch a product from a ProductRepositoryInterface, PHPStan is going to complain that this method doesn't exist.

What's a good way of handling this? I can put an ignoreErrors in my phpstan.neon like this:

- '#Call to an undefined method Magento\\Catalog\\Api\\Data\\ProductInterface::getData\(\).#'

However, this is going to lead to a fairly bloated file. It's also awkward to scale across multiple projects, to keep that list consistent as you discover more examples. Is there a better way to go about it?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions