diff --git a/.github/workflows/ecs.yml b/.github/workflows/ecs.yml new file mode 100644 index 0000000..dff0db6 --- /dev/null +++ b/.github/workflows/ecs.yml @@ -0,0 +1,34 @@ +on: + pull_request: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + - 'infection.json.dist' + - 'phpunit.xml.dist' + + push: + branches: ['main'] + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + - 'infection.json.dist' + - 'phpunit.xml.dist' + +name: ecs + +jobs: + easy-coding-standard: + uses: php-forge/actions/.github/workflows/ecs.yml@main + secrets: + AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }} + with: + os: >- + ['ubuntu-latest'] + php: >- + ['8.1'] diff --git a/.styleci.yml b/.styleci.yml index 5b7ddb2..6f428b6 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -17,9 +17,11 @@ enabled: - combine_nested_dirname - declare_strict_types - dir_constant + - empty_loop_body_braces - fully_qualified_strict_types - function_to_constant - hash_to_slash_comment + - integer_literal_case - is_null - logical_operators - magic_constant_casing @@ -56,7 +58,6 @@ enabled: - phpdoc_order - phpdoc_property - phpdoc_scalar - - phpdoc_separation - phpdoc_singular_inheritdoc - phpdoc_trim - phpdoc_trim_consecutive_blank_line_separation @@ -78,9 +79,9 @@ enabled: - trailing_comma_in_multiline_array - unalign_double_arrow - unalign_equals - - empty_loop_body_braces - - integer_literal_case - union_type_without_spaces disabled: - function_declaration + - psr12_braces + - psr12_class_definition diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..fc62587 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Change Log + +## 0.1.0 February 28, 2024 + +- Initial release diff --git a/LICENSE b/LICENSE index d89684f..136b000 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,16 @@ MIT License -Copyright (c) 2023 yii2-extensions +Copyright (c) 2024 by Wilmer Arámbula (https://github.com/terabytesoftw) All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the +Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index c712bf9..be32bb9 100644 --- a/README.md +++ b/README.md @@ -30,17 +30,17 @@ The preferred way to install this extension is through [composer](https://getcom Either run -``` -composer require --dev --prefer-dist yii2-extensions/asset-popper +```shell +composer require --prefer-dist yii2-extensions/asset-popper:^0.1 ``` or add -``` -"yii2-extensions/asset-popper": "dev-main" +```json +"yii2-extensions/asset-popper": "^0.1" ``` -to the require-dev section of your `composer.json` file. +to the require section of your `composer.json` file. ## Basic usage @@ -79,7 +79,7 @@ PopperCdnAsset::register($this); ## Testing -[Check the documentation testing](/docs/testing.md) to learn about testing. +[Check the documentation testing](docs/testing.md) to learn about testing. ## Our social networks @@ -87,4 +87,4 @@ PopperCdnAsset::register($this); ## License -The MIT License. Please see [License File](LICENSE.md) for more information. +The MIT License. Please see [License File](LICENSE) for more information. diff --git a/changelog.md b/changelog.md deleted file mode 100644 index 9a203e1..0000000 --- a/changelog.md +++ /dev/null @@ -1,2 +0,0 @@ -Change Log -========== diff --git a/composer.json b/composer.json index 1ab29c5..7d94f09 100644 --- a/composer.json +++ b/composer.json @@ -8,20 +8,18 @@ "popper" ], "license": "mit", - "minimum-stability": "dev", - "prefer-stable": true, "require": { "php": ">=8.1", "npm-asset/popperjs--core": "^2.11", - "oomphinc/composer-installers-extender": "^2.0", - "yiisoft/yii2": "*" + "yiisoft/yii2": "^2.0.49 || ^2.2" }, "require-dev": { - "maglnet/composer-require-checker": "^4.6", - "php-forge/support": "dev-main", - "phpunit/phpunit": "^10.2", - "roave/infection-static-analysis-plugin": "^1.32", - "yii2-extensions/phpstan": "dev-main" + "maglnet/composer-require-checker": "^4.7", + "php-forge/support": "^0.1", + "phpunit/phpunit": "^10.5", + "roave/infection-static-analysis-plugin": "^1.34", + "symplify/easy-coding-standard": "^12.1", + "yii2-extensions/phpstan": "^0.1" }, "autoload": { "psr-4": { @@ -35,30 +33,22 @@ }, "extra": { "branch-alias": { - "dev-main": "1.0.x-dev" - }, - "installer-types": [ - "bower-asset", - "npm-asset" - ], - "installer-paths": { - "./node_modules/{$name}": [ - "type:bower-asset", - "type:npm-asset" - ] + "dev-main": "0.1-dev" } }, "config": { "sort-packages": true, "allow-plugins": { + "composer/installers": true, "yiisoft/yii2-composer": true, "infection/extension-installer": true, - "composer/installers": true, - "oomphinc/composer-installers-extender": true + "oomphinc/composer-installers-extender": false } }, "scripts": { + "check-dependencies": "composer-require-checker", + "ecs": "ecs check", "mutation": "roave-infection-static-analysis-plugin", "phpstan": "phpstan", "test": "phpunit" diff --git a/docs/testing.md b/docs/testing.md index 46a4946..6b5902a 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -10,6 +10,23 @@ To run the checker, execute the following command: composer run check-dependencies ``` +## Easy coding standard + +The code is checked with [Easy Coding Standard](https://github.com/easy-coding-standard/easy-coding-standard) and +[PHP CS Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer). To run it: + +```shell +composer run ecs +``` + +## Mutation testing + +Mutation testing is checked with [Infection](https://infection.github.io/). To run it: + +```shell +composer run mutation +``` + ## Static analysis The code is statically analyzed with [Phpstan](https://phpstan.org/). To run static analysis: diff --git a/ecs.php b/ecs.php new file mode 100644 index 0000000..d360125 --- /dev/null +++ b/ecs.php @@ -0,0 +1,39 @@ +withConfiguredRule( + ClassDefinitionFixer::class, + [ + 'space_before_parenthesis' => true, + ], + ) + ->withFileExtensions(['php']) + ->withPaths( + [ + __DIR__ . '/src', + __DIR__ . '/tests', + ], + ) + ->withPhpCsFixerSets(perCS20: true) + ->withPreparedSets( + cleanCode: true, + comments:true, + docblocks: true, + namespaces: true, + psr12: true + ) + ->withRules( + [ + NoUnusedImportsFixer::class, + OrderedClassElementsFixer::class, + OrderedTraitsFixer::class, + ] + ); diff --git a/phpstan-yii-config.php b/phpstan-config.php similarity index 100% rename from phpstan-yii-config.php rename to phpstan-config.php diff --git a/phpstan.neon b/phpstan.neon index 25437e8..9d44298 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -17,5 +17,5 @@ parameters: - vendor/yiisoft/yii2/Yii.php yii2: - config_path: %currentWorkingDirectory%/phpstan-yii-config.php + config_path: %currentWorkingDirectory%/phpstan-config.php diff --git a/src/PopperAsset.php b/src/PopperAsset.php index ce66ecd..f9a3464 100644 --- a/src/PopperAsset.php +++ b/src/PopperAsset.php @@ -11,9 +11,6 @@ */ final class PopperAsset extends AssetBundle { - /** - * @inheritDoc - */ public $sourcePath = '@npm/popperjs--core/dist/umd'; public function init(): void diff --git a/src/PopperCdnAsset.php b/src/PopperCdnAsset.php index fa02f1e..277bcc3 100644 --- a/src/PopperCdnAsset.php +++ b/src/PopperCdnAsset.php @@ -12,8 +12,6 @@ final class PopperCdnAsset extends AssetBundle { /** - * @inheritDoc - * * @phpstan-var array */ public $js = [ @@ -21,8 +19,6 @@ final class PopperCdnAsset extends AssetBundle ]; /** - * @inheritDoc - * * @phpstan-var array */ public $jsOptions = [ diff --git a/tests/Support/main.php b/tests/Support/main.php index eaba028..84f3a0e 100644 --- a/tests/Support/main.php +++ b/tests/Support/main.php @@ -1,4 +1,4 @@ beginPage();?>1head();?>2beginBody();?>3endBody();?>4endPage(); diff --git a/tests/TestCase.php b/tests/TestCase.php index f38d77f..9c83fe3 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -27,8 +27,8 @@ protected function mockWebApplication(): void 'id' => 'testapp', 'aliases' => [ '@app' => dirname(__DIR__), - '@bower' => '@app/node_modules', - '@npm' => '@app/node_modules', + '@bower' => '@vendor/bower-asset', + '@npm' => '@vendor/npm-asset', '@public' => '@app/public', '@vendor' => '@app/vendor', '@web' => __DIR__ . '/Support/runtime',