Skip to content

Commit

Permalink
Merge pull request #288 from cakephp/5x-deprecations
Browse files Browse the repository at this point in the history
5.1 deprecations
  • Loading branch information
markstory authored Aug 18, 2024
2 parents 281b923 + 12f1d9e commit eab2a43
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
9 changes: 9 additions & 0 deletions config/rector/cakephp51.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
declare(strict_types=1);

use Cake\Upgrade\Rector\Set\CakePHPSetList;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([CakePHPSetList::CAKEPHP_51]);
};
14 changes: 14 additions & 0 deletions config/rector/sets/cakephp51.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\String_\RenameStringRector;

# @see https://book.cakephp.org/5/en/appendices/5-1-migration-guide.html
return static function (RectorConfig $rectorConfig): void {

$rectorConfig->ruleWithConfiguration(RenameStringRector::class, [
// Rename the cache configuration used by translations.
'_cake_core_' => '_cake_translations_',
]);
};
5 changes: 3 additions & 2 deletions src/Command/RectorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ protected function runRector(ConsoleIo $io, Arguments $args, string $autoload):

$cmdPath = ROOT . '/vendor/bin/rector process';
$command = sprintf(
'%s %s --autoload-file=%s --config=%s %s --clear-cache',
'%s %s %s --autoload-file=%s --config=%s %s --clear-cache',
$cmdPath,
$args->getOption('dry-run') ? '--dry-run' : '',
$args->getOption('verbose') ? '-vvvv' : '',
escapeshellarg($autoload),
escapeshellarg($config),
escapeshellarg($path)
Expand Down Expand Up @@ -194,7 +195,7 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
])
->addOption('rules', [
'help' => 'The rector ruleset to run',
'default' => 'cakephp40',
'default' => 'cakephp50',
])
->addOption('autoload', [
'help' => 'The path to the application/plugin autoload if one cannot be auto-detected, ' .
Expand Down
5 changes: 5 additions & 0 deletions src/Rector/Set/CakePHPSetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ final class CakePHPSetList implements SetListInterface
*/
public const CAKEPHP_50 = __DIR__ . '/../../../config/rector/sets/cakephp50.php';

/**
* @var string
*/
public const CAKEPHP_51 = __DIR__ . '/../../../config/rector/sets/cakephp51.php';

/**
* @var string
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Command/RectorCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public function testInvalidAppDir()
public function testApplyAppDir()
{
$this->setupTestApp(__FUNCTION__);
$this->exec('upgrade rector --dry-run ' . TEST_APP);
$this->exec('upgrade rector --rules cakephp40 --dry-run ' . TEST_APP);
debug($this->_out->messages());

$this->assertExitSuccess();
$this->assertOutputContains('HelloCommand.php');
Expand Down

0 comments on commit eab2a43

Please sign in to comment.