Completed
Branch master (939199)
by
unknown
39:35
created

includes/widget/ComplexTitleInputWidget.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * MediaWiki Widgets – ComplexTitleInputWidget 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
 * Complex title input widget.
12
 */
13
class ComplexTitleInputWidget extends \OOUI\Widget {
14
15
	protected $namespace = null;
16
	protected $title = null;
17
18
	/**
19
	 * Like TitleInputWidget, but the namespace has to be input through a separate dropdown field.
20
	 *
21
	 * @param array $config Configuration options
22
	 * @param array $config['namespace'] Configuration for the NamespaceInputWidget dropdown
0 ignored issues
show
There is no parameter named $config['namespace']. Did you maybe mean $config?

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 $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
23
	 *  with list of namespaces
24
	 * @param array $config['title'] Configuration for the TitleInputWidget text field
25
	 */
26
	public function __construct( array $config = [] ) {
27
		// Configuration initialization
28
		$config = array_merge(
29
			[
30
				'namespace' => [],
31
				'title' => [],
32
			],
33
			$config
34
		);
35
36
		// Parent constructor
37
		parent::__construct( $config );
38
39
		// Properties
40
		$this->config = $config;
41
		$this->namespace = new NamespaceInputWidget( $config['namespace'] );
42
		$this->title = new TitleInputWidget( array_merge(
43
			$config['title'],
44
			[
45
				'relative' => true,
46
				'namespace' => isset( $config['namespace']['value'] ) ?
47
					$config['namespace']['value'] :
48
					null,
49
			]
50
		) );
51
52
		// Initialization
53
		$this
54
			->addClasses( [ 'mw-widget-complexTitleInputWidget' ] )
55
			->appendContent( $this->namespace, $this->title );
56
	}
57
58
	protected function getJavaScriptClassName() {
59
		return 'mw.widgets.ComplexTitleInputWidget';
60
	}
61
62
	public function getConfig( &$config ) {
63
		$config['namespace'] = $this->config['namespace'];
64
		$config['title'] = $this->config['title'];
65
		return parent::getConfig( $config );
66
	}
67
}
68