@@ -12,7 +12,7 @@ |
||
12 | 12 | * This is attached to the MediaWiki 'ParserFirstCallInit' hook. |
13 | 13 | * |
14 | 14 | * @param $parser Parser |
15 | - * @return bool |
|
15 | + * @return null|boolean |
|
16 | 16 | */ |
17 | 17 | public static function onSemanticFormsSelectSetup ( & $parser ) { |
18 | 18 |
@@ -14,14 +14,14 @@ |
||
14 | 14 | * @param $parser Parser |
15 | 15 | * @return bool |
16 | 16 | */ |
17 | - public static function onSemanticFormsSelectSetup ( & $parser ) { |
|
17 | + public static function onSemanticFormsSelectSetup(& $parser) { |
|
18 | 18 | |
19 | - if ( !defined( 'PF_VERSION' ) ) { |
|
20 | - die( '<b>Error:</b><a href="https://github.com/SemanticMediaWiki/SemanticFormsSelect/">Semantic Forms Select</a> requires the <a href="https://www.mediawiki.org/wiki/Extension:PageForms">Page Forms</a> extension. Please install and activate this extension first.' ); |
|
19 | + if (!defined('PF_VERSION')) { |
|
20 | + die('<b>Error:</b><a href="https://github.com/SemanticMediaWiki/SemanticFormsSelect/">Semantic Forms Select</a> requires the <a href="https://www.mediawiki.org/wiki/Extension:PageForms">Page Forms</a> extension. Please install and activate this extension first.'); |
|
21 | 21 | } |
22 | 22 | |
23 | - if ( isset( $GLOBALS['wgPageFormsFormPrinter'] )) { |
|
24 | - $GLOBALS['wgPageFormsFormPrinter']->registerInputType( '\SFS\SemanticFormsSelectInput' ); |
|
23 | + if (isset($GLOBALS['wgPageFormsFormPrinter'])) { |
|
24 | + $GLOBALS['wgPageFormsFormPrinter']->registerInputType('\SFS\SemanticFormsSelectInput'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | return true; |
@@ -125,6 +125,9 @@ |
||
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 ) { |
@@ -32,7 +32,7 @@ discard block |
||
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 |
||
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 |
||
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("<", ">", "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( "<", ">", "sep=;" ), |
|
107 | - array( "<", ">", "sep={$sep};" ), |
|
106 | + array("<", ">", "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 | } |
@@ -65,9 +65,9 @@ |
||
65 | 65 | * Returns the HTML code to be included in the output page for this input. |
66 | 66 | * @deprecated use getHtmlText() instead |
67 | 67 | * |
68 | - * @param $cur_value |
|
69 | - * @param $input_name |
|
70 | - * @param $is_mandatory |
|
68 | + * @param string $cur_value |
|
69 | + * @param string $input_name |
|
70 | + * @param boolean $is_mandatory |
|
71 | 71 | * @param $is_disabled |
72 | 72 | * @param $other_args |
73 | 73 | * @return string |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | */ |
25 | 25 | private static $data = array(); |
26 | 26 | |
27 | - public function __construct( $inputNumber, $curValue, $inputName, $disabled, $otherArgs ) { |
|
28 | - parent::__construct( $inputNumber, $curValue, $inputName, $disabled, $otherArgs ); |
|
27 | + public function __construct($inputNumber, $curValue, $inputName, $disabled, $otherArgs) { |
|
28 | + parent::__construct($inputNumber, $curValue, $inputName, $disabled, $otherArgs); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | public static function getName() { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param $other_args |
73 | 73 | * @return string |
74 | 74 | */ |
75 | - public function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
|
75 | + public function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) { |
|
76 | 76 | global # $wgScriptSelectCount, |
77 | 77 | $wgScriptSelectCount, $sfgFieldNum, $wgUser, $wgParser; |
78 | 78 | |
@@ -81,72 +81,72 @@ discard block |
||
81 | 81 | $staticvalue = false; |
82 | 82 | $data = array(); |
83 | 83 | |
84 | - if ( array_key_exists( "query", $other_args ) ) { |
|
84 | + if (array_key_exists("query", $other_args)) { |
|
85 | 85 | $query = $other_args["query"]; |
86 | - $query = str_replace( array( "~", "(", ")" ), array( "=", "[", "]" ), $query ); |
|
86 | + $query = str_replace(array("~", "(", ")"), array("=", "[", "]"), $query); |
|
87 | 87 | |
88 | 88 | $selectField["query"] = $query; |
89 | 89 | |
90 | 90 | // unparametrized query |
91 | - if ( strpos( $query, '@@@@' ) === false ) { |
|
92 | - $params = explode( ";", $query ); |
|
91 | + if (strpos($query, '@@@@') === false) { |
|
92 | + $params = explode(";", $query); |
|
93 | 93 | |
94 | 94 | // there is no need to run the parser, $query has been parsed already |
95 | 95 | //$params[0] = $wgParser->replaceVariables( $params[0] ); |
96 | 96 | |
97 | - $values = QueryProcessor::getResultFromFunctionParams( $params, SMW_OUTPUT_WIKI ); |
|
97 | + $values = QueryProcessor::getResultFromFunctionParams($params, SMW_OUTPUT_WIKI); |
|
98 | 98 | |
99 | 99 | $staticvalue = true; |
100 | 100 | } |
101 | 101 | |
102 | - } elseif ( array_key_exists( "function", $other_args ) ) { |
|
102 | + } elseif (array_key_exists("function", $other_args)) { |
|
103 | 103 | $query = $other_args["function"]; |
104 | - $query = '{{#' . $query . '}}'; |
|
105 | - $query = str_replace( array( "~", "(", ")" ), array( "=", "[", "]" ), $query ); |
|
104 | + $query = '{{#'.$query.'}}'; |
|
105 | + $query = str_replace(array("~", "(", ")"), array("=", "[", "]"), $query); |
|
106 | 106 | |
107 | 107 | $selectField["function"] = $query; |
108 | 108 | |
109 | 109 | // unparametrized function |
110 | - if ( strpos( $query, '@@@@' ) === false ) { |
|
111 | - $f = str_replace( ";", "|", $query ); |
|
110 | + if (strpos($query, '@@@@') === false) { |
|
111 | + $f = str_replace(";", "|", $query); |
|
112 | 112 | |
113 | - $values = $wgParser->replaceVariables( $f ); |
|
113 | + $values = $wgParser->replaceVariables($f); |
|
114 | 114 | |
115 | 115 | $staticvalue = true; |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | - if ( $staticvalue ) { |
|
120 | - $values = explode( ",", $values ); |
|
121 | - $values = array_map( "trim", $values ); |
|
122 | - $values = array_unique( $values ); |
|
119 | + if ($staticvalue) { |
|
120 | + $values = explode(",", $values); |
|
121 | + $values = array_map("trim", $values); |
|
122 | + $values = array_unique($values); |
|
123 | 123 | } else { |
124 | 124 | |
125 | - if ( $wgScriptSelectCount == 0 ) { |
|
125 | + if ($wgScriptSelectCount == 0) { |
|
126 | 126 | // this has been moved to getResourceModuleNames() |
127 | 127 | //Output::addModule( 'ext.sf_select.scriptselect' ); |
128 | 128 | } |
129 | 129 | // $wgScriptSelectCount ++; |
130 | 130 | |
131 | - $data["selectismultiple"] = array_key_exists( "part_of_multiple", $other_args ); |
|
131 | + $data["selectismultiple"] = array_key_exists("part_of_multiple", $other_args); |
|
132 | 132 | |
133 | - $index = strpos( $input_name, "[" ); |
|
134 | - $data['selecttemplate'] = substr( $input_name, 0, $index ); |
|
133 | + $index = strpos($input_name, "["); |
|
134 | + $data['selecttemplate'] = substr($input_name, 0, $index); |
|
135 | 135 | |
136 | 136 | // Does hit work for multiple template? |
137 | - $index = strrpos( $input_name, "[" ); |
|
138 | - $data['selectfield'] = substr( $input_name, $index + 1, strlen( $input_name ) - $index - 2 ); |
|
137 | + $index = strrpos($input_name, "["); |
|
138 | + $data['selectfield'] = substr($input_name, $index + 1, strlen($input_name) - $index - 2); |
|
139 | 139 | |
140 | 140 | $valueField = array(); |
141 | 141 | $data["valuetemplate"] = |
142 | - array_key_exists( "sametemplate", $other_args ) ? $data['selecttemplate'] : $other_args["template"]; |
|
142 | + array_key_exists("sametemplate", $other_args) ? $data['selecttemplate'] : $other_args["template"]; |
|
143 | 143 | $data["valuefield"] = $other_args["field"]; |
144 | 144 | |
145 | - $data['selectrm'] = array_key_exists( 'rmdiv', $other_args ); |
|
146 | - $data['label'] = array_key_exists( 'label', $other_args ); |
|
147 | - $data['sep'] = array_key_exists( 'sep', $other_args ) ? $other_args["sep"] : ','; |
|
145 | + $data['selectrm'] = array_key_exists('rmdiv', $other_args); |
|
146 | + $data['label'] = array_key_exists('label', $other_args); |
|
147 | + $data['sep'] = array_key_exists('sep', $other_args) ? $other_args["sep"] : ','; |
|
148 | 148 | |
149 | - if ( array_key_exists( "query", $selectField ) ) { |
|
149 | + if (array_key_exists("query", $selectField)) { |
|
150 | 150 | $data['selectquery'] = $selectField['query']; |
151 | 151 | } else { |
152 | 152 | $data['selectfunction'] = $selectField['function']; |
@@ -160,32 +160,32 @@ discard block |
||
160 | 160 | |
161 | 161 | // TODO This needs clean-up |
162 | 162 | |
163 | - if ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] == true ) { |
|
163 | + if (array_key_exists('is_list', $other_args) && $other_args['is_list'] == true) { |
|
164 | 164 | $is_list = true; |
165 | 165 | } |
166 | 166 | |
167 | - if ( $is_list ) { |
|
167 | + if ($is_list) { |
|
168 | 168 | $extraatt = ' multiple="multiple" '; |
169 | 169 | } |
170 | 170 | |
171 | - if ( array_key_exists( "size", $other_args ) ) { |
|
171 | + if (array_key_exists("size", $other_args)) { |
|
172 | 172 | $extraatt .= " size=\"{$other_args['size']}\""; |
173 | 173 | } |
174 | 174 | |
175 | 175 | $classes = array(); |
176 | - if ( $is_mandatory ) { |
|
176 | + if ($is_mandatory) { |
|
177 | 177 | $classes[] = "mandatoryField"; |
178 | 178 | } |
179 | - if ( array_key_exists( "class", $other_args ) ) { |
|
179 | + if (array_key_exists("class", $other_args)) { |
|
180 | 180 | $classes[] = $other_args['class']; |
181 | 181 | } |
182 | - if ( $classes ) { |
|
183 | - $cstr = implode( " ", $classes ); |
|
182 | + if ($classes) { |
|
183 | + $cstr = implode(" ", $classes); |
|
184 | 184 | $extraatt .= " class=\"$cstr\""; |
185 | 185 | } |
186 | 186 | |
187 | 187 | $inname = $input_name; |
188 | - if ( $is_list ) { |
|
188 | + if ($is_list) { |
|
189 | 189 | $inname .= '[]'; |
190 | 190 | } |
191 | 191 | |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | $spanextra = $is_mandatory ? 'mandatoryFieldSpan' : ''; |
195 | 195 | $ret = "<span class=\"inputSpan $spanextra\"><select name='$inname' id='input_$sfgFieldNum' $extraatt>"; |
196 | 196 | $curvalues = null; |
197 | - if ( $cur_value ) { |
|
198 | - if ( $cur_value === 'current user' ) { |
|
197 | + if ($cur_value) { |
|
198 | + if ($cur_value === 'current user') { |
|
199 | 199 | $cur_value = $wgUser->getName(); |
200 | 200 | } |
201 | - if ( is_array( $cur_value ) ) { |
|
201 | + if (is_array($cur_value)) { |
|
202 | 202 | $curvalues = $cur_value; |
203 | 203 | } else { |
204 | - $curvalues = array_map( "trim", explode( ",", $cur_value ) ); |
|
204 | + $curvalues = array_map("trim", explode(",", $cur_value)); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | } else { |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | // TODO handle empty value case. |
212 | 212 | $ret .= "<option></option>"; |
213 | 213 | |
214 | - foreach ( $curvalues as $cur ) { |
|
214 | + foreach ($curvalues as $cur) { |
|
215 | 215 | $ret .= "<option selected='selected'>$cur</option>"; |
216 | 216 | } |
217 | 217 | |
218 | - if ( $staticvalue ) { |
|
219 | - foreach ( $values as $val ) { |
|
220 | - if ( !in_array( $val, $curvalues ) ) { |
|
218 | + if ($staticvalue) { |
|
219 | + foreach ($values as $val) { |
|
220 | + if (!in_array($val, $curvalues)) { |
|
221 | 221 | $ret .= "<option>$val</option>"; |
222 | 222 | } |
223 | 223 | } |
@@ -226,13 +226,13 @@ discard block |
||
226 | 226 | $ret .= "</select></span>"; |
227 | 227 | $ret .= "<span id=\"info_$sfgFieldNum\" class=\"errorMessage\"></span>"; |
228 | 228 | |
229 | - if ( $other_args["is_list"] ) { |
|
230 | - $hiddenname = $input_name . '[is_list]'; |
|
229 | + if ($other_args["is_list"]) { |
|
230 | + $hiddenname = $input_name.'[is_list]'; |
|
231 | 231 | $ret .= "<input type='hidden' name='$hiddenname' value='1' />"; |
232 | 232 | } |
233 | 233 | |
234 | - if ( !$staticvalue ) { |
|
235 | - $item = Output::addToHeadItem( $data ); |
|
234 | + if (!$staticvalue) { |
|
235 | + $item = Output::addToHeadItem($data); |
|
236 | 236 | //$wgOut->addJsConfigVars('sf_select', array(json_encode( $data ))); |
237 | 237 | } |
238 | 238 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | class OutputTest extends \PHPUnit_Framework_TestCase { |
17 | 17 | |
18 | 18 | public function testCanConstruct() { |
19 | - $this->assertInstanceOf( '\SFS\Output', new Output() ); |
|
19 | + $this->assertInstanceOf('\SFS\Output', new Output()); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function testAddToHeadItem() { |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | $data['Foo'] = 'Bar'; |
25 | 25 | $data['Spam'] = 'Eggs'; |
26 | 26 | |
27 | - $ret = Output::addToHeadItem( $data ); |
|
27 | + $ret = Output::addToHeadItem($data); |
|
28 | 28 | |
29 | - $this->assertArrayHasKey( 'Foo', $ret ); |
|
30 | - $this->assertArrayHasKey( 'Spam', $ret ); |
|
29 | + $this->assertArrayHasKey('Foo', $ret); |
|
30 | + $this->assertArrayHasKey('Spam', $ret); |
|
31 | 31 | } |
32 | 32 | } |
@@ -1,23 +1,23 @@ discard block |
||
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 | global $IP; |
12 | 12 | |
13 | 13 | //if ( !is_readable( $autoloaderClassPath = __DIR__ . '/../../SemanticMediaWiki/tests/autoloader.php' ) ) { |
14 | -if ( !is_readable( $autoloaderClassPath = $IP . '/extensions/SemanticMediaWiki/tests/autoloader.php' ) ) { |
|
15 | - die( "\nThe Semantic MediaWiki test autoloader is not available\n" ); |
|
14 | +if (!is_readable($autoloaderClassPath = $IP.'/extensions/SemanticMediaWiki/tests/autoloader.php')) { |
|
15 | + die("\nThe Semantic MediaWiki test autoloader is not available\n"); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | // if ( !class_exists( 'SemanticFormsSelect' ) || ( $version = SemanticFormsSelect::getVersion() ) === null ) { |
19 | -if ( ExtensionRegistry::getInstance()->isLoaded( 'SemanticFormsSelect' ) ) { |
|
20 | - die( "\nSemantic Forms Select is not available, please check your Composer or LocalSettings.\n" ); |
|
19 | +if (ExtensionRegistry::getInstance()->isLoaded('SemanticFormsSelect')) { |
|
20 | + die("\nSemantic Forms Select is not available, please check your Composer or LocalSettings.\n"); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | //print sprintf( "\n%-20s%s\n", "Semantic Forms Select: ", ExtensionRegistry::getInstance()->isLoaded( 'SemanticFormsSelect' ) ); |
@@ -26,4 +26,4 @@ discard block |
||
26 | 26 | $autoloader = require $autoloaderClassPath; |
27 | 27 | //$autoloader->addPsr4( 'SFS\\Tests\\', __DIR__ . '/phpunit/Unit' ); |
28 | 28 | //$autoloader->addPsr4( 'SFS\\Tests\\Integration\\', __DIR__ . '/phpunit/Integration' ); |
29 | -unset( $autoloader ); |
|
29 | +unset($autoloader); |
@@ -21,43 +21,43 @@ |
||
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 |
@@ -21,7 +21,7 @@ discard block |
||
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 |
||
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 |
||
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; |
@@ -17,13 +17,13 @@ discard block |
||
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 |
||
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 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @param array $data |
27 | 27 | */ |
28 | - public static function addToHeadItem( Array $data = [] ) { |
|
28 | + public static function addToHeadItem(Array $data = []) { |
|
29 | 29 | return self::$headItems[] = $data; |
30 | 30 | } |
31 | 31 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | // to be used in JS like: |
40 | 40 | // var SFSelect_fobjs = $.parseJSON( mw.config.get( 'sf_select' ) ); |
41 | - $wgOut->addJsConfigVars('sf_select', json_encode( self::$headItems )); |
|
41 | + $wgOut->addJsConfigVars('sf_select', json_encode(self::$headItems)); |
|
42 | 42 | |
43 | 43 | //self::$resourceModules = array(); |
44 | 44 | //self::$headItems = array(); |