1 | <?php |
||
20 | trait LastRecalculation |
||
21 | { |
||
22 | use NumericalId; |
||
23 | use TimeEntity; |
||
24 | |||
25 | //<editor-fold desc="Fields"> |
||
26 | /** |
||
27 | * @ORM\Column(type="integer", nullable=false) |
||
28 | * @var int |
||
29 | */ |
||
30 | private $version; |
||
31 | //</editor-fold desc="Fields"> |
||
32 | |||
33 | //<editor-fold desc="Public Methods"> |
||
34 | /** |
||
35 | * @return int |
||
36 | */ |
||
37 | public function getVersion(): int |
||
41 | |||
42 | /** |
||
43 | * @param int $version |
||
44 | * @return $this|LastRecalculation |
||
|
|||
45 | */ |
||
46 | public function setVersion(int $version): LastRecalculation |
||
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.