aboutsummaryrefslogtreecommitdiffstats
path: root/includes/htmlform
diff options
context:
space:
mode:
Diffstat (limited to 'includes/htmlform')
-rw-r--r--includes/htmlform/HTMLForm.php12
-rw-r--r--includes/htmlform/HTMLFormElement.php4
-rw-r--r--includes/htmlform/HTMLFormField.php6
-rw-r--r--includes/htmlform/fields/HTMLExpiryField.php2
-rw-r--r--includes/htmlform/fields/HTMLFloatField.php2
-rw-r--r--includes/htmlform/fields/HTMLFormFieldCloner.php12
-rw-r--r--includes/htmlform/fields/HTMLSelectAndOtherField.php5
-rw-r--r--includes/htmlform/fields/HTMLSelectOrOtherField.php4
-rw-r--r--includes/htmlform/fields/HTMLSizeFilterField.php2
-rw-r--r--includes/htmlform/fields/HTMLTextAreaField.php6
-rw-r--r--includes/htmlform/fields/HTMLTextField.php6
11 files changed, 24 insertions, 37 deletions
diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php
index 043e0f632b29..785d30f8a305 100644
--- a/includes/htmlform/HTMLForm.php
+++ b/includes/htmlform/HTMLForm.php
@@ -333,9 +333,7 @@ class HTMLForm extends ContextSource {
$this->mFlatFields = [];
foreach ( $descriptor as $fieldname => $info ) {
- $section = isset( $info['section'] )
- ? $info['section']
- : '';
+ $section = $info['section'] ?? '';
if ( isset( $info['type'] ) && $info['type'] === 'file' ) {
$this->mUseMultipart = true;
@@ -805,7 +803,7 @@ class HTMLForm extends ContextSource {
if ( $section === null ) {
return $this->mHeader;
} else {
- return isset( $this->mSectionHeaders[$section] ) ? $this->mSectionHeaders[$section] : '';
+ return $this->mSectionHeaders[$section] ?? '';
}
}
@@ -860,7 +858,7 @@ class HTMLForm extends ContextSource {
if ( $section === null ) {
return $this->mFooter;
} else {
- return isset( $this->mSectionFooters[$section] ) ? $this->mSectionFooters[$section] : '';
+ return $this->mSectionFooters[$section] ?? '';
}
}
@@ -959,8 +957,8 @@ class HTMLForm extends ContextSource {
$data = [
'name' => $args[0],
'value' => $args[1],
- 'id' => isset( $args[2] ) ? $args[2] : null,
- 'attribs' => isset( $args[3] ) ? $args[3] : null,
+ 'id' => $args[2] ?? null,
+ 'attribs' => $args[3] ?? null,
];
} else {
if ( !isset( $data['name'] ) ) {
diff --git a/includes/htmlform/HTMLFormElement.php b/includes/htmlform/HTMLFormElement.php
index 2830b9c258e2..fbef2651f669 100644
--- a/includes/htmlform/HTMLFormElement.php
+++ b/includes/htmlform/HTMLFormElement.php
@@ -13,8 +13,8 @@ trait HTMLFormElement {
public function initializeHTMLFormElement( array $config = [] ) {
// Properties
- $this->hideIf = isset( $config['hideIf'] ) ? $config['hideIf'] : null;
- $this->modules = isset( $config['modules'] ) ? $config['modules'] : [];
+ $this->hideIf = $config['hideIf'] ?? null;
+ $this->modules = $config['modules'] ?? [];
// Initialization
if ( $this->hideIf ) {
diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php
index 5066f28ee432..cd4d4b749f87 100644
--- a/includes/htmlform/HTMLFormField.php
+++ b/includes/htmlform/HTMLFormField.php
@@ -546,8 +546,7 @@ abstract class HTMLFormField {
'mw-htmlform-nolabel' => ( $label === '' )
];
- $horizontalLabel = isset( $this->mParams['horizontal-label'] )
- ? $this->mParams['horizontal-label'] : false;
+ $horizontalLabel = $this->mParams['horizontal-label'] ?? false;
if ( $horizontalLabel ) {
$field = ' ' . $inputHtml . "\n$errors";
@@ -950,8 +949,7 @@ abstract class HTMLFormField {
$displayFormat = $this->mParent->getDisplayFormat();
$html = '';
- $horizontalLabel = isset( $this->mParams['horizontal-label'] )
- ? $this->mParams['horizontal-label'] : false;
+ $horizontalLabel = $this->mParams['horizontal-label'] ?? false;
if ( $displayFormat === 'table' ) {
$html =
diff --git a/includes/htmlform/fields/HTMLExpiryField.php b/includes/htmlform/fields/HTMLExpiryField.php
index dfe6a8a62389..e7bdb44b85ec 100644
--- a/includes/htmlform/fields/HTMLExpiryField.php
+++ b/includes/htmlform/fields/HTMLExpiryField.php
@@ -56,7 +56,7 @@ class HTMLExpiryField extends HTMLFormField {
$this->relativeField->getInputOOUI( $value ),
[
'id' => $this->mID,
- 'required' => isset( $this->mParams['required'] ) ? $this->mParams['required'] : false,
+ 'required' => $this->mParams['required'] ?? false,
]
);
}
diff --git a/includes/htmlform/fields/HTMLFloatField.php b/includes/htmlform/fields/HTMLFloatField.php
index d2d54e28d060..72381f016194 100644
--- a/includes/htmlform/fields/HTMLFloatField.php
+++ b/includes/htmlform/fields/HTMLFloatField.php
@@ -5,7 +5,7 @@
*/
class HTMLFloatField extends HTMLTextField {
public function getSize() {
- return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 20;
+ return $this->mParams['size'] ?? 20;
}
public function validate( $value, $alldata ) {
diff --git a/includes/htmlform/fields/HTMLFormFieldCloner.php b/includes/htmlform/fields/HTMLFormFieldCloner.php
index 53c6835949e5..6beb9966672f 100644
--- a/includes/htmlform/fields/HTMLFormFieldCloner.php
+++ b/includes/htmlform/fields/HTMLFormFieldCloner.php
@@ -273,9 +273,7 @@ class HTMLFormFieldCloner extends HTMLFormField {
* @return string
*/
protected function getInputHTMLForKey( $key, array $values ) {
- $displayFormat = isset( $this->mParams['format'] )
- ? $this->mParams['format']
- : $this->mParent->getDisplayFormat();
+ $displayFormat = $this->mParams['format'] ?? $this->mParent->getDisplayFormat();
// Conveniently, PHP method names are case-insensitive.
$getFieldHtmlMethod = $displayFormat == 'table' ? 'getTableRow' : ( 'get' . $displayFormat );
@@ -306,9 +304,7 @@ class HTMLFormFieldCloner extends HTMLFormField {
if ( !isset( $fields['delete'] ) ) {
$name = "{$this->mName}[$key][delete]";
- $label = isset( $this->mParams['delete-button-message'] )
- ? $this->mParams['delete-button-message']
- : 'htmlform-cloner-delete';
+ $label = $this->mParams['delete-button-message'] ?? 'htmlform-cloner-delete';
$field = HTMLForm::loadInputFromParameters( $name, [
'type' => 'submit',
'formnovalidate' => true,
@@ -379,9 +375,7 @@ class HTMLFormFieldCloner extends HTMLFormField {
], $html );
$name = "{$this->mName}[create]";
- $label = isset( $this->mParams['create-button-message'] )
- ? $this->mParams['create-button-message']
- : 'htmlform-cloner-create';
+ $label = $this->mParams['create-button-message'] ?? 'htmlform-cloner-create';
$field = HTMLForm::loadInputFromParameters( $name, [
'type' => 'submit',
'formnovalidate' => true,
diff --git a/includes/htmlform/fields/HTMLSelectAndOtherField.php b/includes/htmlform/fields/HTMLSelectAndOtherField.php
index 610b5093057f..a4d9bca67b98 100644
--- a/includes/htmlform/fields/HTMLSelectAndOtherField.php
+++ b/includes/htmlform/fields/HTMLSelectAndOtherField.php
@@ -126,8 +126,7 @@ class HTMLSelectAndOtherField extends HTMLSelectField {
'or' => false,
'classes' => [ 'mw-htmlform-select-and-other-field' ],
'data' => [
- 'maxlengthUnit' => isset( $this->mParams['maxlength-unit'] )
- ? $this->mParams['maxlength-unit'] : 'bytes'
+ 'maxlengthUnit' => $this->mParams['maxlength-unit'] ?? 'bytes'
],
] );
}
@@ -177,7 +176,7 @@ class HTMLSelectAndOtherField extends HTMLSelectField {
}
public function getSize() {
- return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
+ return $this->mParams['size'] ?? 45;
}
public function validate( $value, $alldata ) {
diff --git a/includes/htmlform/fields/HTMLSelectOrOtherField.php b/includes/htmlform/fields/HTMLSelectOrOtherField.php
index fb133f20e5d0..91050a0cc672 100644
--- a/includes/htmlform/fields/HTMLSelectOrOtherField.php
+++ b/includes/htmlform/fields/HTMLSelectOrOtherField.php
@@ -12,9 +12,7 @@ class HTMLSelectOrOtherField extends HTMLTextField {
$this->getOptions();
if ( !in_array( 'other', $this->mOptions, true ) ) {
$msg =
- isset( $params['other'] )
- ? $params['other']
- : wfMessage( 'htmlform-selectorother-other' )->text();
+ $params['other'] ?? wfMessage( 'htmlform-selectorother-other' )->text();
// Have 'other' always as first element
$this->mOptions = [ $msg => 'other' ] + $this->mOptions;
}
diff --git a/includes/htmlform/fields/HTMLSizeFilterField.php b/includes/htmlform/fields/HTMLSizeFilterField.php
index 145a0ecdb20f..bd96d3c61fb7 100644
--- a/includes/htmlform/fields/HTMLSizeFilterField.php
+++ b/includes/htmlform/fields/HTMLSizeFilterField.php
@@ -10,7 +10,7 @@
*/
class HTMLSizeFilterField extends HTMLIntField {
public function getSize() {
- return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 9;
+ return $this->mParams['size'] ?? 9;
}
public function getInputHTML( $value ) {
diff --git a/includes/htmlform/fields/HTMLTextAreaField.php b/includes/htmlform/fields/HTMLTextAreaField.php
index 3370e4af13af..e9ed03198285 100644
--- a/includes/htmlform/fields/HTMLTextAreaField.php
+++ b/includes/htmlform/fields/HTMLTextAreaField.php
@@ -29,15 +29,15 @@ class HTMLTextAreaField extends HTMLFormField {
}
public function getCols() {
- return isset( $this->mParams['cols'] ) ? $this->mParams['cols'] : static::DEFAULT_COLS;
+ return $this->mParams['cols'] ?? static::DEFAULT_COLS;
}
public function getRows() {
- return isset( $this->mParams['rows'] ) ? $this->mParams['rows'] : static::DEFAULT_ROWS;
+ return $this->mParams['rows'] ?? static::DEFAULT_ROWS;
}
public function getSpellCheck() {
- $val = isset( $this->mParams['spellcheck'] ) ? $this->mParams['spellcheck'] : null;
+ $val = $this->mParams['spellcheck'] ?? null;
if ( is_bool( $val ) ) {
// "spellcheck" attribute literally requires "true" or "false" to work.
return $val === true ? 'true' : 'false';
diff --git a/includes/htmlform/fields/HTMLTextField.php b/includes/htmlform/fields/HTMLTextField.php
index b2e4f2a5596f..b51182a2da9a 100644
--- a/includes/htmlform/fields/HTMLTextField.php
+++ b/includes/htmlform/fields/HTMLTextField.php
@@ -38,11 +38,11 @@ class HTMLTextField extends HTMLFormField {
}
public function getSize() {
- return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
+ return $this->mParams['size'] ?? 45;
}
public function getSpellCheck() {
- $val = isset( $this->mParams['spellcheck'] ) ? $this->mParams['spellcheck'] : null;
+ $val = $this->mParams['spellcheck'] ?? null;
if ( is_bool( $val ) ) {
// "spellcheck" attribute literally requires "true" or "false" to work.
return $val === true ? 'true' : 'false';
@@ -107,7 +107,7 @@ class HTMLTextField extends HTMLFormField {
}
protected function getType( &$attribs ) {
- $type = isset( $attribs['type'] ) ? $attribs['type'] : 'text';
+ $type = $attribs['type'] ?? 'text';
unset( $attribs['type'] );
# Implement tiny differences between some field variants