Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
[lhc/web/wiklou.git] / includes / libs / Timing.php
index 57c253d..04a13e2 100644 (file)
@@ -52,7 +52,7 @@ class Timing implements LoggerAwareInterface {
 
        public function __construct( array $params = [] ) {
                $this->clearMarks();
-               $this->setLogger( isset( $params['logger'] ) ? $params['logger'] : new NullLogger() );
+               $this->setLogger( $params['logger'] ?? new NullLogger() );
        }
 
        /**
@@ -94,9 +94,7 @@ class Timing implements LoggerAwareInterface {
                                'requestStart' => [
                                        'name'      => 'requestStart',
                                        'entryType' => 'mark',
-                                       'startTime' => isset( $_SERVER['REQUEST_TIME_FLOAT'] )
-                                               ? $_SERVER['REQUEST_TIME_FLOAT']
-                                               : $_SERVER['REQUEST_TIME'],
+                                       'startTime' => $_SERVER['REQUEST_TIME_FLOAT'],
                                        'duration'  => 0,
                                ],
                        ];
@@ -157,7 +155,7 @@ class Timing implements LoggerAwareInterface {
         */
        private function sortEntries() {
                uasort( $this->entries, function ( $a, $b ) {
-                       return 10000 * ( $a['startTime'] - $b['startTime'] );
+                       return $a['startTime'] <=> $b['startTime'];
                } );
        }
 
@@ -190,6 +188,6 @@ class Timing implements LoggerAwareInterface {
         * @return array|null Entry named $name or null if it does not exist.
         */
        public function getEntryByName( $name ) {
-               return isset( $this->entries[$name] ) ? $this->entries[$name] : null;
+               return $this->entries[$name] ?? null;
        }
 }