1 | <?php |
||
10 | class TreeNode extends Node { |
||
11 | |||
12 | /** |
||
13 | * SRFTreeElement constructor. |
||
14 | * |
||
15 | * @param \SMWResultArray[] | null $row |
||
16 | */ |
||
17 | 5 | public function __construct( $row = null ) { |
|
20 | |||
21 | /** |
||
22 | * @return string |
||
23 | */ |
||
24 | 5 | public function getHash() { |
|
34 | |||
35 | /** |
||
36 | * @return null|\SMWDIWikiPage |
||
37 | */ |
||
38 | 5 | public function getResultSubject() { |
|
48 | |||
49 | /** |
||
50 | * @param NodeInterface $child |
||
51 | * |
||
52 | * @return NodeTrait |
||
|
|||
53 | * @throws Exception |
||
54 | */ |
||
55 | 5 | public function addChild( NodeInterface $child ) { |
|
65 | |||
66 | } |
||
67 | |||
68 |
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.