Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
[lhc/web/wiklou.git] / includes / parser / Parser.php
index dfd9602..8df5b5b 100644 (file)
@@ -593,7 +593,7 @@ class Parser {
                // Add on template profiling data in human/machine readable way
                $dataByFunc = $this->mProfiler->getFunctionStats();
                uasort( $dataByFunc, function ( $a, $b ) {
-                       return $a['real'] < $b['real']; // descending order
+                       return $b['real'] <=> $a['real']; // descending order
                } );
                $profileReport = [];
                foreach ( array_slice( $dataByFunc, 0, 10 ) as $item ) {
@@ -3566,7 +3566,7 @@ class Parser {
                if ( is_string( $stuff['text'] ) ) {
                        $text = strtr( $text, "\x7f", "?" );
                }
-               $finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title;
+               $finalTitle = $stuff['finalTitle'] ?? $title;
                if ( isset( $stuff['deps'] ) ) {
                        foreach ( $stuff['deps'] as $dep ) {
                                $this->mOutput->addTemplate( $dep['title'], $dep['page_id'], $dep['rev_id'] );
@@ -4763,7 +4763,7 @@ class Parser {
                if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) {
                        throw new MWException( "Invalid character {$m[0]} in setHook('$tag', ...) call" );
                }
-               $oldVal = isset( $this->mTagHooks[$tag] ) ? $this->mTagHooks[$tag] : null;
+               $oldVal = $this->mTagHooks[$tag] ?? null;
                $this->mTagHooks[$tag] = $callback;
                if ( !in_array( $tag, $this->mStripList ) ) {
                        $this->mStripList[] = $tag;
@@ -4794,7 +4794,7 @@ class Parser {
                if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) {
                        throw new MWException( "Invalid character {$m[0]} in setTransparentHook('$tag', ...) call" );
                }
-               $oldVal = isset( $this->mTransparentTagHooks[$tag] ) ? $this->mTransparentTagHooks[$tag] : null;
+               $oldVal = $this->mTransparentTagHooks[$tag] ?? null;
                $this->mTransparentTagHooks[$tag] = $callback;
 
                return $oldVal;
@@ -4909,8 +4909,7 @@ class Parser {
                if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) {
                        throw new MWException( "Invalid character {$m[0]} in setFunctionTagHook('$tag', ...) call" );
                }
-               $old = isset( $this->mFunctionTagHooks[$tag] ) ?
-                       $this->mFunctionTagHooks[$tag] : null;
+               $old = $this->mFunctionTagHooks[$tag] ?? null;
                $this->mFunctionTagHooks[$tag] = [ $callback, $flags ];
 
                if ( !in_array( $tag, $this->mStripList ) ) {
@@ -5377,7 +5376,7 @@ class Parser {
                Hooks::run( 'ParserMakeImageParams', [ $title, $file, &$params, $this ] );
 
                # Linker does the rest
-               $time = isset( $options['time'] ) ? $options['time'] : false;
+               $time = $options['time'] ?? false;
                $ret = Linker::makeImageLink( $this, $title, $file, $params['frame'], $params['handler'],
                        $time, $descQuery, $this->mOptions->getThumbSize() );