Merge "Don't armor french spaces before punctuation followed by word characters"
[lhc/web/wiklou.git] / includes / libs / Timing.php
index 57c253d..65a9247 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() );
        }
 
        /**
@@ -83,7 +83,7 @@ class Timing implements LoggerAwareInterface {
        }
 
        /**
-        * @param string $markName The name of the mark that should
+        * @param string|null $markName The name of the mark that should
         *  be cleared. If not specified, all marks will be cleared.
         */
        public function clearMarks( $markName = null ) {
@@ -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,
                                ],
                        ];
@@ -119,7 +117,7 @@ class Timing implements LoggerAwareInterface {
         *
         * @param string $measureName
         * @param string $startMark
-        * @param string $endMark
+        * @param string|null $endMark
         * @return array|bool The measure that has been created, or false if either
         *  the start mark or the end mark do not exist.
         */
@@ -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;
        }
 }