diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index 92c8559..2477e66 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -2,39 +2,20 @@
declare(strict_types=1);
-use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
+use Yiisoft\CodeStyle\ConfigBuilder;
$finder = (new Finder())->in([
__DIR__ . '/src',
__DIR__ . '/tests',
]);
-return (new Config())
+return ConfigBuilder::build()
->setRiskyAllowed(true)
->setParallelConfig(ParallelConfigFactory::detect())
->setRules([
- '@PER-CS3.0' => true,
- 'no_unused_imports' => true,
- 'no_extra_blank_lines' => [
- 'tokens' => [
- 'curly_brace_block',
- 'extra',
- ],
- ],
- 'ordered_class_elements' => true,
- 'class_attributes_separation' => ['elements' => ['method' => 'one']],
- 'declare_strict_types' => true,
- 'native_function_invocation' => true,
- 'native_constant_invocation' => true,
- 'fully_qualified_strict_types' => [
- 'import_symbols' => true
- ],
- 'global_namespace_import' => [
- 'import_classes' => true,
- 'import_constants' => true,
- 'import_functions' => true,
- ],
+ '@Yiisoft/Core' => true,
+ '@Yiisoft/Core:risky' => true,
])
->setFinder($finder);
diff --git a/README.md b/README.md
index 85db04c..6871f71 100644
--- a/README.md
+++ b/README.md
@@ -2,18 +2,18 @@
-
Yii _____
+ Yii Code Style
-[](https://packagist.org/packages/yiisoft/_____)
-[](https://packagist.org/packages/yiisoft/_____)
-[](https://github.com/yiisoft/_____/actions/workflows/build.yml?query=branch%3Amaster)
-[](https://codecov.io/gh/yiisoft/_____)
-[](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/_____/master)
-[](https://github.com/yiisoft/_____/actions/workflows/static.yml?query=branch%3Amaster)
-[](https://shepherd.dev/github/yiisoft/_____)
-[](https://shepherd.dev/github/yiisoft/_____)
+[](https://packagist.org/packages/yiisoft/code-style)
+[](https://packagist.org/packages/yiisoft/code-style)
+[](https://github.com/yiisoft/code-style/actions/workflows/build.yml?query=branch%3Amaster)
+[](https://codecov.io/gh/yiisoft/code-style)
+[](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/code-style/master)
+[](https://github.com/yiisoft/code-style/actions/workflows/static.yml?query=branch%3Amaster)
+[](https://shepherd.dev/github/yiisoft/code-style)
+[](https://shepherd.dev/github/yiisoft/code-style)
The package ...
@@ -26,7 +26,7 @@ The package ...
The package could be installed with [Composer](https://getcomposer.org):
```shell
-composer require yiisoft/_____
+composer require yiisoft/code-style
```
## General usage
@@ -40,7 +40,7 @@ for that. You may also check out other [Yii Community Resources](https://www.yii
## License
-The Yii _____ is free software. It is released under the terms of the BSD License.
+The Yii Code Style is free software. It is released under the terms of the BSD License.
Please see [`LICENSE`](./LICENSE.md) for more information.
Maintained by [Yii Software](https://www.yiiframework.com/).
diff --git a/composer.json b/composer.json
index 0f3fbaa..bd8b9fc 100644
--- a/composer.json
+++ b/composer.json
@@ -1,15 +1,16 @@
{
- "name": "yiisoft/_____",
+ "name": "yiisoft/code-style",
"type": "library",
- "description": "_____",
+ "description": "Code style tools rulesets collection",
"keywords": [
- "_____"
+ "yii",
+ "code style"
],
"homepage": "https://www.yiiframework.com/",
"license": "BSD-3-Clause",
"support": {
- "issues": "https://github.com/yiisoft/_____/issues?state=open",
- "source": "https://github.com/yiisoft/_____",
+ "issues": "https://github.com/yiisoft/code-style/issues?state=open",
+ "source": "https://github.com/yiisoft/code-style",
"forum": "https://www.yiiframework.com/forum/",
"wiki": "https://www.yiiframework.com/wiki/",
"irc": "ircs://irc.libera.chat:6697/yii",
@@ -28,10 +29,10 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
- "php": "^8.1"
+ "php": "^8.1",
+ "friendsofphp/php-cs-fixer": "^3.92.5"
},
"require-dev": {
- "friendsofphp/php-cs-fixer": "^3.89.1",
"maglnet/composer-require-checker": "^4.7.1",
"phpunit/phpunit": "^10.5.46",
"rector/rector": "^2.0.16",
@@ -41,12 +42,12 @@
},
"autoload": {
"psr-4": {
- "Yiisoft\\_____\\": "src/"
+ "Yiisoft\\CodeStyle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
- "Yiisoft\\_____\\Tests\\": "tests/"
+ "Yiisoft\\CodeStyle\\Tests\\": "tests/"
}
},
"config": {
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index fddc7ad..7f0a8fe 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -19,7 +19,7 @@
-
+
./tests
diff --git a/src/.gitkeep b/src/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/src/ConfigBuilder.php b/src/ConfigBuilder.php
new file mode 100644
index 0000000..7531e43
--- /dev/null
+++ b/src/ConfigBuilder.php
@@ -0,0 +1,23 @@
+registerCustomRuleSets([
+ new YiisoftCoreSet(),
+ new YiisoftCoreRiskySet(),
+ ]);
+
+ return $config;
+ }
+}
diff --git a/src/Sets/YiisoftCoreRiskySet.php b/src/Sets/YiisoftCoreRiskySet.php
new file mode 100644
index 0000000..48abde4
--- /dev/null
+++ b/src/Sets/YiisoftCoreRiskySet.php
@@ -0,0 +1,34 @@
+ true,
+ 'native_function_invocation' => true,
+ 'native_constant_invocation' => true,
+ ];
+ }
+
+ public function getDescription(): string
+ {
+ return 'Rules recommended by ``Yiisoft`` team. Extends ``@PER-CS``';
+ }
+
+ public function isRisky(): bool
+ {
+ return true;
+ }
+}
diff --git a/src/Sets/YiisoftCoreSet.php b/src/Sets/YiisoftCoreSet.php
new file mode 100644
index 0000000..da39d7a
--- /dev/null
+++ b/src/Sets/YiisoftCoreSet.php
@@ -0,0 +1,49 @@
+ true,
+ 'no_unused_imports' => true,
+ 'no_extra_blank_lines' => [
+ 'tokens' => [
+ 'curly_brace_block',
+ 'extra',
+ ],
+ ],
+ 'ordered_class_elements' => true,
+ 'class_attributes_separation' => ['elements' => ['method' => 'one']],
+ 'fully_qualified_strict_types' => [
+ 'import_symbols' => true,
+ ],
+ 'global_namespace_import' => [
+ 'import_classes' => true,
+ 'import_constants' => true,
+ 'import_functions' => true,
+ ],
+ ];
+ }
+
+ public function getDescription(): string
+ {
+ return 'Rules recommended by ``Yiisoft`` team. Extends ``@PER-CS``.';
+ }
+
+ public function isRisky(): bool
+ {
+ return false;
+ }
+}
diff --git a/tests/.gitkeep b/tests/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/ConfigBuilderTest.php b/tests/ConfigBuilderTest.php
new file mode 100644
index 0000000..f1c54a8
--- /dev/null
+++ b/tests/ConfigBuilderTest.php
@@ -0,0 +1,31 @@
+getCustomRuleSets();
+
+ $this->assertCount(2, $customRuleSets);
+
+ $this->assertInstanceOf(YiisoftCoreSet::class, $customRuleSets[0]);
+ $this->assertNotEmpty($customRuleSets[0]->getRules());
+ $this->assertNotEmpty($customRuleSets[0]->getDescription());
+ $this->assertFalse($customRuleSets[0]->isRisky());
+
+ $this->assertInstanceOf(YiisoftCoreRiskySet::class, $customRuleSets[1]);
+ $this->assertNotEmpty($customRuleSets[1]->getRules());
+ $this->assertNotEmpty($customRuleSets[1]->getDescription());
+ $this->assertTrue($customRuleSets[1]->isRisky());
+ }
+}