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