Issues (139)

Model/Data/CardId.php (1 issue)

1
<?php
2
/**
3
 * Copyright © Getnet. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See LICENSE for license details.
7
 */
8
9
declare(strict_types=1);
10
11
namespace Getnet\PaymentMagento\Model\Data;
12
13
use Getnet\PaymentMagento\Api\Data\CardIdInterface;
14
use Magento\Framework\Api\AbstractSimpleObject;
15
16
/**
17
 * Class Card Id - Model data.
18
 */
19
class CardId extends AbstractSimpleObject implements CardIdInterface
20
{
21
    /**
22
     * @inheritdoc
23
     */
24
    public function getCardId()
25
    {
26
        return $this->_get(CardIdInterface::GETNET_CARD_ID);
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32
    public function setCardId($cardId)
33
    {
34
        return $this->setData(CardIdInterface::GETNET_CARD_ID, $cardId);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->setData(Ge...ETNET_CARD_ID, $cardId) returns the type Getnet\PaymentMagento\Model\Data\CardId which is incompatible with the return type mandated by Getnet\PaymentMagento\Ap...dInterface::setCardId() of void.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
35
    }
36
}
37