1 | <?php |
||
9 | trait MenuItemTrait { |
||
10 | |||
11 | public function setContent($content){ |
||
24 | |||
25 | /** |
||
26 | * @param string $placeholder |
||
27 | * @param string $icon |
||
28 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem |
||
29 | */ |
||
30 | public function asSearchInput($placeholder=NULL,$icon=NULL){ |
||
40 | |||
41 | /** |
||
42 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem |
||
43 | */ |
||
44 | public function asDivider(){ |
||
50 | |||
51 | /** |
||
52 | * @param string $caption |
||
53 | * @param string $icon |
||
54 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem |
||
55 | */ |
||
56 | public function asHeader($caption=NULL,$icon=NULL){ |
||
64 | } |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.