Skip to content

Commit 8b9285f

Browse files
authored
Configure nullable types explicitly to avoid deprecation warnings in PHP 8.4 (#73)
1 parent cbe0d1f commit 8b9285f

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/Codeception/Lib/DbPopulator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct(array $config)
5353
* @param string|null $dumpFile The dump file to build the command with.
5454
* @return string The resulting command string after evaluating any configuration's key
5555
*/
56-
protected function buildCommand(string $command, string $dumpFile = null): string
56+
protected function buildCommand(string $command, ?string $dumpFile = null): string
5757
{
5858
$dsn = $this->config['dsn'] ?? '';
5959
$dsnVars = [];

src/Codeception/Lib/Driver/Db.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Db
3131
*/
3232
protected array $primaryKeys = [];
3333

34-
public static function connect(string $dsn, string $user = null, string $password = null, array $options = null): PDO
34+
public static function connect(string $dsn, ?string $user = null, ?string $password = null, ?array $options = null): PDO
3535
{
3636
$dbh = new PDO($dsn, $user, $password, $options);
3737
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -47,7 +47,7 @@ public static function connect(string $dsn, string $user = null, string $passwor
4747
*
4848
* @return Db|SqlSrv|MySql|Oci|PostgreSql|Sqlite
4949
*/
50-
public static function create(string $dsn, string $user = null, string $password = null, array $options = null): Db
50+
public static function create(string $dsn, ?string $user = null, ?string $password = null, ?array $options = null): Db
5151
{
5252
$provider = self::getProvider($dsn);
5353

@@ -78,7 +78,7 @@ public static function getProvider($dsn): string
7878
* @see https://www.php.net/manual/en/pdo.construct.php
7979
* @see https://www.php.net/manual/de/ref.pdo-mysql.php#pdo-mysql.constants
8080
*/
81-
public function __construct(string $dsn, string $user = null, string $password = null, array $options = null)
81+
public function __construct(string $dsn, ?string $user = null, ?string $password = null, ?array $options = null)
8282
{
8383
$this->dbh = new PDO($dsn, $user, $password, $options);
8484
$this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

src/Codeception/Lib/Driver/Sqlite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Sqlite extends Db
1414

1515
protected string $filename = '';
1616

17-
public function __construct(string $dsn, string $user = null, string $password = null, array $options = null)
17+
public function __construct(string $dsn, ?string $user = null, ?string $password = null, ?array $options = null)
1818
{
1919
$filename = substr($dsn, 7);
2020
if ($filename === ':memory:') {

src/Codeception/Module/Db.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ protected function removeInserted($databaseKey = null): void
684684
$this->insertedRows[$databaseKey] = [];
685685
}
686686

687-
public function _cleanup(string $databaseKey = null, array $databaseConfig = null): void
687+
public function _cleanup(?string $databaseKey = null, ?array $databaseConfig = null): void
688688
{
689689
$databaseKey = empty($databaseKey) ? self::DEFAULT_DATABASE : $databaseKey;
690690
$databaseConfig = empty($databaseConfig) ? $this->config : $databaseConfig;
@@ -737,7 +737,7 @@ public function _isPopulated()
737737
return $this->databasesPopulated[$this->currentDatabase];
738738
}
739739

740-
public function _loadDump(string $databaseKey = null, array $databaseConfig = null): void
740+
public function _loadDump(?string $databaseKey = null, ?array $databaseConfig = null): void
741741
{
742742
$databaseKey = empty($databaseKey) ? self::DEFAULT_DATABASE : $databaseKey;
743743
$databaseConfig = empty($databaseConfig) ? $this->config : $databaseConfig;

0 commit comments

Comments
 (0)