r100041 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100040‎ | r100041 | r100042 >
Date:15:56, 17 October 2011
Author:happy-melon
Status:ok (Comments)
Tags:
Comment:
Type hinting
Modified paths:
  • /trunk/phase3/includes/HTMLForm.php (modified) (history)
  • /trunk/phase3/includes/Xml.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Xml.php
@@ -334,10 +334,10 @@
335335
336336 /**
337337 * Convenience function to build an HTML radio button
338 - * @param $name value of the name attribute
339 - * @param $value value of the value attribute
340 - * @param $checked Whether the checkbox is checked or not
341 - * @param $attribs other attributes
 338+ * @param $name String value of the name attribute
 339+ * @param $value String value of the value attribute
 340+ * @param $checked Bool Whether the checkbox is checked or not
 341+ * @param $attribs Array other attributes
342342 * @return string HTML
343343 */
344344 public static function radio( $name, $value, $checked = false, $attribs = array() ) {
@@ -376,8 +376,8 @@
377377 * @param $label String text of the label
378378 * @param $name String value of the name attribute
379379 * @param $id String id of the input
380 - * @param $size int value of the size attribute
381 - * @param $value value of the value attribute
 380+ * @param $size Int|Bool value of the size attribute
 381+ * @param $value String|Bool value of the value attribute
382382 * @param $attribs array other attributes
383383 * @return string HTML
384384 */
@@ -389,11 +389,11 @@
390390 /**
391391 * Same as Xml::inputLabel() but return input and label in an array
392392 *
393 - * @param $label
394 - * @param $name
395 - * @param $id
396 - * @param $size
397 - * @param $value
 393+ * @param $label String
 394+ * @param $name String
 395+ * @param $id String
 396+ * @param $size Int|Bool
 397+ * @param $value String|Bool
398398 * @param $attribs array
399399 *
400400 * @return array
Index: trunk/phase3/includes/HTMLForm.php
@@ -81,7 +81,10 @@
8282 );
8383
8484 protected $mMessagePrefix;
 85+
 86+ /** @var HTMLFormField[] */
8587 protected $mFlatFields;
 88+
8689 protected $mFieldTree;
8790 protected $mShowReset = false;
8891 public $mFieldData;
@@ -512,6 +515,7 @@
513516
514517 /**
515518 * Get the whole body of the form.
 519+ * @return String
516520 */
517521 function getBody() {
518522 return $this->displaySection( $this->mFieldTree );
@@ -686,9 +690,10 @@
687691
688692 /**
689693 * TODO: Document
690 - * @param $fields array of fields (either arrays or objects)
 694+ * @param $fields array[]|HTMLFormField[] array of fields (either arrays or objects)
691695 * @param $sectionName string ID attribute of the <table> tag for this section, ignored if empty
692696 * @param $fieldsetIDPrefix string ID prefix for the <fieldset> tag of each subsection, ignored if empty
 697+ * @return String
693698 */
694699 function displaySection( $fields, $sectionName = '', $fieldsetIDPrefix = '' ) {
695700 $tableHtml = '';
@@ -1310,6 +1315,7 @@
13111316 /**
13121317 * For a checkbox, the label goes on the right hand side, and is
13131318 * added in getInputHTML(), rather than HTMLFormField::getRow()
 1319+ * @return String
13141320 */
13151321 function getLabel() {
13161322 return '&#160;';
@@ -1756,6 +1762,8 @@
17571763 /**
17581764 * This returns a block of all the radio options, in one cell.
17591765 * @see includes/HTMLFormField#getInputHTML()
 1766+ * @param $value String
 1767+ * @return String
17601768 */
17611769 function getInputHTML( $value ) {
17621770 $html = $this->formatOptions( $this->mParams['options'], $value );
@@ -1881,6 +1889,9 @@
18821890
18831891 /**
18841892 * Button cannot be invalid
 1893+ * @param $value String
 1894+ * @param $alldata Array
 1895+ * @return Bool
18851896 */
18861897 public function validate( $value, $alldata ){
18871898 return true;

Comments

#Comment by Nikerabbit (talk | contribs)   17:54, 17 October 2011

So we started using foo[] syntax now?

#Comment by Happy-melon (talk | contribs)   19:04, 17 October 2011

HTMLFormField[] 'works' (ie after calling foreach( $array as $foo => $bar ){ ... }, $bar is recognised as being an HTMLFormField by my IDE); while Array( HTMLFormField ) doesn't.

Status & tagging log