1 | <?php |
||
24 | class SpecialUnconnectedPages extends QueryPage { |
||
25 | |||
26 | /** |
||
27 | * @var int maximum supported offset |
||
28 | */ |
||
29 | const MAX_OFFSET = 10000; |
||
30 | |||
31 | /** |
||
32 | * @var NamespaceChecker|null |
||
33 | */ |
||
34 | private $namespaceChecker = null; |
||
35 | |||
36 | /** |
||
37 | * @see SpecialPage::__construct |
||
38 | * |
||
39 | * @param string $name |
||
40 | */ |
||
41 | public function __construct( $name = 'UnconnectedPages' ) { |
||
44 | |||
45 | /** |
||
46 | * @see QueryPage::isSyndicated |
||
47 | * |
||
48 | * @return bool Always false because we do not want to build RSS/Atom feeds for this page. |
||
49 | */ |
||
50 | public function isSyndicated() { |
||
53 | |||
54 | /** |
||
55 | * @see QueryPage::isCacheable |
||
56 | * |
||
57 | * @return bool Always false because we can not have caching since we will store additional information. |
||
58 | */ |
||
59 | public function isCacheable() { |
||
62 | |||
63 | public function setNamespaceChecker( NamespaceChecker $namespaceChecker ) { |
||
66 | |||
67 | /** |
||
68 | * @return NamespaceChecker |
||
69 | */ |
||
70 | public function getNamespaceChecker() { |
||
77 | |||
78 | /** |
||
79 | * Build conditionals for namespace |
||
80 | * |
||
81 | * @param IDatabase $dbr |
||
82 | * @param Title|null $title |
||
83 | * @param NamespaceChecker|null $checker |
||
84 | * |
||
85 | * @return string[] |
||
86 | */ |
||
87 | public function buildConditionals( IDatabase $dbr, Title $title = null, NamespaceChecker $checker = null ) { |
||
107 | |||
108 | /** |
||
109 | * @see QueryPage::getQueryInfo |
||
110 | * |
||
111 | * @return array[] |
||
112 | */ |
||
113 | public function getQueryInfo() { |
||
145 | |||
146 | /** |
||
147 | * @see QueryPage::reallyDoQuery |
||
148 | * |
||
149 | * @param int|bool $limit |
||
150 | * @param int|bool $offset |
||
151 | * |
||
152 | * @return IResultWrapper |
||
153 | */ |
||
154 | public function reallyDoQuery( $limit, $offset = false ) { |
||
161 | |||
162 | /** |
||
163 | * @see QueryPage::formatResult |
||
164 | * |
||
165 | * @param Skin $skin |
||
166 | * @param object $result |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | public function formatResult( $skin, $result ) { |
||
182 | |||
183 | /** |
||
184 | * @see QueryPage::getPageHeader |
||
185 | * |
||
186 | * @return string |
||
187 | */ |
||
188 | public function getPageHeader() { |
||
216 | |||
217 | /** |
||
218 | * @see SpecialPage::getGroupName |
||
219 | * |
||
220 | * @return string |
||
221 | */ |
||
222 | protected function getGroupName() { |
||
225 | |||
226 | /** |
||
227 | * @see QueryPage::linkParameters |
||
228 | * |
||
229 | * @return array |
||
230 | */ |
||
231 | public function linkParameters() { |
||
236 | |||
237 | } |
||
238 |
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.