Question

From this \vendor\magento\module-wishlist\Pricing\ConfiguredPrice\ConfigurableProduct.php

File I find below code:

public function getConfiguredAmount(): \Magento\Framework\Pricing\Amount\AmountInterface
    {
        /** @var \Magento\Wishlist\Model\Item\Option $customOption */
        $customOption = $this->getProduct()->getCustomOption('simple_product');
        $product = $customOption ? $customOption->getProduct() : $this->getProduct();
        return $product->getPriceInfo()->getPrice(ConfiguredPriceInterface::CONFIGURED_PRICE_CODE)->getAmount();
    }

What the below code mean

public function getConfiguredAmount(): \Magento\Framework\Pricing\Amount\AmountInterface

Was it helpful?

Solution

It is a new feature in PHP 7 called Return type declarations.

Return type declarations specify the type of the value that will be returned from a function. The same types are available for return type declarations as are available for argument type declarations.

Relevant for your given code ;

When overriding a parent method, the child's method must match any return type declaration on the parent. If the parent doesn't define a return type, then the child method may do so.

You can read it more in new features notes - here

and detailed official documentation - here

Please don't hesitate to ping me in case of confusion.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top