Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['8.2', '8.5']
php-version: ['8.2', '8.5', '8.6']
db-type: [mariadb, mysql, pgsql, sqlite]
prefer-lowest: ['']
legacy-tables: ['']
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
"require": {
"php": ">=8.2",
"cakephp/cache": "^5.3.0",
"cakephp/database": "^5.3.2",
"cakephp/database": "^5.4.4",
"cakephp/orm": "^5.3.0"
},
"require-dev": {
"cakephp/bake": "^3.3",
"cakephp/cakephp": "^5.3.0",
"cakephp/cakephp": "^5.4.4",
"cakephp/cakephp-codesniffer": "^5.0",
"phpunit/phpunit": "^11.5.3 || ^12.1.3 || ^13.0"
},
Expand Down Expand Up @@ -76,7 +76,7 @@
"stan-setup": "phive install",
"lowest": "validate-prefer-lowest",
"lowest-setup": "composer update --prefer-lowest --prefer-stable --prefer-dist --no-interaction && cp composer.json composer.backup && composer require --dev dereuromark/composer-prefer-lowest && mv composer.backup composer.json",
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"~2.7.0\" phpstan/phpstan:\"~2.3.0\" && mv composer.backup composer.json",
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"~2.7.0\" phpstan/phpstan:\"2.3.0\" && mv composer.backup composer.json",
"rector-check": "vendor/bin/rector process --dry-run",
"rector-fix": "vendor/bin/rector process",
"test": "phpunit",
Expand Down
5 changes: 5 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromCreateMockAssignRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnParentClassMethodRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictFluentReturnRector;

$cacheDir = getenv('RECTOR_CACHE_DIR') ?: sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'rector';
Expand Down Expand Up @@ -45,6 +46,10 @@
])

->withSkip([
// Keep Config::offsetGet() compatible with subclasses that omit its return type.
AddReturnTypeDeclarationBasedOnParentClassMethodRector::class => [
__DIR__ . '/src/Config/Config.php',
],
ClassPropertyAssignToConstructorPromotionRector::class,
CatchExceptionNameMatchingTypeRector::class,
ClosureToArrowFunctionRector::class,
Expand Down
5 changes: 3 additions & 2 deletions src/Command/BakeSimpleMigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ abstract class BakeSimpleMigrationCommand extends SimpleBakeCommand
'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor',
'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'final', 'finally', 'for', 'foreach',
'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface',
'isset', 'list', 'namespace', 'new', 'or', 'parent', 'private', 'protected', 'public', 'return','static',
'is', 'isset', 'let', 'list', 'namespace', 'new', 'or', 'parent', 'private', 'protected', 'public',
'return', 'static',
];

/**
Expand Down Expand Up @@ -181,8 +182,8 @@ protected function bake(string $name, Arguments $args, ConsoleIo $io): void
}

$renderer = new TemplateRenderer($this->theme);
$renderer->set('name', $name);
$renderer->set($this->templateData($args));
$renderer->set('name', $name);

$contents = $renderer->generate($this->template());

Expand Down
22 changes: 19 additions & 3 deletions tests/TestCase/Command/BakeMigrationCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,28 @@ public function testCreateDuplicateName(): void
/**
* Tests that baking a migration with the name as reserved keyword triggers prefixing.
*/
public function testCreateWithReservedKeyword(): void
#[DataProvider('reservedMigrationNames')]
public function testCreateWithReservedKeyword(string $name, string $className): void
{
$this->exec('bake migration New --connection test', ['Prefix']);
$this->exec(sprintf('bake migration %s --connection test', $name), ['Prefix']);

$files = glob(ROOT . DS . 'config' . DS . 'Migrations' . DS . '*_Prefix' . $className . '.php');
$this->generatedFile = current($files);
$this->assertExitCode(BaseCommand::CODE_SUCCESS);
$this->assertOutputRegExp('/Wrote.*?PrefixNew\.php/');
$this->assertOutputRegExp('/Wrote.*?Prefix' . $className . '\.php/');
$this->assertFileContains('class Prefix' . $className . ' extends BaseMigration', $this->generatedFile);
}

/**
* @return array<string, array{string, string}>
*/
public static function reservedMigrationNames(): array
{
return [
'new' => ['New', 'New'],
'let' => ['let', 'Let'],
'is' => ['IS', 'IS'],
];
}

public function testCreateBuiltInAlias(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Migration/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ public function testRollbackToVersionByName(array $availableRollbacks, ?string $

$this->manager = new Manager($config, $this->io);
$this->manager->setEnvironment($envStub);
$this->manager->rollback($availableRollbacks[$version]['migration_name'] ?? $version);
$this->manager->rollback($availableRollbacks[(string)$version]['migration_name'] ?? $version);

$output = $this->getOutput();

Expand Down
Loading