1 | <?php |
||
7 | abstract class ExportDbUnit extends ImportDbUnit implements ExportDbUnitInterface |
||
8 | { |
||
9 | /** |
||
10 | * Order by columns for reverse move |
||
11 | * @var array |
||
12 | */ |
||
13 | protected $reverseMoveOrder = []; |
||
14 | /** |
||
15 | * Direction for reverse move |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $reverseDirection = 'asc'; |
||
19 | /** |
||
20 | * Conditions for reverse move |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $reverseConditions = []; |
||
24 | |||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | */ |
||
28 | 3 | public function getReverseMoveOrder() |
|
32 | |||
33 | /** |
||
34 | * {@inheritdoc} |
||
35 | */ |
||
36 | 3 | public function setReverseMoveOrder(array $reverseMoveOrder) |
|
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | 3 | public function getReverseMoveDirection() |
|
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 3 | public function setReverseMoveDirection($direction) |
|
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | 3 | public function getReverseMoveConditions() |
|
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | 1 | public function setReverseMoveConditions($conditions) |
|
72 | } |
||
73 |
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.
Let’s take a look at an example:
Our function
my_function
expects aPost
object, and outputs the author of the post. The base classPost
returns a simple string and outputting a simple string will work just fine. However, the child classBlogPost
which is a sub-type ofPost
instead decided to return anobject
, and is therefore violating the SOLID principles. If aBlogPost
were passed tomy_function
, PHP would not complain, but ultimately fail when executing thestrtoupper
call in its body.