diff --git a/src/Generator/Generator.php b/src/Generator/Generator.php index fdd19854b..1945879b2 100644 --- a/src/Generator/Generator.php +++ b/src/Generator/Generator.php @@ -9,6 +9,7 @@ use Doctrine\Migrations\Tools\Console\Helper\MigrationDirectoryHelper; use InvalidArgumentException; +use function assert; use function explode; use function file_get_contents; use function file_put_contents; @@ -74,11 +75,14 @@ public function generateMigration( string|null $up = null, string|null $down = null, ): string { - $mch = []; - if (preg_match('~(.*)\\\\([^\\\\]+)~', $fqcn, $mch) === 0) { + $mch = []; + $matchResult = preg_match('~(.*)\\\\([^\\\\]+)~', $fqcn, $mch); + if ($matchResult === 0) { throw new InvalidArgumentException(sprintf('Invalid FQCN')); } + assert($matchResult !== false); + [$fqcn, $namespace, $className] = $mch; $dirs = $this->configuration->getMigrationDirectories();