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
This commit is contained in:
Timo Tijhof 2020-03-02 02:55:35 +00:00
parent f05872cfd6
commit c243872abb

View file

@ -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 );