| 1 | <?php |
||
| 19 | trait Table |
||
| 20 | { |
||
| 21 | //<editor-fold desc="Fields"> |
||
| 22 | /** |
||
| 23 | * @ORM\Column(name="table_id", type="smallint", nullable=true) |
||
| 24 | * @var int|null |
||
| 25 | */ |
||
| 26 | private $table; |
||
| 27 | //</editor-fold desc="Fields"> |
||
| 28 | |||
| 29 | //<editor-fold desc="Public Methods"> |
||
| 30 | /** |
||
| 31 | * @return int|null |
||
| 32 | */ |
||
| 33 | public function getTable(): ?int |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param int|null $table |
||
| 40 | * @return $this|Table |
||
|
|
|||
| 41 | * @throws ValueNotValid |
||
| 42 | */ |
||
| 43 | public function setTable(?int $table) |
||
| 51 | //</editor-fold desc="Public Methods"> |
||
| 52 | } |
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.