| 1 | <?php |
||
| 8 | trait ManufacturerTrait |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var boolean |
||
| 12 | * |
||
| 13 | * @ORM\Column(type="boolean") |
||
| 14 | */ |
||
| 15 | protected $consignment = false; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * This is the last stock movement used in reports |
||
| 19 | * This implies that stock movements can't be changed |
||
| 20 | * |
||
| 21 | * @var StockMovementInterface|null |
||
| 22 | * |
||
| 23 | * @ORM\ManyToOne(targetEntity="Loevgaard\DandomainStock\Entity\StockMovement") |
||
| 24 | */ |
||
| 25 | protected $consignmentLastStockMovement; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @return bool |
||
| 29 | */ |
||
| 30 | public function isConsignment(): bool |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param bool $consignment |
||
| 37 | * @return ManufacturerTrait |
||
|
|
|||
| 38 | */ |
||
| 39 | public function setConsignment(bool $consignment) |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @return StockMovementInterface|null |
||
| 47 | */ |
||
| 48 | public function getConsignmentLastStockMovement(): ?StockMovementInterface |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param StockMovementInterface|null $consignmentLastStockMovement |
||
| 55 | * @return ManufacturerTrait |
||
| 56 | */ |
||
| 57 | public function setConsignmentLastStockMovement(?StockMovementInterface $consignmentLastStockMovement) |
||
| 62 | } |
In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.
If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.