Skip to content
Draft
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
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "craftcms/rector",
"description": "Rector sets to automate Craft CMS upgrades",
"require": {
"rector/rector": "^1.0.0"
"rector/rector": "^2.0.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"craftcms/cms": "^4.0.0|^5.0.0",
"phpunit/phpunit": "^12.0",
"craftcms/cms": "^4.0.0|^5.0.0|^6.x-dev",
"craftcms/ecs": "dev-main",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan": "^2.0.0",
"symfony/var-exporter": "^6.0"
},
"autoload": {
Expand All @@ -24,7 +24,8 @@
"scripts": {
"phpstan": "phpstan --ansi --memory-limit=1G",
"check-cs": "ecs check --ansi",
"fix-cs": "ecs check --fix --ansi"
"fix-cs": "ecs check --fix --ansi",
"tests": "phpunit"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
9 changes: 9 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,14 @@
<testsuite name="main">
<directory>tests</directory>
</testsuite>
<testsuite name="craftcms40">
<directory>tests/set/craftcms40</directory>
</testsuite>
<testsuite name="craftcms50">
<directory>tests/set/craftcms50</directory>
</testsuite>
<testsuite name="craftcms60">
<directory>tests/set/craftcms60</directory>
</testsuite>
</testsuites>
</phpunit>
17 changes: 17 additions & 0 deletions sets/craft-cms-60.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use craft\rector\SignatureConfigurator;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\Name\RenameClassRector;

return static function(RectorConfig $rectorConfig): void {
// Class renames
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
'craft\enums\Edition' => 'CraftCms\Cms\Edition',
]);

// Property/method signatures
SignatureConfigurator::configure($rectorConfig, 'craft-cms-60');
};
14 changes: 14 additions & 0 deletions signatures/craft-cms-60.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

return [
// Property types (empty for now, will be filled as needed)
'propertyTypes' => [],

// Method return types (empty for now, will be filled as needed)
'methodReturnTypes' => [],

// Method param types (empty for now, will be filled as needed)
'methodParamTypes' => [],
];
5 changes: 5 additions & 0 deletions src/SetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ final class SetList implements SetListInterface
*/
public const CRAFT_CMS_50 = __DIR__ . '/../sets/craft-cms-50.php';

/**
* @var string
*/
public const CRAFT_CMS_60 = __DIR__ . '/../sets/craft-cms-60.php';

/**
* @var string
*/
Expand Down
30 changes: 30 additions & 0 deletions tests/set/craftcms60/CraftCMS60Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace craft\rector\tests\set\craftcms60;

use craft\rector\SetList;
use Iterator;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class CraftCMS60Test extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(string $filePath): void
{
$this->doTestFile($filePath);
}

public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/fixture');
}

public function provideConfigFilePath(): string
{
return SetList::CRAFT_CMS_60;
}
}
11 changes: 11 additions & 0 deletions tests/set/craftcms60/fixture/plugin.php.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

public \craft\enums\Edition $minCmsEdition = \craft\enums\Edition::Pro;

?>
-----
<?php

public \CraftCms\Cms\Edition $minCmsEdition = CraftCms\Cms\Edition::Pro;

?>
Loading