Skip to content

Commit

Permalink
Assert there is no failure
Browse files Browse the repository at this point in the history
The pattern is not dynamic, and we know it works. This addresses an
issue reported by PHPStan.
  • Loading branch information
greg0ire committed Aug 27, 2024
1 parent a0eb4e1 commit edec5c5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit edec5c5

Please sign in to comment.