|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* MediaWiki Widgets – TitleInputWidget class. |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt |
|
6
|
|
|
* @license The MIT License (MIT); see LICENSE.txt |
|
7
|
|
|
*/ |
|
8
|
|
|
namespace MediaWiki\Widget; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Title input widget. |
|
12
|
|
|
*/ |
|
13
|
|
|
class TitleInputWidget extends \OOUI\TextInputWidget { |
|
14
|
|
|
|
|
15
|
|
|
protected $namespace = null; |
|
16
|
|
|
protected $relative = null; |
|
17
|
|
|
protected $suggestions = null; |
|
18
|
|
|
protected $highlightFirst = null; |
|
19
|
|
|
protected $validateTitle = null; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @param array $config Configuration options |
|
23
|
|
|
* @param int|null $config['namespace'] Namespace to prepend to queries |
|
|
|
|
|
|
24
|
|
|
* @param bool|null $config['relative'] If a namespace is set, |
|
|
|
|
|
|
25
|
|
|
* return a title relative to it (default: true) |
|
26
|
|
|
* @param bool|null $config['suggestions'] Display search suggestions (default: true) |
|
|
|
|
|
|
27
|
|
|
* @param bool|null $config['highlightFirst'] Automatically highlight |
|
|
|
|
|
|
28
|
|
|
* the first result (default: true) |
|
29
|
|
|
* @param bool|null $config['validateTitle'] Whether the input must |
|
|
|
|
|
|
30
|
|
|
* be a valid title (default: true) |
|
31
|
|
|
*/ |
|
32
|
|
|
public function __construct( array $config = [] ) { |
|
33
|
|
|
// Parent constructor |
|
34
|
|
|
parent::__construct( |
|
35
|
|
|
array_merge( [ 'maxLength' => 255 ], $config ) |
|
36
|
|
|
); |
|
37
|
|
|
|
|
38
|
|
|
// Properties, which are ignored in PHP and just shipped back to JS |
|
39
|
|
|
if ( isset( $config['namespace'] ) ) { |
|
40
|
|
|
$this->namespace = $config['namespace']; |
|
41
|
|
|
} |
|
42
|
|
|
if ( isset( $config['relative'] ) ) { |
|
43
|
|
|
$this->relative = $config['relative']; |
|
44
|
|
|
} |
|
45
|
|
|
if ( isset( $config['suggestions'] ) ) { |
|
46
|
|
|
$this->suggestions = $config['suggestions']; |
|
47
|
|
|
} |
|
48
|
|
|
if ( isset( $config['highlightFirst'] ) ) { |
|
49
|
|
|
$this->highlightFirst = $config['highlightFirst']; |
|
50
|
|
|
} |
|
51
|
|
|
if ( isset( $config['validateTitle'] ) ) { |
|
52
|
|
|
$this->validateTitle = $config['validateTitle']; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
// Initialization |
|
56
|
|
|
$this->addClasses( [ 'mw-widget-titleInputWidget' ] ); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
protected function getJavaScriptClassName() { |
|
60
|
|
|
return 'mw.widgets.TitleInputWidget'; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function getConfig( &$config ) { |
|
64
|
|
|
if ( $this->namespace !== null ) { |
|
65
|
|
|
$config['namespace'] = $this->namespace; |
|
66
|
|
|
} |
|
67
|
|
|
if ( $this->relative !== null ) { |
|
68
|
|
|
$config['relative'] = $this->relative; |
|
69
|
|
|
} |
|
70
|
|
|
if ( $this->suggestions !== null ) { |
|
71
|
|
|
$config['suggestions'] = $this->suggestions; |
|
72
|
|
|
} |
|
73
|
|
|
if ( $this->highlightFirst !== null ) { |
|
74
|
|
|
$config['highlightFirst'] = $this->highlightFirst; |
|
75
|
|
|
} |
|
76
|
|
|
if ( $this->validateTitle !== null ) { |
|
77
|
|
|
$config['validateTitle'] = $this->validateTitle; |
|
78
|
|
|
} |
|
79
|
|
|
return parent::getConfig( $config ); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.