From c243872abb9784002e886e8d5cb74fb909e536e6 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 2 Mar 2020 02:55:35 +0000 Subject: [PATCH] profiler: Document SectionProfiler private start and end as 'array|null' Follows-up I2d35bfddfcc4c194aa7. Also add a second check for is_array on end to please static analysis. Change-Id: Ie8cf4bb1a6e64479cc411f049d7aab08570e6aa1 --- includes/profiler/SectionProfiler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/profiler/SectionProfiler.php b/includes/profiler/SectionProfiler.php index 2365551f02f..ebf09e58376 100644 --- a/includes/profiler/SectionProfiler.php +++ b/includes/profiler/SectionProfiler.php @@ -28,9 +28,9 @@ use Wikimedia\ScopedCallback; * @ingroup Profiler */ class SectionProfiler { - /** @var array Map of (mem,real,cpu) */ + /** @var array|null Map of (mem,real,cpu) */ protected $start; - /** @var array Map of (mem,real,cpu) */ + /** @var array|null Map of (mem,real,cpu) */ protected $end; /** @var array[] List of resolved profile calls with start/end data */ protected $stack = []; @@ -96,7 +96,7 @@ class SectionProfiler { public function getFunctionStats() { $this->collateData(); - if ( is_array( $this->start ) ) { + if ( is_array( $this->start ) && is_array( $this->end ) ) { $totalCpu = max( $this->end['cpu'] - $this->start['cpu'], 0 ); $totalReal = max( $this->end['real'] - $this->start['real'], 0 ); $totalMem = max( $this->end['memory'] - $this->start['memory'], 0 );