Skip to content

Commit e51a1d9

Browse files
committed
fix: number_format(): Passing null to parameter #1 ($num) of type float is deprecated
Fixes #5535
1 parent 6b2816c commit e51a1d9

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

system/Database/BaseConnection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,14 @@ abstract class BaseConnection implements ConnectionInterface
258258
*
259259
* @var float
260260
*/
261-
protected $connectTime;
261+
protected $connectTime = 0.0;
262262

263263
/**
264264
* How long it took to establish connection.
265265
*
266266
* @var float
267267
*/
268-
protected $connectDuration;
268+
protected $connectDuration = 0.0;
269269

270270
/**
271271
* If true, no queries will actually be

tests/system/Database/BaseConnectionTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ public function testStoresConnectionTimings()
123123
$this->assertGreaterThan(0.0, $db->getConnectDuration());
124124
}
125125

126+
/**
127+
* @see https://github.com/codeigniter4/CodeIgniter4/issues/5535
128+
*/
129+
public function testStoresConnectionTimingsNotConnected()
130+
{
131+
$db = new MockConnection($this->options);
132+
133+
$this->assertSame('0.000000', $db->getConnectDuration());
134+
}
135+
126136
public function testMagicIssetTrue()
127137
{
128138
$db = new MockConnection($this->options);

0 commit comments

Comments
 (0)