1
|
|
|
<?php |
2
|
|
|
/************************************************************************ |
3
|
|
|
* OVIDENTIA http://www.ovidentia.org * |
4
|
|
|
************************************************************************ |
5
|
|
|
* Copyright (c) 2003 by CANTICO ( http://www.cantico.fr ) * |
6
|
|
|
* * |
7
|
|
|
* This file is part of Ovidentia. * |
8
|
|
|
* * |
9
|
|
|
* Ovidentia is free software; you can redistribute it and/or modify * |
10
|
|
|
* it under the terms of the GNU General Public License as published by * |
11
|
|
|
* the Free Software Foundation; either version 2, or (at your option) * |
12
|
|
|
* any later version. * |
13
|
|
|
* * |
14
|
|
|
* This program is distributed in the hope that it will be useful, but * |
15
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of * |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
17
|
|
|
* See the GNU General Public License for more details. * |
18
|
|
|
* * |
19
|
|
|
* You should have received a copy of the GNU General Public License * |
20
|
|
|
* along with this program; if not, write to the Free Software * |
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,* |
22
|
|
|
* USA. * |
23
|
|
|
************************************************************************/ |
24
|
|
|
|
25
|
|
|
bab_Widgets()->includePhpClass('Widget_Frame'); |
26
|
|
|
bab_functionality::includefile('Icons'); |
|
|
|
|
27
|
|
|
|
28
|
|
|
|
29
|
|
|
class absences_CardFrame extends Widget_Frame |
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
protected function titledLabel($title, $caption) |
33
|
|
|
{ |
34
|
|
|
$W = bab_Widgets(); |
35
|
|
|
|
36
|
|
|
return $W->FlowItems( |
37
|
|
|
$W->Label($title)->addClass('widget-strong')->colon(), |
38
|
|
|
$W->Label($caption) |
39
|
|
|
)->addClass('widget-small')->setSpacing(.2,'em', .3,'em'); |
40
|
|
|
} |
41
|
|
|
} |
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: