diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index c84731f8..ceddbcd7 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -68,7 +68,7 @@ to run all the tests. We are using [`infection/infection`](https://github.com/infection/infection) to ensure a minimum quality of the tests. -Enable `Xdebug` and run +Enable `pcov` or `Xdebug` and run ``` $ make mutation-tests diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 3305bbde..fcf8184b 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -23,20 +23,20 @@ jobs: steps: - name: "Checkout" - uses: actions/checkout@v1.1.0 + uses: actions/checkout@v1 - name: "Install PHP with extensions" - uses: shivammathur/setup-php@master + uses: shivammathur/setup-php@v1 with: coverage: none - extension-csv: "mbstring" + extensions: "mbstring" php-version: ${{ matrix.php-version }} - name: "Validate composer.json and composer.lock" - run: $(which composer) validate --strict + run: composer validate --strict - name: "Cache dependencies installed with composer" - uses: actions/cache@v1.0.2 + uses: actions/cache@v1 with: path: ~/.composer/cache key: php${{ matrix.php-version }}-composer-locked-${{ hashFiles('**/composer.lock') }} @@ -44,18 +44,18 @@ jobs: php${{ matrix.php-version }}-composer-locked- - name: "Install locked dependencies with composer" - run: $(which composer) install --no-interaction --no-progress --no-suggest + run: composer install --no-interaction --no-progress --no-suggest - name: "Run localheinz/composer-normalize" - run: $(which composer) normalize --dry-run + run: composer normalize --dry-run - name: "Create cache directory for friendsofphp/php-cs-fixer" run: mkdir -p .build/php-cs-fixer - name: "Cache cache directory for friendsofphp/php-cs-fixer" - uses: actions/cache@v1.0.2 + uses: actions/cache@v1 with: - path: ~/.build/php-cs-fixer + path: .build/php-cs-fixer key: php${{ matrix.php-version }}-php-cs-fixer-${{ hashFiles('**/composer.lock') }} restore-keys: | php${{ matrix.php-version }}-php-cs-fixer- @@ -75,17 +75,17 @@ jobs: steps: - name: "Checkout" - uses: actions/checkout@v1.1.0 + uses: actions/checkout@v1 - name: "Install PHP with extensions" - uses: shivammathur/setup-php@master + uses: shivammathur/setup-php@v1 with: coverage: none - extension-csv: "mbstring" + extensions: "mbstring" php-version: ${{ matrix.php-version }} - name: "Cache dependencies installed with composer" - uses: actions/cache@v1.0.2 + uses: actions/cache@v1 with: path: ~/.composer/cache key: php${{ matrix.php-version }}-composer-locked-${{ hashFiles('**/composer.lock') }} @@ -93,10 +93,10 @@ jobs: php${{ matrix.php-version }}-composer-locked- - name: "Install locked dependencies with composer" - run: $(which composer) install --no-interaction --no-progress --no-suggest + run: composer install --no-interaction --no-progress --no-suggest - name: "Run maglnet/composer-require-checker" - uses: docker://localheinz/composer-require-checker-action:1.1.0 + uses: docker://localheinz/composer-require-checker-action:1.1.1 static-code-analysis: name: "Static Code Analysis" @@ -110,17 +110,17 @@ jobs: steps: - name: "Checkout" - uses: actions/checkout@v1.1.0 + uses: actions/checkout@v1 - name: "Install PHP with extensions" - uses: shivammathur/setup-php@master + uses: shivammathur/setup-php@v1 with: coverage: none - extension-csv: "mbstring" + extensions: "mbstring" php-version: ${{ matrix.php-version }} - name: "Cache dependencies installed with composer" - uses: actions/cache@v1.0.2 + uses: actions/cache@v1 with: path: ~/.composer/cache key: ${{ matrix.php-version }}-composer-locked-${{ hashFiles('**/composer.lock') }} @@ -128,7 +128,7 @@ jobs: ${{ matrix.php-version }}-composer-locked- - name: "Install locked dependencies with composer" - run: $(which composer) install --no-interaction --no-progress --no-suggest + run: composer install --no-interaction --no-progress --no-suggest - name: "Run phpstan/phpstan" run: vendor/bin/phpstan analyse --configuration=phpstan.neon @@ -152,17 +152,17 @@ jobs: steps: - name: "Checkout" - uses: actions/checkout@v1.1.0 + uses: actions/checkout@v1 - name: "Install PHP with extensions" - uses: shivammathur/setup-php@master + uses: shivammathur/setup-php@v1 with: coverage: none - extension-csv: "mbstring" + extensions: "mbstring" php-version: ${{ matrix.php-version }} - name: "Cache dependencies installed with composer" - uses: actions/cache@v1.0.2 + uses: actions/cache@v1 with: path: ~/.composer/cache key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }} @@ -171,15 +171,15 @@ jobs: - name: "Install lowest dependencies with composer" if: matrix.dependencies == 'lowest' - run: $(which composer) update --no-interaction --no-progress --no-suggest --prefer-lowest + run: composer update --no-interaction --no-progress --no-suggest --prefer-lowest - name: "Install locked dependencies with composer" if: matrix.dependencies == 'locked' - run: $(which composer) install --no-interaction --no-progress --no-suggest + run: composer install --no-interaction --no-progress --no-suggest - name: "Install highest dependencies with composer" if: matrix.dependencies == 'highest' - run: $(which composer) update --no-interaction --no-progress --no-suggest + run: composer update --no-interaction --no-progress --no-suggest - name: "Run auto-review tests with phpunit/phpunit" run: vendor/bin/phpunit --configuration=test/AutoReview/phpunit.xml @@ -202,17 +202,17 @@ jobs: steps: - name: "Checkout" - uses: actions/checkout@v1.1.0 + uses: actions/checkout@v1 - name: "Install PHP with extensions" - uses: shivammathur/setup-php@master + uses: shivammathur/setup-php@v1 with: - coverage: xdebug - extension-csv: "mbstring" + coverage: pcov + extensions: "mbstring" php-version: ${{ matrix.php-version }} - name: "Cache dependencies installed with composer" - uses: actions/cache@v1.0.2 + uses: actions/cache@v1 with: path: ~/.composer/cache key: php${{ matrix.php-version }}-composer-locked-${{ hashFiles('**/composer.lock') }} @@ -220,13 +220,10 @@ jobs: php${{ matrix.php-version }}-composer-locked- - name: "Install locked dependencies with composer" - run: $(which composer) install --no-interaction --no-progress --no-suggest + run: composer install --no-interaction --no-progress --no-suggest - - name: "Dump Xdebug filter with phpunit/phpunit" - run: vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --dump-xdebug-filter=.build/phpunit/xdebug-filter.php - - - name: "Collect code coverage with Xdebug and phpunit/phpunit" - run: vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-clover=build/logs/clover.xml --prepend=.build/phpunit/xdebug-filter.php + - name: "Collect code coverage with pcov and phpunit/phpunit" + run: vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-clover=build/logs/clover.xml - name: "Send code coverage report to Codecov.io" env: @@ -245,17 +242,17 @@ jobs: steps: - name: "Checkout" - uses: actions/checkout@v1.1.0 + uses: actions/checkout@v1 - name: "Install PHP with extensions" - uses: shivammathur/setup-php@master + uses: shivammathur/setup-php@v1 with: - coverage: xdebug - extension-csv: "mbstring" + coverage: pcov + extensions: "mbstring" php-version: ${{ matrix.php-version }} - name: "Cache dependencies installed with composer" - uses: actions/cache@v1.0.2 + uses: actions/cache@v1 with: path: ~/.composer/cache key: php${{ matrix.php-version }}-composer-locked-${{ hashFiles('**/composer.lock') }} @@ -263,7 +260,7 @@ jobs: php${{ matrix.php-version }}-composer-locked- - name: "Install locked dependencies with composer" - run: $(which composer) install --no-interaction --no-progress --no-suggest + run: composer install --no-interaction --no-progress --no-suggest - - name: "Run mutation tests with infection/infection" + - name: "Run mutation tests with pcov and infection/infection" run: vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=100 --min-msi=100 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0982fe1a..e69de29b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,32 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## Unreleased - -For a full diff see [`1.1.0...master`][1.1.0...master]. - -## [`1.1.0`][1.1.0] - -For a full diff see [`1.0.0...1.1.0`][1.0.0...1.1.0]. - -### Added - -* Added `Ergebnis\PhpCsFixer\Config\RuleSet\Laravel6`, a rule set for Laravel 6 ([#3]), by [@linuxjuggler] - -## [`1.0.0`][1.0.0] - -For a full diff see [`d899e77...1.0.0`][d899e77...1.0.0]. - -[1.0.0]: https://github.com/ergebnis/php-cs-fixer-config/releases/tag/1.0.0 -[1.1.0]: https://github.com/ergebnis/php-cs-fixer-config/releases/tag/1.2.0 - -[d899e77...1.0.0]: https://github.com/ergebnis/php-cs-fixer-config/compare/d899e77...1.0.0 -[1.0.0...1.1.0]: https://github.com/ergebnis/php-cs-fixer-config/compare/1.0.0...1.1.0 -[1.1.0...master]: https://github.com/ergebnis/php-cs-fixer-config/compare/1.1.0...master - -[#3]: https://github.com/ergebnis/php-cs-fixer-config/pull/3 - -[@linuxjuggler]: https://github.com/linuxjuggler diff --git a/Makefile b/Makefile index 21fbad8b..9c72933b 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,7 @@ it: coding-standards dependency-analysis static-code-analysis tests ## Runs the .PHONY: code-coverage code-coverage: vendor ## Collects coverage from running unit tests with phpunit/phpunit - mkdir -p .build/phpunit - vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --dump-xdebug-filter=.build/phpunit/xdebug-filter.php - vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-text --prepend=.build/phpunit/xdebug-filter.php + vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-text .PHONY: coding-standards coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fixer @@ -14,7 +12,7 @@ coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fix .PHONY: dependency-analysis dependency-analysis: vendor ## Runs a dependency analysis with maglnet/composer-require-checker - docker run --interactive --rm --tty --workdir=/app --volume ${PWD}:/app localheinz/composer-require-checker-action:1.1.0 + docker run --interactive --rm --tty --workdir=/app --volume ${PWD}:/app localheinz/composer-require-checker-action:1.1.1 .PHONY: help help: ## Displays this list of targets with descriptions diff --git a/README.md b/README.md index 2faf7b1c..e69de29b 100644 --- a/README.md +++ b/README.md @@ -1,275 +0,0 @@ -# php-cs-fixer-config - -[![Continuous Integration](https://github.com/ergebnis/php-cs-fixer-config/workflows/Continuous%20Integration/badge.svg)](https://github.com/ergebnis/php-cs-fixer-config/actions) -[![Code Coverage](https://codecov.io/gh/ergebnis/php-cs-fixer-config/branch/master/graph/badge.svg)](https://codecov.io/gh/ergebnis/php-cs-fixer-config) -[![Latest Stable Version](https://poser.pugx.org/ergebnis/php-cs-fixer-config/v/stable)](https://packagist.org/packages/ergebnis/php-cs-fixer-config) -[![Total Downloads](https://poser.pugx.org/ergebnis/php-cs-fixer-config/downloads)](https://packagist.org/packages/ergebnis/php-cs-fixer-config) - -Provides a configuration factory and multiple rule sets for [`friendsofphp/php-cs-fixer`](http://github.com/FriendsOfPHP/PHP-CS-Fixer). - -## Installation - -Run - -```sh -$ composer require --dev ergebnis/php-cs-fixer-config -``` - -## Usage - -### Configuration - -Pick one of the rule sets: - -* [`Ergebnis\PhpCsFixer\RuleSet\Laravel6`](src/RuleSet/Laravel6.php) -* [`Ergebnis\PhpCsFixer\RuleSet\Php71`](src/RuleSet/Php71.php) -* [`Ergebnis\PhpCsFixer\RuleSet\Php73`](src/RuleSet/Php73.php) - -Create a configuration file `.php_cs` in the root of your project: - -```php -getFinder()->in(__DIR__); -$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/php_cs.cache'); - -return $config; -``` - -### Git - -All configuration examples use the caching feature, and if you want to use it as well, you should add the cache directory to `.gitignore`: - -```diff -+ /.build/ - /vendor/ -``` - -:bulb: Personally, I prefer to use a `.build` directory for storing build artifacts. - -### Configuration with header - -:bulb: Optionally specify a header: - -```diff - getFinder()->in(__DIR__); - $config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/php_cs.cache'); - - return $config; -``` - -This will enable and configure the [`HeaderCommentFixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.1.1/src/Fixer/Comment/HeaderCommentFixer.php), so that -file headers will be added to PHP files, for example: - -```php - false, -+ 'strict_comparison' => false, -+]); - - $config->getFinder()->in(__DIR__); - $config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/php_cs.cache'); - - return $config; -``` - -### Makefile - -If you like [`Makefile`](https://www.gnu.org/software/make/manual/make.html#Introduction)s, create a `Makefile` with a `coding-standards` target: - -```diff -+.PHONY: coding-standards -+coding-standards: vendor -+ mkdir -p .build/php-cs-fixer -+ vendor/bin/php-cs-fixer fix --config=.php_cs --diff --verbose - - vendor: composer.json composer.lock - composer validate - composer install -``` - -Run - -``` -$ make coding-standards -``` - -to automatically fix coding standard violations. - -### Composer script - -If you like [`composer` scripts](https://getcomposer.org/doc/articles/scripts.md), add a `coding-standards` script to `composer.json`: - -```diff - { - "name": "foo/bar", - "require": { - "php": "^7.2", - }, - "require-dev": { - "ergebnis/php-cs-fixer-config": "~1.0.0" -+ }, -+ "scripts": { -+ "coding-standards": [ -+ "mkdir -p .build/php-cs-fixer", -+ "php-cs-fixer fix --diff --diff-format=udiff --verbose" -+ ] - } - } -``` - -Run - -``` -$ composer coding-standards -``` - -to automatically fix coding standard violations. - -### GitHub Actions - -If you like [GitHub Actions](https://github.com/features/actions), add a `coding-standards` job to your workflow: - -```diff - on: - pull_request: - push: - branches: - - master - tags: - - "**" - - name: "Continuous Integration" - - jobs: -+ coding-standards: -+ name: "Coding Standards" -+ -+ runs-on: ubuntu-latest -+ -+ steps: -+ - name: "Checkout" -+ uses: actions/checkout@v1.1.0 -+ -+ - name: "Disable Xdebug" -+ run: php7.2 --ini | grep xdebug | sed 's/,$//' | xargs sudo rm -+ -+ - name: "Cache dependencies installed with composer" -+ uses: actions/cache@v1.0.2 -+ with: -+ path: ~/.composer/cache -+ key: php7.2-composer-locked-${{ hashFiles('**/composer.lock') }} -+ restore-keys: | -+ php7.2-composer-locked- -+ -+ - name: "Install locked dependencies with composer" -+ run: php7.2 $(which composer) install --no-interaction --no-progress --no-suggest -+ -+ - name: "Create cache directory for friendsofphp/php-cs-fixer" -+ run: mkdir -p .build/php-cs-fixer -+ -+ - name: "Cache cache directory for friendsofphp/php-cs-fixer" -+ uses: actions/cache@v1.0.2 -+ with: -+ path: ~/.build/php-cs-fixer -+ key: php7.2-php-cs-fixer-${{ hashFiles('**/composer.lock') }} -+ restore-keys: | -+ php7.2-php-cs-fixer- -+ -+ - name: "Run friendsofphp/php-cs-fixer" -+ run: php7.2 vendor/bin/php-cs-fixer fix --config=.php_cs --diff --diff-format=udiff --dry-run --verbose -``` - -### Travis - -If you like [Travis CI](https://travis-ci.com), add a `coding-standards` stage to your jobs: - -```diff - language: php - - cache: - directories: - - $HOME/.composer/cache -+ - .build/php-cs-fixer - - jobs: - include: -+ - stage: "Coding Standards" -+ -+ php: 7.2 -+ -+ install: -+ - composer install --no-interaction --no-progress --no-suggest -+ -+ before_script: -+ - mkdir -p .build/php-cs-fixer -+ -+ script: -+ - vendor/bin/php-cs-fixer fix --config=.php_cs --diff --dry-run --verbose -``` - -## Changelog - -Please have a look at [`CHANGELOG.md`](CHANGELOG.md). - -## Contributing - -Please have a look at [`CONTRIBUTING.md`](.github/CONTRIBUTING.md). - -:bulb: Do you want to add a rule for personal use or use in your organization? Instead of opening a pull request here, perhaps consider creating a new package based on [`ergebnis/php-cs-fixer-config-template`](https://github.com/ergebnis/php-cs-fixer-config-template), a GitHub repository template that provides a good starting point for creating and sharing your own rule sets. - -## Code of Conduct - -Please have a look at [`CODE_OF_CONDUCT.md`](.github/CODE_OF_CONDUCT.md). - -## License - -This package is licensed using the MIT License. - -## Credits - -This project is inspired by and also replaces [`localheinz/php-cs-fixer-config`](https://github.com/localheinz/php-cs-fixer-config). - -The rule set [`Ergebnis\PhpCsFixer\RuleSet\Laravel6`](src/RuleSet/Laravel6.php) is based on [`laravel-shift/.php_cs.laravel.php`](https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200). diff --git a/composer.json b/composer.json index 7bfb58b0..dcbebc3a 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "jangregor/phpstan-prophecy": "~0.4.2", "localheinz/composer-normalize": "^1.3.1", "localheinz/phpstan-rules": "~0.13.0", + "phpstan/extension-installer": "^1.0.3", "phpstan/phpstan": "~0.11.19", "phpstan/phpstan-deprecation-rules": "~0.11.2", "phpstan/phpstan-strict-rules": "~0.11.1", diff --git a/composer.lock b/composer.lock index 8d1315c5..7cc6512c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "36785227cbda4c51ba156d5f33966b70", + "content-hash": "0e17dc53a6091741c193b9805e5b0397", "packages": [ { "name": "composer/semver", @@ -3129,6 +3129,50 @@ ], "time": "2019-10-03T11:07:50+00:00" }, + { + "name": "phpstan/extension-installer", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "295656793c53b5eb73a38486032ad1bd650264bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/295656793c53b5eb73a38486032ad1bd650264bc", + "reference": "295656793c53b5eb73a38486032ad1bd650264bc", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1", + "php": "^7.1", + "phpstan/phpstan": ">=0.11.6" + }, + "require-dev": { + "composer/composer": "^1.8", + "consistence/coding-standard": "^3.8", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "jakub-onderka/php-parallel-lint": "^1.0", + "phing/phing": "^2.16", + "phpstan/phpstan-strict-rules": "^0.11", + "slevomat/coding-standard": "^5.0.4" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "time": "2019-10-18T17:09:48+00:00" + }, { "name": "phpstan/phpdoc-parser", "version": "0.3.5", diff --git a/phpstan.neon b/phpstan.neon index d9baa936..c092e951 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,17 +1,12 @@ includes: - phpstan-baseline.neon - - vendor/jangregor/phpstan-prophecy/src/extension.neon - - vendor/localheinz/phpstan-rules/rules.neon - - vendor/phpstan/phpstan-deprecation-rules/rules.neon - - vendor/phpstan/phpstan-strict-rules/rules.neon - - vendor/phpstan/phpstan/conf/bleedingEdge.neon - - vendor/phpstan/phpstan/conf/config.levelmax.neon parameters: classesAllowedToBeExtended: - Ergebnis\PhpCsFixer\Config\RuleSet\AbstractRuleSet - Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet\AbstractRuleSetTestCase inferPrivatePropertyTypeFromConstructor: true + level: max paths: - src - test