Skip to content

Commit

Permalink
fix warning in info when using connection config (#2312)
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOdin authored Sep 25, 2024
1 parent 2e9d7d2 commit 0ef61fc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Phinx/Console/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Phinx\Console\Command;

use InvalidArgumentException;
use PDO;
use Phinx\Config\Config;
use Phinx\Config\ConfigInterface;
use Phinx\Db\Adapter\AdapterInterface;
Expand Down Expand Up @@ -467,7 +468,12 @@ protected function writeInformationOutput(?string &$environment, OutputInterface

if (isset($envOptions['name'])) {
$name = $envOptions['name'];
if ($envOptions['adapter'] === 'sqlite') {
// We do error handling for missing adapter or connection is invalid later on running a command
$adapter = $envOptions['adapter'] ?? null;
if (isset($envOptions['connection']) && $envOptions['connection'] instanceof PDO) {
$adapter = $envOptions['connection']->getAttribute(PDO::ATTR_DRIVER_NAME);
}
if ($adapter === 'sqlite') {
$name .= SQLiteAdapter::getSuffix($envOptions);
}
$output->writeln('<info>using database</info> ' . $name, $this->verbosityLevel);
Expand Down

0 comments on commit 0ef61fc

Please sign in to comment.