Skip to content

Commit

Permalink
Fix glob pattern escaping.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Nov 29, 2024
1 parent 89b6331 commit ee96e7f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Command/BakeMigrationDiffCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function bake(string $name, Arguments $args, ConsoleIo $io): void
protected function setup(Arguments $args): void
{
$this->migrationsPath = $this->getPath($args);
$this->migrationsFiles = glob($this->migrationsPath . '*.php') ?: [];
$this->migrationsFiles = glob($this->migrationsPath . '*\\.php') ?: [];
$this->phinxTable = $this->getPhinxTable($this->plugin);

$connection = ConnectionManager::get($this->connection);
Expand Down
2 changes: 1 addition & 1 deletion src/Util/TableFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function findTables(?string $pluginName = null): array
return [];
}

return array_map('basename', glob($path . '*.php') ?: []);
return array_map('basename', glob($path . '*\\.php') ?: []);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Command/BakeMigrationSnapshotCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function testNotEmptySnapshotNoLock()
$bakeName = $this->getBakeName('TestNotEmptySnapshot');
$this->exec("bake migration_snapshot {$bakeName} -c test --no-lock");

$generatedMigration = glob($this->migrationPath . '*_TestNotEmptySnapshot*.php');
$generatedMigration = glob($this->migrationPath . '*_TestNotEmptySnapshot*\\.php');
$this->generatedFiles = $generatedMigration;
$this->generatedFiles[] = $this->migrationPath . 'schema-dump-test.lock';
$generatedMigration = basename($generatedMigration[0]);
Expand Down Expand Up @@ -198,7 +198,7 @@ protected function runSnapshotTest(string $scenario, string $arguments = ''): vo
$bakeName = $this->getBakeName("TestSnapshot{$scenario}");
$this->exec("bake migration_snapshot {$bakeName} -c test{$arguments}");

$generatedMigration = glob($this->migrationPath . "*_TestSnapshot{$scenario}*.php");
$generatedMigration = glob($this->migrationPath . "*_TestSnapshot{$scenario}*\\.php");
$this->generatedFiles = $generatedMigration;
$this->generatedFiles[] = $this->migrationPath . 'schema-dump-test.lock';

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Command/Phinx/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function testExecute()
'--connection' => 'test',
]);

$files = glob(ROOT . DS . 'config' . DS . 'Create' . DS . '*_TestCreateChange*.php');
$files = glob(ROOT . DS . 'config' . DS . 'Create' . DS . '*_TestCreateChange*\\.php');
$this->generatedFiles = $files;
$this->assertNotEmpty($files);

Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Util/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function testGlobPath()
$this->assertCount(1, $files);
$this->assertEquals('empty.txt', basename($files[0]));

$files = Util::glob(__DIR__ . '/_files/migrations/*.php');
$files = Util::glob(__DIR__ . '/_files/migrations/*\\.php');
$this->assertCount(3, $files);
$this->assertEquals('20120111235330_test_migration.php', basename($files[0]));
$this->assertEquals('20120116183504_test_migration_2.php', basename($files[1]));
Expand All @@ -121,8 +121,8 @@ public function testGlobPath()
public function testGlobAll()
{
$files = Util::globAll([
__DIR__ . '/_files/migrations/*.php',
__DIR__ . '/_files/migrations/subdirectory/*.txt',
__DIR__ . '/_files/migrations/*\\.php',
__DIR__ . '/_files/migrations/subdirectory/*\\.txt',
]);

$this->assertCount(4, $files);
Expand Down

0 comments on commit ee96e7f

Please sign in to comment.