diff options
author | Bartosz DziewoĆski <matma.rex@gmail.com> | 2017-10-07 00:17:58 +0200 |
---|---|---|
committer | James D. Forrester <jforrester@wikimedia.org> | 2018-05-30 18:06:13 -0700 |
commit | 485f66f1744fea056e20a5bef619989bf1749202 (patch) | |
tree | 10f1fa9496adf8a6057e28138c941bb2671fbeec /includes/htmlform/HTMLForm.php | |
parent | b191e5e860f24e1dd05e3d3d782364e4ea75b176 (diff) | |
download | mediawikicore-485f66f1744fea056e20a5bef619989bf1749202.tar.gz mediawikicore-485f66f1744fea056e20a5bef619989bf1749202.zip |
Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '
(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)
Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).
Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
Diffstat (limited to 'includes/htmlform/HTMLForm.php')
-rw-r--r-- | includes/htmlform/HTMLForm.php | 12 |
1 files changed, 5 insertions, 7 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'] ) ) { |