diff --git a/.gitattributes b/.gitattributes index 5841755..82ef09d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,8 +2,6 @@ spec/ export-ignore .editorconfig export-ignore .gitattributes export-ignore .gitignore export-ignore -.scrutinizer.yml export-ignore -.travis.yml export-ignore CONTRIBUTING.md export-ignore phpspec.yml.ci export-ignore phpspec.yml.dist export-ignore diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f7b8104 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 + - package-ecosystem: composer + directory: / + schedule: + interval: monthly + open-pull-requests-limit: 5 + versioning-strategy: widen diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 32d4001..5881fb2 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -6,9 +6,13 @@ on: pull_request: branches: [ master ] +permissions: + contents: read + jobs: test: strategy: + fail-fast: false matrix: php-versions: [ '8.2', '8.3', '8.4', '8.5' ] @@ -21,22 +25,36 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - coverage: ${{ matrix.coverage }} - - - name: Validate composer.json and composer.lock - run: composer validate --strict + coverage: none + tools: composer:v2 + + - name: Validate Composer metadata + run: | + if [ -f composer.lock ]; then + composer validate --strict --no-interaction + else + composer validate --strict --no-check-lock --no-interaction + fi + + - name: Get Composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" - name: Cache Composer packages - id: composer-cache uses: actions/cache@v4 with: - path: vendor - key: ${{ runner.os }}-composer-${{ matrix.composer-prefer }}$-${{ hashFiles('**/composer.lock') }} + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ matrix.php-versions }}-${{ hashFiles('**/composer.json', '**/composer.lock') }} restore-keys: | - ${{ runner.os }}-composer-${{ matrix.composer-prefer }}- + ${{ runner.os }}-composer-${{ matrix.php-versions }}- - name: Install dependencies - run: composer update --prefer-dist --no-progress --ignore-platform-req="ext-*" ${{ matrix.composer-prefer }} + run: | + if [ -f composer.lock ]; then + composer install --prefer-dist --no-progress --no-interaction + else + composer update --prefer-dist --no-progress --no-interaction + fi - name: Run phpspec - run: vendor/bin/phpspec run --config phpspec.yml.ci + run: vendor/bin/phpspec run --config phpspec.yml.dist diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index acbda73..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,7 +0,0 @@ -checks: - php: - code_rating: true - duplication: true - -tools: - external_code_coverage: true diff --git a/README.md b/README.md index 2bb26af..18ad65f 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,27 @@ # portphp/symfony-console [![Latest Version](https://img.shields.io/github/release/portphp/symfony-console.svg?style=flat-square)](https://github.com/portphp/symfony-console/releases) -[![Build Status](https://travis-ci.org/portphp/symfony-console.svg)](https://travis-ci.org/portphp/symfony-console) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/portphp/symfony-console/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/portphp/symfony-console/?branch=master) -[![Code Coverage](https://scrutinizer-ci.com/g/portphp/symfony-console/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/portphp/symfony-console/?branch=master) +[![CI](https://github.com/portphp/symfony-console/actions/workflows/checks.yml/badge.svg?branch=master)](https://github.com/portphp/symfony-console/actions/workflows/checks.yml) +[![PHP Version](https://img.shields.io/packagist/php-v/portphp/symfony-console.svg?style=flat-square)](https://packagist.org/packages/portphp/symfony-console) + +**Requirements:** PHP ^8.2 (tested on 8.2–8.5). Requires `portphp/portphp` ^2.0 and `symfony/console` ^5.4 || ^6 || ^7 || ^8. Symfony Console tools for PortPHP. ## Installation -Open a command console, enter your project directory and execute the -following command to download the latest stable version of this package: - ```bash $ composer require portphp/symfony-console ``` -This command requires you to have Composer installed globally, as explained -in the [installation chapter](https://getcomposer.org/doc/00-intro.md) -of the Composer documentation. - ## Documentation -Documentation is available at https://docs.portphp.org. +Documentation is available at https://portphp.readthedocs.io. ## Issues and feature requests Please report issues and request features at https://github.com/portphp/portphp/issues. -## Contributing - -Contributions are very welcome. Please see [CONTRIBUTING.md](CONTRIBUTING.md) for -details. Thanks to [everyone who has contributed](https://github.com/portphp/symfony-console/graphs/contributors) -already. - -## Security - -If you discover any security-related issues, please contact us at -security@portphp.org.sec - ## License This package is licensed under the [MIT license](LICENSE). diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md new file mode 100644 index 0000000..1f43a70 --- /dev/null +++ b/UPGRADE-2.0.md @@ -0,0 +1,6 @@ +# Upgrade from 1.x to 2.0 + +- Minimum PHP is **8.2** (`^8.2`). +- Requires `portphp/portphp` **^2.0**. +- Requires `symfony/console` **^5.4 || ^6.0 || ^7.0 || ^8.0**. +- Writer methods use `: void` return types from the core interfaces. diff --git a/composer.json b/composer.json index e43c277..f40a24d 100644 --- a/composer.json +++ b/composer.json @@ -20,12 +20,12 @@ "support": { "issues": "https://github.com/portphp/portphp/issues", "source": "https://github.com/portphp/symfony-console", - "docs": "https://portphp.readthedocs.org" + "docs": "https://portphp.readthedocs.io" }, "require": { - "php": "^5.6 || ^7.0 || ^8.0", - "portphp/portphp": "^1.1", - "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0" + "php": "^8.2", + "portphp/portphp": "^2.0", + "symfony/console": "^5.4 || ^6.0 || ^7.0 || ^8.0" }, "autoload": { "psr-4": { @@ -33,8 +33,7 @@ } }, "require-dev": { - "phpspec/phpspec": "^7.2 || ^8.0", - "friends-of-phpspec/phpspec-code-coverage" : "^6.1 || ^7.0" + "phpspec/phpspec": "^8.0" }, "extra": { "branch-alias": { diff --git a/phpspec.yml.ci b/phpspec.yml.ci index 94caa4c..e086a62 100644 --- a/phpspec.yml.ci +++ b/phpspec.yml.ci @@ -1,10 +1,5 @@ suites: - console_suite: - namespace: Port\SymfonyConsole - psr4_prefix: Port\SymfonyConsole + default: + namespace: Port\SymfonyConsole + psr4_prefix: Port\SymfonyConsole formatter.name: pretty -extensions: - FriendsOfPhpSpec\PhpSpec\CodeCoverage\CodeCoverageExtension: ~ -code_coverage: - format: clover - output: coverage.clover diff --git a/phpspec.yml.dist b/phpspec.yml.dist index 644dd25..e086a62 100644 --- a/phpspec.yml.dist +++ b/phpspec.yml.dist @@ -1,5 +1,5 @@ suites: - console_suite: - namespace: Port\SymfonyConsole - psr4_prefix: Port\SymfonyConsole + default: + namespace: Port\SymfonyConsole + psr4_prefix: Port\SymfonyConsole formatter.name: pretty diff --git a/src/ProgressWriter.php b/src/ProgressWriter.php index 3c3261b..5b12000 100644 --- a/src/ProgressWriter.php +++ b/src/ProgressWriter.php @@ -60,8 +60,7 @@ public function __construct( /** * {@inheritdoc} */ - public function prepare() - { + public function prepare(): void { $this->progress = new ProgressBar($this->output, $this->reader->count()); $this->progress->setFormat($this->verbosity); $this->progress->setRedrawFrequency($this->redrawFrequency); @@ -71,16 +70,14 @@ public function prepare() /** * {@inheritdoc} */ - public function writeItem(array $item) - { + public function writeItem(array $item): void { $this->progress->advance(); } /** * {@inheritdoc} */ - public function finish() - { + public function finish(): void { $this->progress->finish(); } } diff --git a/src/TableWriter.php b/src/TableWriter.php index 5821d4a..c6cf65a 100644 --- a/src/TableWriter.php +++ b/src/TableWriter.php @@ -33,7 +33,7 @@ public function __construct(Table $table) { /** * {@inheritdoc} */ - public function writeItem(array $item) { + public function writeItem(array $item): void { // Save first item to get keys to display at header if (is_null($this->firstItem)) { @@ -46,7 +46,7 @@ public function writeItem(array $item) { /** * {@inheritdoc} */ - public function finish() { + public function finish(): void { $headers = $this->firstItem ? array_keys($this->firstItem) : []; $this->table->setHeaders($headers); $this->table->render();