diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 6070c47..a2af597 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -46,8 +46,7 @@ jobs:
dependency-versions: ${{ matrix.dependency-versions }}
- name: Execute test cases
- run: time composer test
-
+ run: composer test
php-lint:
name: "PHP Lint"
diff --git a/composer.json b/composer.json
index 3316315..c8f1443 100644
--- a/composer.json
+++ b/composer.json
@@ -12,13 +12,15 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.6",
+ "jackalope/jackalope-doctrine-dbal": "^1.7",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.6",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.1",
"phpstan/phpstan-webmozart-assert": "^1.0",
"phpunit/phpunit": "^9.5",
- "rector/rector-src": "dev-main",
+ "rector/rector": "dev-main",
+ "sulu/sulu": "^2.5@dev",
"thecodingmachine/phpstan-strict-rules": "^1.0"
},
"autoload": {
@@ -41,8 +43,15 @@
"scripts": {
"lint": [
"@php-cs",
- "@lint-composer"
+ "@lint-composer",
+ "@lint-rector"
],
+ "fix": [
+ "@php-cs-fix",
+ "@rector"
+ ],
+ "lint-rector": "@php vendor/bin/rector process --dry-run",
+ "rector": "@php vendor/bin/rector process",
"lint-composer": "@composer validate --strict",
"phpstan": "@php vendor/bin/phpstan analyze",
"php-cs": "@php vendor/bin/php-cs-fixer fix --verbose --diff --dry-run",
diff --git a/config/config.php b/config/config.php
index 71e89bd..5b8fd99 100644
--- a/config/config.php
+++ b/config/config.php
@@ -14,7 +14,7 @@
->autowire()
->autoconfigure();
- $services->load('Sulu\\Rector', __DIR__ . '/../src')
+ $services->load('Sulu\\Rector\\', __DIR__ . '/../src')
->exclude([__DIR__ . '/../src/{Rector,ValueObject}']);
$rectorConfig->rule(RenameClassNonPhpRector::class);
diff --git a/config/sets/sulu/sulu-24.php b/config/sets/sulu/sulu-24.php
index d086828..7b6c7f0 100644
--- a/config/sets/sulu/sulu-24.php
+++ b/config/sets/sulu/sulu-24.php
@@ -3,7 +3,27 @@
declare(strict_types=1);
use Rector\Config\RectorConfig;
+use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
+use Rector\Renaming\ValueObject\MethodCallRename;
return static function (RectorConfig $rectorConfig): void {
- // TODO configure upgrades
+ $rectorConfig
+ ->ruleWithConfiguration(RenameMethodRector::class, [
+ // @see https://github.com/sulu/sulu/pull/6071
+ new MethodCallRename(
+ 'Sulu\Component\Localization\Localization',
+ 'setXDefault',
+ 'setDefault',
+ ),
+ new MethodCallRename(
+ 'Sulu\Component\Localization\Localization',
+ 'getXDefault',
+ 'getDefault',
+ ),
+ new MethodCallRename(
+ 'Sulu\Component\Localization\Localization',
+ 'isXDefault',
+ 'isDefault',
+ ),
+ ]);
};
diff --git a/phpstan.neon b/phpstan.neon
index a467c56..f8df184 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -3,7 +3,18 @@ parameters:
- config
- src
- tests
+
level: max
scanDirectories:
- stubs
+
+ bootstrapFiles:
+ - vendor/rector/rector/vendor/scoper-autoload.php
+
+
+ ignoreErrors:
+ # allowed on null-safe calls
+ -
+ message: '#Do not use chained method calls\. Put each on separated lines#'
+ path: config/config.php
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 0000000..a7ae43c
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,22 @@
+
+
+
+
+ tests
+
+
+
+
+
+ src
+ config
+
+
+
diff --git a/rector.php b/rector.php
new file mode 100644
index 0000000..f8c3ff0
--- /dev/null
+++ b/rector.php
@@ -0,0 +1,25 @@
+services();
+ $rectorConfig->importNames();
+ $rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/tests']);
+
+ $rectorConfig->parallel();
+
+ // for testing
+ $rectorConfig->import(__DIR__ . '/config/config.php');
+
+ $rectorConfig->sets([
+ LevelSetList::UP_TO_PHP_81,
+ SetList::CODE_QUALITY,
+ SetList::DEAD_CODE,
+ SetList::NAMING,
+ ]);
+};
diff --git a/tests/Set/Sulu24/Fixture/localization.php.inc b/tests/Set/Sulu24/Fixture/localization.php.inc
new file mode 100644
index 0000000..ab31738
--- /dev/null
+++ b/tests/Set/Sulu24/Fixture/localization.php.inc
@@ -0,0 +1,25 @@
+setXDefault('en');
+ $localization->getXDefault();
+ $localization->isXDefault();
+ }
+}
+
+?>
+---
+setDefault('en');
+ $localization->getDefault();
+ $localization->isDefault();
+ }
+}
+
+?>
diff --git a/tests/Set/Sulu24/Sulu24Test.php b/tests/Set/Sulu24/Sulu24Test.php
new file mode 100644
index 0000000..0a2fb43
--- /dev/null
+++ b/tests/Set/Sulu24/Sulu24Test.php
@@ -0,0 +1,33 @@
+doTestFileInfo($fileInfo);
+ }
+
+ /**
+ * @return Iterator
+ */
+ public function provideData(): Iterator
+ {
+ return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
+ }
+
+ public function provideConfigFilePath(): string
+ {
+ return __DIR__ . '/config/sulu-24.php';
+ }
+}
diff --git a/tests/Set/Sulu24/config/sulu-24.php b/tests/Set/Sulu24/config/sulu-24.php
new file mode 100644
index 0000000..37c10e0
--- /dev/null
+++ b/tests/Set/Sulu24/config/sulu-24.php
@@ -0,0 +1,11 @@
+import(__DIR__ . '/../../../../config/config.php');
+ $rectorConfig->sets([SuluSetList::SULU_24]);
+};