diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 8d647f40e497..1493398334c1 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -1146,11 +1146,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/Migration.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Database\\\\Migration\\:\\:\\$DBGroup \\(string\\) on left side of \\?\\? is not nullable\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/Migration.php', -]; $ignoreErrors[] = [ 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', 'count' => 8, diff --git a/system/Database/Migration.php b/system/Database/Migration.php index 1616830f9267..f12509d6264a 100644 --- a/system/Database/Migration.php +++ b/system/Database/Migration.php @@ -21,7 +21,7 @@ abstract class Migration /** * The name of the database group to use. * - * @var string + * @var string|null */ protected $DBGroup; @@ -39,12 +39,15 @@ abstract class Migration */ protected $forge; - /** - * Constructor. - */ public function __construct(?Forge $forge = null) { - $this->forge = $forge ?? Database::forge($this->DBGroup ?? config(Database::class)->defaultGroup); + if (isset($this->DBGroup)) { + $this->forge = Database::forge($this->DBGroup); + } elseif ($forge !== null) { + $this->forge = $forge; + } else { + $this->forge = Database::forge(config(Database::class)->defaultGroup); + } $this->db = $this->forge->getConnection(); }