1 | <?php |
||
20 | trait BackwardCompatibleMethodsTrait |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * Sets constructor arguments used on instance instantiation |
||
25 | * |
||
26 | * @param array $arguments |
||
27 | * @return $this|self |
||
|
|||
28 | * |
||
29 | * @deprecated You should use ObjectDefinition::withConstructorArgument(). |
||
30 | * This will be removed in the next major release. |
||
31 | */ |
||
32 | public function setConstructArgs(array $arguments) |
||
39 | |||
40 | /** |
||
41 | * Set a method to be called when resolving this definition |
||
42 | * |
||
43 | * @param string $name Method name |
||
44 | * @param array $arguments Method parameters |
||
45 | * |
||
46 | * @return $this|self |
||
47 | * |
||
48 | * @deprecated You should use ObjectDefinition::callMethod(). This |
||
49 | * will be removed in the next major release. |
||
50 | */ |
||
51 | public function setMethod($name, array $arguments = []) |
||
59 | |||
60 | /** |
||
61 | * Sets property value when resolving this definition |
||
62 | * |
||
63 | * @param string $name The property name |
||
64 | * @param mixed $value The property value |
||
65 | * |
||
66 | * @return $this|self |
||
67 | * |
||
68 | * @deprecated You should use ObjectDefinition::assignProperty(). This |
||
69 | * will be removed in the next major release. |
||
70 | */ |
||
71 | public function setProperty($name, $value) |
||
78 | } |
||
79 |
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.