diff --git a/.gitattributes b/.gitattributes index f19490b..cabf750 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,10 +7,10 @@ .editorconfig export-ignore .gitattributes export-ignore .gitignore export-ignore -.travis.yml export-ignore -phpstan.neon export-ignore -rector.yaml export-ignore -phpunit.xml export-ignore +peck.json export-ignore +phpstan.neon.dist export-ignore +phpunit.xml.dist export-ignore +rector.php export-ignore CHANGELOG.md export-ignore CONTRIBUTING.md export-ignore README.md export-ignore diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index d03cb24..0f791b1 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -2,4 +2,4 @@ github: nunomaduro patreon: nunomaduro -custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L +custom: https://www.paypal.com/paypalme/enunomaduro diff --git a/.github/workflows/formats.yml b/.github/workflows/formats.yml index bbdd577..ceef196 100644 --- a/.github/workflows/formats.yml +++ b/.github/workflows/formats.yml @@ -10,7 +10,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [7.4] + php: [8.4] dependency-version: [prefer-lowest, prefer-stable] name: Formats P${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} @@ -18,29 +18,32 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 - - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: ~/.composer/cache/files - key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} extensions: dom, mbstring, zip - tools: prestissimo coverage: pcov + - name: Get Composer cache directory + id: composer-cache + shell: bash + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: dependencies-php-${{ matrix.php }}-os-${{ matrix.os }}-version-${{ matrix.dependency-version }}-composer-${{ hashFiles('composer.json') }} + restore-keys: dependencies-php-${{ matrix.php }}-os-${{ matrix.os }}-version-${{ matrix.dependency-version }}-composer- + - name: Install Composer dependencies run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist - name: Coding Style Checks - run: | - vendor/bin/rector process src --dry-run - vendor/bin/php-cs-fixer fix -v --dry-run + run: composer test:lint - name: Type Checks - run: vendor/bin/phpstan analyse --ansi + run: composer test:types diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ef25a1f..e582bdd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, macos-latest, windows-latest] - php: [7.3, 7.4] + php: [8.4] dependency-version: [prefer-lowest, prefer-stable] name: Tests P${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} @@ -17,13 +17,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 - - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: ~/.composer/cache/files - key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -32,6 +26,18 @@ jobs: extensions: dom, mbstring, zip coverage: none + - name: Get Composer cache directory + id: composer-cache + shell: bash + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: dependencies-php-${{ matrix.php }}-os-${{ matrix.os }}-version-${{ matrix.dependency-version }}-composer-${{ hashFiles('composer.json') }} + restore-keys: dependencies-php-${{ matrix.php }}-os-${{ matrix.os }}-version-${{ matrix.dependency-version }}-composer- + - name: Install Composer dependencies run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist diff --git a/.gitignore b/.gitignore index 8c2406a..58e0c87 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ -.idea/* -.idea/codeStyleSettings.xml -composer.lock +/.phpunit.result.cache +/.phpunit.cache +/.php-cs-fixer.cache +/.php-cs-fixer.php +/composer.lock +/phpunit.xml /vendor/ -coverage.xml -.phpunit.result.cache -.php_cs.cache +/.idea/ *.swp *.swo diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 4277bb1..0000000 --- a/.php_cs +++ /dev/null @@ -1,28 +0,0 @@ -in(__DIR__ . DIRECTORY_SEPARATOR . 'tests') - ->in(__DIR__ . DIRECTORY_SEPARATOR . 'src') - ->append(['.php_cs']); - -$rules = [ - '@Symfony' => true, - 'phpdoc_no_empty_return' => false, - 'array_syntax' => ['syntax' => 'short'], - 'yoda_style' => false, - 'binary_operator_spaces' => [ - 'operators' => [ - '=>' => 'align', - '=' => 'align', - ], - ], - 'concat_space' => ['spacing' => 'one'], - 'not_operator_with_space' => false, -]; - -$rules['increment_style'] = ['style' => 'post']; - -return PhpCsFixer\Config::create() - ->setUsingCache(true) - ->setRules($rules) - ->setFinder($finder); diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5211b17..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: php - -sudo: false - -php: - - 7.2 - - 7.3 - - nightly - -env: - matrix: - - COMPOSER_FLAGS="--prefer-lowest" - - COMPOSER_FLAGS="" - -before_script: - - travis_retry composer self-update - - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source - -script: - - composer test diff --git a/README.md b/README.md index 55236dc..dad8d64 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Skeleton Php

- GitHub Workflow Status (master) + GitHub Workflow Status (master) Total Downloads Latest Version License @@ -11,19 +11,24 @@ ------ This package provides a wonderful **PHP Skeleton** to start building your next package idea. -> **Requires [PHP 7.3.0+](https://php.net/releases/)** +> **Requires [PHP 8.4+](https://php.net/releases/)** ⚡️ Create your package using [Composer](https://getcomposer.org): ```bash -composer create-project nunomaduro/skeleton-php --prefer-source PackageName +composer create-project nunomaduro/skeleton-php --prefer-dist PackageName ``` -🧹 Keep a modern codebase with **PHP CS Fixer** & **Rector**: +🧹 Keep a modern codebase with **Pint**: ```bash composer lint ``` +✅ Run refactors using **Rector** +```bash +composer refactor +``` + ⚗️ Run static analysis using **PHPStan**: ```bash composer test:types @@ -39,4 +44,4 @@ composer test:unit composer test ``` -**Skeleton PHP** was created by **[Nuno Maduro](https://twitter.com/enunomaduro)** under the **[MIT license](https://opensource.org/licenses/MIT)**. +**Skeleton PHP** was created by **[Nuno Maduro](https://x.com/enunomaduro)** under the **[MIT license](https://opensource.org/licenses/MIT)**. diff --git a/composer.json b/composer.json index 498766f..ce0636f 100644 --- a/composer.json +++ b/composer.json @@ -10,17 +10,16 @@ } ], "require": { - "php": "^7.3" + "php": "^8.4.0" }, "require-dev": { - "pestphp/pest": "^0.2.2", - "friendsofphp/php-cs-fixer": "^2.16.3", - "ergebnis/phpstan-rules": "^0.15.0", - "phpstan/phpstan": "^0.12.31", - "phpstan/phpstan-strict-rules": "^0.12.2", - "symfony/var-dumper": "^5.1.2", - "rector/rector": "^0.7.37", - "thecodingmachine/phpstan-strict-rules": "^0.12.0" + "laravel/pint": "^1.24.0", + "peckphp/peck": "^0.1.3", + "pestphp/pest": "^4.1.0", + "pestphp/pest-plugin-type-coverage": "^4.0.2", + "phpstan/phpstan": "^2.1.26", + "rector/rector": "^2.1.7", + "symfony/var-dumper": "^7.3.3" }, "autoload": { "psr-4": { @@ -36,17 +35,27 @@ "prefer-stable": true, "config": { "sort-packages": true, - "preferred-install": "dist" + "preferred-install": "dist", + "allow-plugins": { + "pestphp/pest-plugin": true + } }, "scripts": { - "lint": "rector process src && php-cs-fixer fix -v", - "test:lint": "php-cs-fixer fix -v --dry-run && rector process src --dry-run", - "test:types": "phpstan analyse --ansi --memory-limit=0", - "test:unit": "pest --colors=always", + "lint": "pint", + "refactor": "rector", + "test:type-coverage": "pest --type-coverage --exactly=100", + "test:typos": "peck", + "test:lint": "pint --test", + "test:unit": "pest --coverage --exactly=100", + "test:types": "phpstan", + "test:refactor": "rector --dry-run", "test": [ "@test:lint", + "@test:type-coverage", + "@test:typos", + "@test:unit", "@test:types", - "@test:unit" + "@test:refactor" ] } } diff --git a/peck.json b/peck.json new file mode 100644 index 0000000..94b4e71 --- /dev/null +++ b/peck.json @@ -0,0 +1,8 @@ +{ + "preset": "base", + "ignore": { + "words": [ + "php" + ] + } +} diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 92a52bf..5fd25fc 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,13 +1,6 @@ -includes: - - vendor/phpstan/phpstan-strict-rules/rules.neon - - vendor/ergebnis/phpstan-rules/rules.neon - - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - parameters: level: max paths: - src - checkMissingIterableValueType: true - checkGenericClassInNonGenericObjectType: false reportUnmatchedIgnoredErrors: true diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 368f6bd..35ce165 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,16 +1,16 @@ + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" + colors="true" + cacheDirectory=".phpunit.cache"> + + + ./src + + ./tests - - - ./src - - diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..0c54648 --- /dev/null +++ b/rector.php @@ -0,0 +1,24 @@ +withPaths([ + __DIR__.'/src', + __DIR__.'/tests', + ]) + ->withSkip([ + AddOverrideAttributeToOverriddenMethodsRector::class, + ]) + ->withPreparedSets( + deadCode: true, + codeQuality: true, + typeDeclarations: true, + privatization: true, + earlyReturn: true, + strictBooleans: true, + ) + ->withPhpSets(); diff --git a/rector.yaml b/rector.yaml deleted file mode 100644 index 90dd811..0000000 --- a/rector.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# rector.yaml -parameters: - sets: - - 'action-injection-to-constructor-injection' - - 'array-str-functions-to-static-call' - - 'celebrity' - - 'doctrine' - - 'phpstan' - - 'phpunit-code-quality' - - 'solid' - - 'early-return' - - 'doctrine-code-quality' - - 'code-quality' - - 'php71' - - 'php72' - - 'php73' diff --git a/tests/Feature.php b/tests/Feature.php new file mode 100644 index 0000000..cfc83bb --- /dev/null +++ b/tests/Feature.php @@ -0,0 +1,11 @@ +foo(); + + expect($result)->toBe('bar'); +}); diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php deleted file mode 100644 index 59f7d2a..0000000 --- a/tests/Feature/ExampleTest.php +++ /dev/null @@ -1,7 +0,0 @@ -