1 | <?php |
||
15 | class HtmlTR extends HtmlSemCollection { |
||
16 | use TableElementTrait; |
||
17 | private $_tdTagName; |
||
18 | private $_container; |
||
19 | private $_row; |
||
20 | |||
21 | public function __construct($identifier) { |
||
25 | |||
26 | public function setColCount($colCount) { |
||
34 | |||
35 | /** |
||
36 | * |
||
37 | * {@inheritDoc} |
||
38 | * |
||
39 | * @see \Ajax\common\html\HtmlCollection::createItem() |
||
40 | */ |
||
41 | protected function createItem($value) { |
||
47 | |||
48 | public function setTdTagName($tagName="td") { |
||
51 | |||
52 | /** |
||
53 | * Define the container (HtmlTableContent) and the num of the row |
||
54 | * @param HtmlTableContent $container |
||
55 | * @param int $row |
||
56 | */ |
||
57 | public function setContainer($container, $row) { |
||
61 | |||
62 | /** |
||
63 | * Sets values to the row cols |
||
64 | * @param mixed $values |
||
65 | */ |
||
66 | public function setValues($values=array()) { |
||
82 | |||
83 | /** |
||
84 | * Removes the col at $index |
||
85 | * @param int $index the index of the col to remove |
||
86 | * @return \Ajax\semantic\html\content\table\HtmlTR |
||
87 | */ |
||
88 | public function delete($index) { |
||
92 | |||
93 | public function mergeCol($colIndex=0) { |
||
96 | |||
97 | public function mergeRow($colIndex=0) { |
||
100 | |||
101 | public function getColPosition($colIndex) { |
||
122 | |||
123 | public function conditionalCellFormat($callback, $format) { |
||
130 | |||
131 | public function conditionalRowFormat($callback, $format) { |
||
137 | |||
138 | public function containsStr($needle) { |
||
146 | |||
147 | public function apply($callback) { |
||
151 | |||
152 | public function applyCells($callback) { |
||
159 | } |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: