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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Bug #116: Update `LICENSE` and `composer.json` (@terabytesoftw)
- Bug #117: Raise PHPStan level to `5` (@terabytesoftw)
- Bug #118: Add `phpdoc_param_order` rule and update namespace references in `rector.php` (@terabytesoftw)
- Enh #119: Add `php-forge/coding-standard` to development dependencies for code quality checks (@terabytesoftw)

## 0.1.2 June 10, 2024

Expand Down
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
},
"require-dev": {
"maglnet/composer-require-checker": "^4.7",
"php-forge/coding-standard": "^0.1",
"php-forge/support": "^0.3",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-strict-rules": "^2.0.3",
"phpunit/phpunit": "^10.5",
"rector/rector": "^2.2",
"symplify/easy-coding-standard": "^13.0",
"xepozz/internal-mocker": "^1.4"
},
"suggest": {
Expand Down Expand Up @@ -81,11 +80,9 @@
"curl -fsSL -o .editorconfig https://raw.githubusercontent.com/yii2-extensions/template/main/.editorconfig",
"curl -fsSL -o .gitattributes https://raw.githubusercontent.com/yii2-extensions/template/main/.gitattributes",
"curl -fsSL -o .gitignore https://raw.githubusercontent.com/yii2-extensions/template/main/.gitignore",
"curl -fsSL -o ecs.php https://raw.githubusercontent.com/yii2-extensions/template/main/ecs.php",
"curl -fsSL -o infection.json5 https://raw.githubusercontent.com/yii2-extensions/template/main/infection.json5",
"curl -fsSL -o phpstan.neon https://raw.githubusercontent.com/yii2-extensions/template/main/phpstan.neon",
"curl -fsSL -o phpunit.xml.dist https://raw.githubusercontent.com/yii2-extensions/template/main/phpunit.xml.dist",
"curl -fsSL -o rector.php https://raw.githubusercontent.com/yii2-extensions/template/main/rector.php"
"curl -fsSL -o phpunit.xml.dist https://raw.githubusercontent.com/yii2-extensions/template/main/phpunit.xml.dist"
],
"tests": "./vendor/bin/phpunit"
}
Expand Down
98 changes: 8 additions & 90 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,94 +2,12 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\ClassNotation\{ClassDefinitionFixer, OrderedClassElementsFixer, OrderedTraitsFixer};
use PhpCsFixer\Fixer\Import\{NoUnusedImportsFixer, OrderedImportsFixer};
use PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer;
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
/** @var \Symplify\EasyCodingStandard\Configuration\ECSConfigBuilder $ecsConfigBuilder */
$ecsConfigBuilder = require __DIR__ . '/vendor/php-forge/coding-standard/config/ecs.php';

return ECSConfig::configure()
->withConfiguredRule(
ClassDefinitionFixer::class,
[
'space_before_parenthesis' => true,
],
)
->withConfiguredRule(
NullableTypeDeclarationFixer::class,
[
'syntax' => 'union',
],
)
->withConfiguredRule(
OrderedClassElementsFixer::class,
[
'order' => [
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'case',
'property_public',
'property_protected',
'property_private',
'construct',
'destruct',
'magic',
'method_public_abstract',
'method_protected_abstract',
'method_public',
'method_protected',
'method_private',
],
'sort_algorithm' => 'alpha',
],
)
->withConfiguredRule(
OrderedImportsFixer::class,
[
'imports_order' => [
'class',
'function',
'const',
],
'sort_algorithm' => 'alpha',
],
)
->withConfiguredRule(
PhpdocTypesOrderFixer::class,
[
'sort_algorithm' => 'none',
'null_adjustment' => 'always_last',
],
)
->withConfiguredRule(
PhpUnitTestCaseStaticMethodCallsFixer::class,
[
'call_type' => 'self',
],
)
->withFileExtensions(['php'])
->withPaths(
[
__DIR__ . '/src',
__DIR__ . '/tests',
],
)
->withPhpCsFixerSets(perCS30: true)
->withPreparedSets(
cleanCode: true,
comments: true,
docblocks: true,
namespaces: true,
strict: true,
)
->withRules(
[
NoUnusedImportsFixer::class,
OrderedTraitsFixer::class,
SingleQuoteFixer::class,
]
);
return $ecsConfigBuilder->withPaths(
[
__DIR__ . '/src',
__DIR__ . '/tests',
],
);
26 changes: 3 additions & 23 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,15 @@

declare(strict_types=1);

return static function (\Rector\Config\RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
use Rector\Config\RectorConfig;

$rectorConfig->importNames();
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->import(__DIR__ . '/vendor/php-forge/coding-standard/config/rector.php');

$rectorConfig->paths(
[
__DIR__ . '/src',
__DIR__ . '/tests',
],
);

$rectorConfig->sets(
[
\Rector\Set\ValueObject\SetList::PHP_81,
\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81,
\Rector\Set\ValueObject\SetList::TYPE_DECLARATION,
],
);

$rectorConfig->skip(
[
\Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromCreateMockAssignRector::class,
],
);

$rectorConfig->rules(
[
\Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class,
],
);
};
Loading