* A License class for use on Special:Upload
*/
class Licenses extends HTMLFormField {
- /**
- * @var string
- */
+ /** @var string */
protected $msg;
- /**
- * @var array
- */
- protected $licenses = array();
+ /** @var array */
+ protected $licenses = [];
- /**
- * @var string
- */
+ /** @var string */
protected $html;
/**#@-*/
/**
- * Constructor
- *
- * @param $params array
+ * @param array $params
*/
public function __construct( $params ) {
parent::__construct( $params );
- $this->msg = empty( $params['licenses'] ) ? wfMessage( 'licenses' )->inContentLanguage()->plain() : $params['licenses'];
+ $this->msg = empty( $params['licenses'] )
+ ? wfMessage( 'licenses' )->inContentLanguage()->plain()
+ : $params['licenses'];
$this->selected = null;
$this->makeLicenses();
* @private
*/
protected function makeLicenses() {
- $levels = array();
+ $levels = [];
$lines = explode( "\n", $this->msg );
foreach ( $lines as $line ) {
}
/**
- * @param $str
+ * @param string $str
* @return array
*/
protected function trimStars( $str ) {
$numStars = strspn( $str, '*' );
- return array( $numStars, ltrim( substr( $str, $numStars ), ' ' ) );
+ return [ $numStars, ltrim( substr( $str, $numStars ), ' ' ) ];
}
/**
- * @param $list
- * @param $path
- * @param $item
+ * @param array $list
+ * @param array $path
+ * @param mixed $item
*/
protected function stackItem( &$list, $path, $item ) {
$position =& $list;
if ( $path ) {
- foreach( $path as $key ) {
+ foreach ( $path as $key ) {
$position =& $position[$key];
}
}
}
/**
- * @param $tagset
- * @param $depth int
+ * @param array $tagset
+ * @param int $depth
*/
protected function makeHtml( $tagset, $depth = 0 ) {
foreach ( $tagset as $key => $val ) {
if ( is_array( $val ) ) {
$this->html .= $this->outputOption(
$key, '',
- array(
+ [
'disabled' => 'disabled',
'style' => 'color: GrayText', // for MSIE
- ),
+ ],
$depth
);
$this->makeHtml( $val, $depth + 1 );
} else {
$this->html .= $this->outputOption(
$val->text, $val->template,
- array( 'title' => '{{' . $val->template . '}}' ),
+ [ 'title' => '{{' . $val->template . '}}' ],
$depth
);
}
}
/**
- * @param $message
- * @param $value
- * @param $attribs null
- * @param $depth int
+ * @param string $message
+ * @param string $value
+ * @param null|array $attribs
+ * @param int $depth
* @return string
*/
protected function outputOption( $message, $value, $attribs = null, $depth = 0 ) {
/**
* Accessor for $this->html
*
- * @param $value bool
+ * @param bool $value
*
* @return string
*/
$this->selected = $value;
$this->html = $this->outputOption( wfMessage( 'nolicense' )->text(), '',
- (bool)$this->selected ? null : array( 'selected' => 'selected' ) );
+ (bool)$this->selected ? null : [ 'selected' => 'selected' ] );
$this->makeHtml( $this->getLicenses() );
- $attribs = array(
+ $attribs = [
'name' => $this->mName,
'id' => $this->mID
- );
+ ];
if ( !empty( $this->mParams['disabled'] ) ) {
$attibs['disabled'] = 'disabled';
}
* A License class for use on Special:Upload (represents a single type of license).
*/
class License {
- /**
- * @var string
- */
- var $template;
+ /** @var string */
+ public $template;
- /**
- * @var string
- */
- var $text;
+ /** @var string */
+ public $text;
/**
- * Constructor
- *
- * @param string $str license name??
+ * @param string $str License name??
*/
function __construct( $str ) {
list( $text, $template ) = explode( '|', strrev( $str ), 2 );