Completed
Pull Request — master (#38)
by None
56:40 queued 36:38
created
src/ApiRequestProcessor.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -125,6 +125,9 @@
 block discarded – undo
125 125
 		) );
126 126
 	}
127 127
 
128
+	/**
129
+	 * @param string $sep
130
+	 */
128 131
 	private function getFormattedValuesFrom( $sep, $values ) {
129 132
 
130 133
 		if ( strpos( $values, $sep ) === false ) {
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @param Parser $parser
34 34
 	 */
35
-	public function __construct( Parser $parser ) {
35
+	public function __construct(Parser $parser) {
36 36
 		$this->parser = $parser;
37 37
 	}
38 38
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @param boolean $debugFlag
43 43
 	 */
44
-	public function setDebugFlag( $debugFlag ) {
44
+	public function setDebugFlag($debugFlag) {
45 45
 		$this->debugFlag = $debugFlag;
46 46
 	}
47 47
 
@@ -52,91 +52,91 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return string
54 54
 	 */
55
-	public function getJsonDecodedResultValuesForRequestParameters( array $parameters ) {
55
+	public function getJsonDecodedResultValuesForRequestParameters(array $parameters) {
56 56
 
57
-		if ( !isset( $parameters['query'] ) || !isset( $parameters['sep'] ) ) {
58
-			throw new InvalidArgumentException( 'Missing an query parameter' );
57
+		if (!isset($parameters['query']) || !isset($parameters['sep'])) {
58
+			throw new InvalidArgumentException('Missing an query parameter');
59 59
 		}
60 60
 
61 61
 		$this->parser->firstCallInit();
62 62
 		$json = array();
63 63
 
64
-		if ( isset( $parameters['approach'] ) && $parameters['approach'] == 'smw' ) {
65
-			$json = $this->doProcessQueryFor( $parameters['query'], $parameters['sep'] );
64
+		if (isset($parameters['approach']) && $parameters['approach'] == 'smw') {
65
+			$json = $this->doProcessQueryFor($parameters['query'], $parameters['sep']);
66 66
 		} else {
67
-			$json = $this->doProcessFunctionFor( $parameters['query'], $parameters['sep'] );
67
+			$json = $this->doProcessFunctionFor($parameters['query'], $parameters['sep']);
68 68
 		}
69 69
 
70 70
 		// I have no idea why we first encode and and then decode here??
71 71
 
72
-		return json_decode( $json );
72
+		return json_decode($json);
73 73
 	}
74 74
 
75
-	private function doProcessQueryFor( $query, $sep = "," ) {
75
+	private function doProcessQueryFor($query, $sep = ",") {
76 76
 
77 77
 		$query = str_replace(
78
-			array( "<", ">", "sep=;" ),
79
-			array( "<", ">", "sep={$sep};" ),
78
+			array("&lt;", "&gt;", "sep=;"),
79
+			array("<", ">", "sep={$sep};"),
80 80
 			$query
81 81
 		);
82 82
 
83
-		$params = explode( ";", $query );
84
-		$f = str_replace( ";", "|", $params[0] );
83
+		$params = explode(";", $query);
84
+		$f = str_replace(";", "|", $params[0]);
85 85
 
86
-		$params[0] = $this->parser->replaceVariables( $f );
86
+		$params[0] = $this->parser->replaceVariables($f);
87 87
 
88
-		if ( $this->debugFlag ) {
89
-			error_log( implode( "|", $params ) );
88
+		if ($this->debugFlag) {
89
+			error_log(implode("|", $params));
90 90
 		}
91 91
 
92 92
 		$values = $this->getFormattedValuesFrom(
93 93
 			$sep,
94
-			QueryProcessor::getResultFromFunctionParams( $params, SMW_OUTPUT_WIKI )
94
+			QueryProcessor::getResultFromFunctionParams($params, SMW_OUTPUT_WIKI)
95 95
 		);
96 96
 
97
-		return json_encode( array(
97
+		return json_encode(array(
98 98
 			"values" => $values,
99
-			"count"  => count( $values )
100
-		) );
99
+			"count"  => count($values)
100
+		));
101 101
 	}
102 102
 
103
-	private function doProcessFunctionFor( $query, $sep = "," ) {
103
+	private function doProcessFunctionFor($query, $sep = ",") {
104 104
 
105 105
 		$query = str_replace(
106
-			array( "&lt;", "&gt;", "sep=;" ),
107
-			array( "<", ">", "sep={$sep};" ),
106
+			array("&lt;", "&gt;", "sep=;"),
107
+			array("<", ">", "sep={$sep};"),
108 108
 			$query
109 109
 		);
110 110
 
111
-		$f = str_replace( ";", "|", $query );
111
+		$f = str_replace(";", "|", $query);
112 112
 
113
-		if ( $this->debugFlag ) {
114
-			error_log( $f );
113
+		if ($this->debugFlag) {
114
+			error_log($f);
115 115
 		}
116 116
 
117 117
 		$values = $this->getFormattedValuesFrom(
118 118
 			$sep,
119
-			$this->parser->replaceVariables( $f )
119
+			$this->parser->replaceVariables($f)
120 120
 		);
121 121
 
122
-		return json_encode( array(
122
+		return json_encode(array(
123 123
 			"values" => $values,
124
-			"count"  => count( $values )
125
-		) );
124
+			"count"  => count($values)
125
+		));
126 126
 	}
127 127
 
128
-	private function getFormattedValuesFrom( $sep, $values ) {
128
+	private function getFormattedValuesFrom($sep, $values) {
129 129
 
130
-		if ( strpos( $values, $sep ) === false ) {
131
-			return array( $values );
130
+		if (strpos($values, $sep) === false) {
131
+			return array($values);
132 132
 		}
133 133
 
134
-		$values = explode( $sep, $values );
135
-		$values = array_map( "trim", $values );
136
-		$values = array_unique( $values );
134
+		$values = explode($sep, $values);
135
+		$values = array_map("trim", $values);
136
+		$values = array_unique($values);
137 137
 
138
-		sort( $values );
139
-		array_unshift( $values, "" );
138
+		sort($values);
139
+		array_unshift($values, "");
140 140
 
141 141
 		return $values;
142 142
 	}
Please login to merge, or discard this patch.
tests/phpunit/Unit/ApiRequestProcessorTest.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,43 +21,43 @@
 block discarded – undo
21 21
 
22 22
 	public function testCanConstruct() {
23 23
 
24
-		$parser = $this->getMockBuilder( '\Parser' )
24
+		$parser = $this->getMockBuilder('\Parser')
25 25
 			->disableOriginalConstructor()
26 26
 			->getMock();
27 27
 
28 28
 		$this->assertInstanceOf(
29 29
 			'\SFS\ApiRequestProcessor',
30
-			new ApiRequestProcessor( $parser )
30
+			new ApiRequestProcessor($parser)
31 31
 		);
32 32
 	}
33 33
 
34 34
 	public function testMissingParametersThrowsException() {
35 35
 
36
-		$parser = $this->getMockBuilder( '\Parser' )
36
+		$parser = $this->getMockBuilder('\Parser')
37 37
 			->disableOriginalConstructor()
38 38
 			->getMock();
39 39
 
40
-		$instance = new ApiRequestProcessor( $parser );
40
+		$instance = new ApiRequestProcessor($parser);
41 41
 
42 42
 		$parameters = array();
43 43
 
44
-		$this->setExpectedException( 'InvalidArgumentException' );
45
-		$instance->getJsonDecodedResultValuesForRequestParameters( $parameters );
44
+		$this->setExpectedException('InvalidArgumentException');
45
+		$instance->getJsonDecodedResultValuesForRequestParameters($parameters);
46 46
 	}
47 47
 
48 48
 	public function testJsonResultValuesFromRequestParameters() {
49 49
 
50
-		$parser = $this->getMockBuilder( '\Parser' )
50
+		$parser = $this->getMockBuilder('\Parser')
51 51
 			->disableOriginalConstructor()
52 52
 			->getMock();
53 53
 
54
-		$instance = new ApiRequestProcessor( $parser );
54
+		$instance = new ApiRequestProcessor($parser);
55 55
 
56
-		$parameters = array( 'query' => 'foo', 'sep' => ',' );
56
+		$parameters = array('query' => 'foo', 'sep' => ',');
57 57
 
58 58
 		$this->assertInternalType(
59 59
 			'object',
60
-			$instance->getJsonDecodedResultValuesForRequestParameters( $parameters )
60
+			$instance->getJsonDecodedResultValuesForRequestParameters($parameters)
61 61
 		);
62 62
 	}
63 63
 
Please login to merge, or discard this patch.
tests/phpunit/Unit/ApiSemanticFormsSelectTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 	public function testCanConstruct() {
23 23
 
24
-		$apiMain = new ApiMain( $this->newRequestContext( array() ), true );
24
+		$apiMain = new ApiMain($this->newRequestContext(array()), true);
25 25
 
26 26
 		$instance = new ApiSemanticFormsSelect(
27 27
 			$apiMain,
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 			'sep'      => ','
44 44
 		);
45 45
 
46
-		$apiMain = new ApiMain( $this->newRequestContext( $parameters ), true );
46
+		$apiMain = new ApiMain($this->newRequestContext($parameters), true);
47 47
 
48 48
 		$instance = new ApiSemanticFormsSelect(
49 49
 			$apiMain,
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 		);
56 56
 	}
57 57
 
58
-	private function newRequestContext( $request = array() ) {
58
+	private function newRequestContext($request = array()) {
59 59
 
60 60
 		$context = new RequestContext();
61 61
 
62
-		if ( $request instanceof WebRequest ) {
63
-			$context->setRequest( $request );
62
+		if ($request instanceof WebRequest) {
63
+			$context->setRequest($request);
64 64
 		} else {
65
-			$context->setRequest( new FauxRequest( $request, true ) );
65
+			$context->setRequest(new FauxRequest($request, true));
66 66
 		}
67 67
 
68 68
 		return $context;
Please login to merge, or discard this patch.
tests/phpunit/Unit/OutputTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 
28 28
 		$this->assertContains(
29 29
 			'mw.config.set({"Foo":"\"Bar\""})',
30
-			Output::addToHeadItem( 'Foo', 'Bar' )
30
+			Output::addToHeadItem('Foo', 'Bar')
31 31
 		);
32 32
 	}
33 33
 
Please login to merge, or discard this patch.
tests/phpunit/Unit/SemanticFormsSelectTest.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 
18 18
 	public function testCanConstruct() {
19 19
 
20
-		$parser = $this->getMockBuilder( '\Parser' )
20
+		$parser = $this->getMockBuilder('\Parser')
21 21
 			->disableOriginalConstructor()
22 22
 			->getMock();
23 23
 
24 24
 		$this->assertInstanceOf(
25 25
 			'\SFS\SemanticFormsSelect',
26
-			new SemanticFormsSelect( $parser )
26
+			new SemanticFormsSelect($parser)
27 27
 		);
28 28
 	}
29 29
 
@@ -41,23 +41,23 @@  discard block
 block discarded – undo
41 41
 			'is_list' => true
42 42
 		);
43 43
 
44
-		$parserOutput = $this->getMockBuilder( '\ParserOutput' )
44
+		$parserOutput = $this->getMockBuilder('\ParserOutput')
45 45
 			->disableOriginalConstructor()
46 46
 			->getMock();
47 47
 
48
-		$parser = $this->getMockBuilder( '\Parser' )
48
+		$parser = $this->getMockBuilder('\Parser')
49 49
 			->disableOriginalConstructor()
50 50
 			->getMock();
51 51
 
52
-		$parser->expects( $this->any() )
53
-			->method( 'getOutput' )
54
-			->will( $this->returnValue( $parserOutput ) );
52
+		$parser->expects($this->any())
53
+			->method('getOutput')
54
+			->will($this->returnValue($parserOutput));
55 55
 
56
-		$instance = new SemanticFormsSelect( $parser );
56
+		$instance = new SemanticFormsSelect($parser);
57 57
 
58 58
 		$this->assertInternalType(
59 59
 			'string',
60
-			$instance->select( $value, $inputName, $isMandatory, $isDisabled, $otherArgs )
60
+			$instance->select($value, $inputName, $isMandatory, $isDisabled, $otherArgs)
61 61
 		);
62 62
 	}
63 63
 
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( PHP_SAPI !== 'cli' ) {
4
-	die( 'Not an entry point' );
3
+if (PHP_SAPI !== 'cli') {
4
+	die('Not an entry point');
5 5
 }
6 6
 
7
-error_reporting( E_ALL | E_STRICT );
8
-date_default_timezone_set( 'UTC' );
9
-ini_set( 'display_errors', 1 );
7
+error_reporting(E_ALL | E_STRICT);
8
+date_default_timezone_set('UTC');
9
+ini_set('display_errors', 1);
10 10
 
11 11
 
12
-if ( !is_readable( $autoloaderClassPath = __DIR__ . '/../../SemanticMediaWiki/tests/autoloader.php' ) ) {
13
-	die( 'The Semantic MediaWiki test autoloader is not available' );
12
+if (!is_readable($autoloaderClassPath = __DIR__.'/../../SemanticMediaWiki/tests/autoloader.php')) {
13
+	die('The Semantic MediaWiki test autoloader is not available');
14 14
 }
15 15
 
16
-if ( !class_exists( 'SemanticFormsSelect' ) || ( $version = SemanticFormsSelect::getVersion() ) === null ) {
17
-	die( "\nSemantic Forms Select is not available, please check your Composer or LocalSettings.\n" );
16
+if (!class_exists('SemanticFormsSelect') || ($version = SemanticFormsSelect::getVersion()) === null) {
17
+	die("\nSemantic Forms Select is not available, please check your Composer or LocalSettings.\n");
18 18
 }
19 19
 
20
-print sprintf( "\n%-20s%s\n", "Semantic Forms Select: ", $version );
20
+print sprintf("\n%-20s%s\n", "Semantic Forms Select: ", $version);
21 21
 
22 22
 $autoloader = require $autoloaderClassPath;
23
-$autoloader->addPsr4( 'SFS\\Tests\\', __DIR__ . '/phpunit/Unit' );
24
-$autoloader->addPsr4( 'SFS\\Tests\\Integration\\', __DIR__ . '/phpunit/Integration' );
25
-unset( $autoloader );
23
+$autoloader->addPsr4('SFS\\Tests\\', __DIR__.'/phpunit/Unit');
24
+$autoloader->addPsr4('SFS\\Tests\\Integration\\', __DIR__.'/phpunit/Integration');
25
+unset($autoloader);
Please login to merge, or discard this patch.
src/SemanticFormsSelect.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param Parser $parser
33 33
 	 */
34
-	public function __construct( &$parser ) {
34
+	public function __construct(&$parser) {
35 35
 		$this->parser = $parser;
36 36
 	}
37 37
 
@@ -40,53 +40,53 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return string
42 42
 	 */
43
-	public static function init( $value, $inputName, $isMandatory, $isDisabled, $otherArgs ) {
43
+	public static function init($value, $inputName, $isMandatory, $isDisabled, $otherArgs) {
44 44
 
45
-		$instance = new self( $GLOBALS['wgParser'] );
45
+		$instance = new self($GLOBALS['wgParser']);
46 46
 
47
-		return $instance->select( $value, $inputName, $isMandatory, $isDisabled, $otherArgs );
47
+		return $instance->select($value, $inputName, $isMandatory, $isDisabled, $otherArgs);
48 48
 	}
49 49
 
50
-	public function select ( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
50
+	public function select($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) {
51 51
 		global $wgScriptSelectCount, $sfgFieldNum, $wgUser;
52 52
 
53 53
 		$selectField = array();
54 54
 		$values = null;
55 55
 		$staticvalue = false;
56 56
 
57
-		if ( array_key_exists( "query", $other_args ) ) {
57
+		if (array_key_exists("query", $other_args)) {
58 58
 			$query = $other_args["query"];
59 59
 
60 60
 			$query = str_replace(
61
-				array( "~", "(", ")" ),
62
-				array( "=", "[", "]" ),
61
+				array("~", "(", ")"),
62
+				array("=", "[", "]"),
63 63
 				$query
64 64
 			);
65 65
 
66 66
 			$selectField["query"] = $query;
67 67
 
68
-			if ( strpos ($query, '@@@@') === false ) {
68
+			if (strpos($query, '@@@@') === false) {
69 69
 				$params = explode(";", $query);
70
-				$params[0] = $this->parser->replaceVariables( $params[0] );
71
-				$values = QueryProcessor::getResultFromFunctionParams($params,SMW_OUTPUT_WIKI);
70
+				$params[0] = $this->parser->replaceVariables($params[0]);
71
+				$values = QueryProcessor::getResultFromFunctionParams($params, SMW_OUTPUT_WIKI);
72 72
 				$staticvalue = true;
73 73
 			}
74 74
 
75
-		} elseif ( array_key_exists( "function", $other_args ) ) {
75
+		} elseif (array_key_exists("function", $other_args)) {
76 76
 			$query = $other_args["function"];
77 77
 			$query = '{{#'.$query.'}}';
78 78
 
79 79
 			$query = str_replace(
80
-				array( "~", "(", ")" ),
81
-				array( "=", "[", "]" ),
80
+				array("~", "(", ")"),
81
+				array("=", "[", "]"),
82 82
 				$query
83 83
 			);
84 84
 
85 85
 			$selectField["function"] = $query;
86 86
 
87
-			if ( strpos( $query, '@@@@' ) === false ) {
88
-				$f = str_replace( ";", "|", $query );
89
-				$values = $this->parser->replaceVariables( $f );
87
+			if (strpos($query, '@@@@') === false) {
88
+				$f = str_replace(";", "|", $query);
89
+				$values = $this->parser->replaceVariables($f);
90 90
 				$staticvalue = true;
91 91
 			}
92 92
 		}
@@ -99,115 +99,115 @@  discard block
 block discarded – undo
99 99
 			$values = array_unique($values);
100 100
 		} else {
101 101
 
102
-			if ($wgScriptSelectCount == 0 ) {
103
-				Output::addModule( 'ext.sf_select.scriptselect' );
102
+			if ($wgScriptSelectCount == 0) {
103
+				Output::addModule('ext.sf_select.scriptselect');
104 104
 			}
105 105
 
106 106
 			$wgScriptSelectCount++;
107 107
 
108
-			$data["selectismultiple"] = array_key_exists( "part_of_multiple", $other_args );
108
+			$data["selectismultiple"] = array_key_exists("part_of_multiple", $other_args);
109 109
 
110 110
 			$index = strpos($input_name, "[");
111 111
 			$data['selecttemplate'] = substr($input_name, 0, $index);
112 112
 
113 113
 			// Does hit work for multiple template?
114 114
 			$index = strrpos($input_name, "[");
115
-			$data['selectfield'] = substr( $input_name, $index+1, strlen( $input_name ) - $index - 2 );
115
+			$data['selectfield'] = substr($input_name, $index + 1, strlen($input_name) - $index - 2);
116 116
 
117 117
 			$valueField = array();
118
-			$data["valuetemplate"] = array_key_exists( "sametemplate", $other_args ) ? $data['selecttemplate'] : $other_args["template"];
118
+			$data["valuetemplate"] = array_key_exists("sametemplate", $other_args) ? $data['selecttemplate'] : $other_args["template"];
119 119
 			$data["valuefield"] = $other_args["field"];
120 120
 
121
-			$data['selectrm'] = array_key_exists( 'rmdiv', $other_args );
122
-			$data['label'] = array_key_exists( 'label', $other_args );
123
-			$data['sep'] = array_key_exists( 'sep', $other_args ) ? $other_args["sep"] : ',';
121
+			$data['selectrm'] = array_key_exists('rmdiv', $other_args);
122
+			$data['label'] = array_key_exists('label', $other_args);
123
+			$data['sep'] = array_key_exists('sep', $other_args) ? $other_args["sep"] : ',';
124 124
 
125
-			if (array_key_exists("query", $selectField ) ) {
125
+			if (array_key_exists("query", $selectField)) {
126 126
 				$data['selectquery'] = $selectField['query'];
127
-			} else{
127
+			} else {
128 128
 				$data['selectfunction'] = $selectField['function'];
129 129
 			}
130 130
 
131 131
 			self::$data[] = $data;
132 132
 		}
133 133
 
134
-		$extraatt="";
135
-		$is_list=false;
134
+		$extraatt = "";
135
+		$is_list = false;
136 136
 
137 137
 		// TODO This needs clean-up
138 138
 
139
-		if (array_key_exists('is_list', $other_args) && $other_args['is_list']==true){
140
-			$is_list=true;
139
+		if (array_key_exists('is_list', $other_args) && $other_args['is_list'] == true) {
140
+			$is_list = true;
141 141
 		}
142
-		if ($is_list){
143
-			$extraatt=' multiple="multiple" ';
142
+		if ($is_list) {
143
+			$extraatt = ' multiple="multiple" ';
144 144
 		}
145
-		if(array_key_exists("size", $other_args)){
146
-			$extraatt.=" size=\"{$other_args['size']}\"";
145
+		if (array_key_exists("size", $other_args)) {
146
+			$extraatt .= " size=\"{$other_args['size']}\"";
147 147
 		}
148
-		$classes=array();
149
-		if($is_mandatory){
150
-			$classes[]="mandatoryField";
148
+		$classes = array();
149
+		if ($is_mandatory) {
150
+			$classes[] = "mandatoryField";
151 151
 		}
152
-		if (array_key_exists("class", $other_args)){
153
-			$classes[]=$other_args['class'];
152
+		if (array_key_exists("class", $other_args)) {
153
+			$classes[] = $other_args['class'];
154 154
 		}
155
-		if ($classes){
156
-			$cstr=implode(" ",$classes);
157
-			$extraatt.=" class=\"$cstr\"";
155
+		if ($classes) {
156
+			$cstr = implode(" ", $classes);
157
+			$extraatt .= " class=\"$cstr\"";
158 158
 		}
159
-		$inname=$input_name;
160
-		if ($is_list){
161
-			$inname.='[]';
159
+		$inname = $input_name;
160
+		if ($is_list) {
161
+			$inname .= '[]';
162 162
 		}
163 163
 
164 164
 		// TODO Use Html::
165 165
 
166
-		$spanextra=$is_mandatory?'mandatoryFieldSpan':'';
167
-		$ret="<span class=\"inputSpan $spanextra\"><select name='$inname' id='input_$sfgFieldNum' $extraatt>";
168
-		$curvalues=null;
169
-		if ($cur_value){
170
-			if ($cur_value==='current user'){
171
-				$cur_value=$wgUser->getName();
166
+		$spanextra = $is_mandatory ? 'mandatoryFieldSpan' : '';
167
+		$ret = "<span class=\"inputSpan $spanextra\"><select name='$inname' id='input_$sfgFieldNum' $extraatt>";
168
+		$curvalues = null;
169
+		if ($cur_value) {
170
+			if ($cur_value === 'current user') {
171
+				$cur_value = $wgUser->getName();
172 172
 			}
173
-			if (is_array($cur_value) ){
174
-				$curvalues=$cur_value;
175
-			} else{
176
-				$curvalues=array_map("trim", explode(",", $cur_value));
173
+			if (is_array($cur_value)) {
174
+				$curvalues = $cur_value;
175
+			} else {
176
+				$curvalues = array_map("trim", explode(",", $cur_value));
177 177
 			}
178 178
 
179 179
 		} else {
180
-			$curvalues=array();
180
+			$curvalues = array();
181 181
 		}
182 182
 
183 183
 		// TODO handle empty value case.
184
-		$ret.="<option></option>";
184
+		$ret .= "<option></option>";
185 185
 
186 186
 		foreach ($curvalues as $cur) {
187
-			$ret.="<option selected='selected'>$cur</option>";
187
+			$ret .= "<option selected='selected'>$cur</option>";
188 188
 		}
189 189
 
190
-		if ($staticvalue){
191
-			foreach($values as $val){
192
-				if(!in_array($val, $curvalues)){
193
-					$ret.="<option>$val</option>";
190
+		if ($staticvalue) {
191
+			foreach ($values as $val) {
192
+				if (!in_array($val, $curvalues)) {
193
+					$ret .= "<option>$val</option>";
194 194
 				}
195 195
 			}
196 196
 		}
197 197
 
198
-		$ret.="</select></span>";
199
-		$ret.="<span id=\"info_$sfgFieldNum\" class=\"errorMessage\"></span>";
198
+		$ret .= "</select></span>";
199
+		$ret .= "<span id=\"info_$sfgFieldNum\" class=\"errorMessage\"></span>";
200 200
 
201
-		if ($other_args["is_list"]){
202
-			$hiddenname=$input_name.'[is_list]';
203
-			$ret.="<input type='hidden' name='$hiddenname' value='1' />";
201
+		if ($other_args["is_list"]) {
202
+			$hiddenname = $input_name.'[is_list]';
203
+			$ret .= "<input type='hidden' name='$hiddenname' value='1' />";
204 204
 		}
205 205
 
206
-		if ( !$staticvalue ){
207
-			Output::addToHeadItem( 'sf_select', self::$data );
206
+		if (!$staticvalue) {
207
+			Output::addToHeadItem('sf_select', self::$data);
208 208
 		}
209 209
 
210
-		Output::commitToParserOutput( $this->parser->getOutput() );
210
+		Output::commitToParserOutput($this->parser->getOutput());
211 211
 
212 212
 		return $ret;
213 213
 	}
Please login to merge, or discard this patch.
src/Output.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @param string $moduleName
30 30
 	 */
31
-	public static function addModule( $moduleName ) {
31
+	public static function addModule($moduleName) {
32 32
 		self::$resourceModules[$moduleName] = $moduleName;
33 33
 	}
34 34
 
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 * @param string $id
39 39
 	 * @param string $data
40 40
 	 */
41
-	public static function addToHeadItem( $id, $data = '' ) {
42
-		return self::$headItems[$id] = self::makeVariablesScript( array( $id => json_encode( $data ) ) );
41
+	public static function addToHeadItem($id, $data = '') {
42
+		return self::$headItems[$id] = self::makeVariablesScript(array($id => json_encode($data)));
43 43
 	}
44 44
 
45 45
 	/**
@@ -47,24 +47,24 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @param ParserOutput $parserOutput
49 49
 	 */
50
-	public static function commitToParserOutput( ParserOutput $parserOutput ) {
50
+	public static function commitToParserOutput(ParserOutput $parserOutput) {
51 51
 
52
-		foreach ( self::$headItems as $key => $item ) {
53
-			$parserOutput->addHeadItem( "\t\t" . $item . "\n", $key );
52
+		foreach (self::$headItems as $key => $item) {
53
+			$parserOutput->addHeadItem("\t\t".$item."\n", $key);
54 54
 		}
55 55
 
56
-		$parserOutput->addModules( array_values( self::$resourceModules ) );
56
+		$parserOutput->addModules(array_values(self::$resourceModules));
57 57
 
58 58
 		self::$resourceModules = array();
59 59
 		self::$headItems = array();
60 60
 	}
61 61
 
62
-	private static function makeVariablesScript( $data ) {
62
+	private static function makeVariablesScript($data) {
63 63
 
64
-		if ( $data ) {
64
+		if ($data) {
65 65
 			return \Html::inlineScript(
66 66
 				ResourceLoader::makeLoaderConditionalScript(
67
-					ResourceLoader::makeConfigSetScript( $data )
67
+					ResourceLoader::makeConfigSetScript($data)
68 68
 				)
69 69
 			);
70 70
 		}
Please login to merge, or discard this patch.
src/ApiSemanticFormsSelect.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,22 +24,22 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	public function execute() {
26 26
 
27
-		$parser = new Parser( $GLOBALS['wgParserConf'] );
28
-		$parser->setTitle( Title::newFromText( 'NO TITLE' ) );
27
+		$parser = new Parser($GLOBALS['wgParserConf']);
28
+		$parser->setTitle(Title::newFromText('NO TITLE'));
29 29
 		$parser->mOptions = new ParserOptions();
30 30
 		$parser->mOutput = new ParserOutput();
31 31
 
32
-		$apiRequestProcessor = new ApiRequestProcessor( $parser );
33
-		$apiRequestProcessor->setDebugFlag( $GLOBALS['wgSF_Select_debug'] );
32
+		$apiRequestProcessor = new ApiRequestProcessor($parser);
33
+		$apiRequestProcessor->setDebugFlag($GLOBALS['wgSF_Select_debug']);
34 34
 
35 35
 		$resultValues = $apiRequestProcessor->getJsonDecodedResultValuesForRequestParameters(
36 36
 			$this->extractRequestParams()
37 37
 		);
38 38
 
39 39
 		$result = $this->getResult();
40
-		$result->setIndexedTagName( $resultValues->values, 'value' );
41
-		$result->addValue( $this->getModuleName(), 'values', $resultValues->values );
42
-		$result->addValue( $this->getModuleName(), 'count', $resultValues->count );
40
+		$result->setIndexedTagName($resultValues->values, 'value');
41
+		$result->addValue($this->getModuleName(), 'values', $resultValues->values);
42
+		$result->addValue($this->getModuleName(), 'count', $resultValues->count);
43 43
 
44 44
 		return true;
45 45
 	}
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @see ApiBase::getVersion
88 88
 	 */
89 89
 	public function getVersion() {
90
-		return __CLASS__ . ': 1.1';
90
+		return __CLASS__.': 1.1';
91 91
 	}
92 92
 
93 93
 }
Please login to merge, or discard this patch.