From 11653d59dc0bedaf617226dd0434f5cd61289f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Fr=C3=B6mer?= Date: Sun, 16 Mar 2025 18:59:34 +0100 Subject: [PATCH 01/10] chore: Remove composer plugin link from readme --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index d57bf9fb..f40f7f25 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,6 @@ Created by [Andreas Frömer](https://twitter.com/icanhazstring) and [contributor [![](https://img.shields.io/github/actions/workflow/status/composer-unused/composer-unused/validate-phar.yml?branch=main&label=build-phar&style=flat-square)](https://github.com/composer-unused/composer-unused) [![](https://img.shields.io/github/tag-date/composer-unused/composer-unused.svg?label=version&style=flat-square)](https://github.com/composer-unused/composer-unused/releases/latest) -> ⚠️ If you want to use this tool as composer-plugin head over to [composer-unused-plugin](https://github.com/composer-unused/composer-unused-plugin). - ## Motivation When working in a big repository, you sometimes lose track of your required Composer From e0f6cb63e11ac0f99b4f517c82f70ca3c94aee17 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 02:29:40 +0000 Subject: [PATCH 02/10] github-actions(deps): bump shivammathur/setup-php Bumps the dependencies group with 1 update: [shivammathur/setup-php](https://github.com/shivammathur/setup-php). Updates `shivammathur/setup-php` from 2.30.0 to 2.32.0 - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.30.0...2.32.0) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dependencies ... Signed-off-by: dependabot[bot] --- .github/workflows/release-phar.yml | 2 +- .github/workflows/validate-code.yml | 6 +++--- .github/workflows/validate-phar.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-phar.yml b/.github/workflows/release-phar.yml index e01d6a66..0e28df23 100644 --- a/.github/workflows/release-phar.yml +++ b/.github/workflows/release-phar.yml @@ -31,7 +31,7 @@ jobs: uses: "actions/checkout@v4" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@2.30.0" + uses: "shivammathur/setup-php@2.32.0" with: coverage: "none" tools: "composer:v2" diff --git a/.github/workflows/validate-code.yml b/.github/workflows/validate-code.yml index 89c0d269..875afb72 100644 --- a/.github/workflows/validate-code.yml +++ b/.github/workflows/validate-code.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v4 - name: Setup PHP - uses: shivammathur/setup-php@2.30.0 + uses: shivammathur/setup-php@2.32.0 with: php-version: ${{ matrix.php }} tools: composer:v2 @@ -45,7 +45,7 @@ jobs: uses: actions/checkout@v4 - name: Setup PHP - uses: shivammathur/setup-php@2.30.0 + uses: shivammathur/setup-php@2.32.0 with: php-version: ${{ matrix.php }} tools: composer:v2 @@ -116,7 +116,7 @@ jobs: uses: actions/checkout@v4 - name: Setup PHP - uses: shivammathur/setup-php@2.30.0 + uses: shivammathur/setup-php@2.32.0 with: php-version: ${{ matrix.php }} tools: composer:v2 diff --git a/.github/workflows/validate-phar.yml b/.github/workflows/validate-phar.yml index fca77cd4..88587167 100644 --- a/.github/workflows/validate-phar.yml +++ b/.github/workflows/validate-phar.yml @@ -33,7 +33,7 @@ jobs: uses: "actions/checkout@v4" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@2.30.0" + uses: "shivammathur/setup-php@2.32.0" with: coverage: "none" tools: "composer:v2" From 8111caeceeb9dd019004723ed2a4db9284cbf735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Fr=C3=B6mer?= Date: Mon, 17 Mar 2025 15:41:26 +0100 Subject: [PATCH 03/10] chore: Require new symbol-parser version --- composer.json | 2 +- composer.lock | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 94ca7e7f..1f1bfb3b 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "ext-json": "*", "composer-runtime-api": "^2.0", "composer-unused/contracts": "^0.3", - "composer-unused/symbol-parser": "^0.2.7", + "composer-unused/symbol-parser": "^0.3.0", "nikic/php-parser": "^5.0", "ondram/ci-detector": "^4.1", "phpstan/phpdoc-parser": "^1.25 || ^2", diff --git a/composer.lock b/composer.lock index c74f2bfc..8701ae6a 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": "0de3864111ead72ff1a54595961da898", + "content-hash": "1be3be3f05d0711fbd1cfa42459eef41", "packages": [ { "name": "composer-unused/contracts", @@ -54,21 +54,21 @@ }, { "name": "composer-unused/symbol-parser", - "version": "0.2.7", + "version": "0.3.0", "source": { "type": "git", "url": "https://github.com/composer-unused/symbol-parser.git", - "reference": "66dda4bef0a49d928d34744674f204a2530e4500" + "reference": "7c4d9d44abd0315146c3476d6e4d57ef7e0bfcd5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer-unused/symbol-parser/zipball/66dda4bef0a49d928d34744674f204a2530e4500", - "reference": "66dda4bef0a49d928d34744674f204a2530e4500", + "url": "https://api.github.com/repos/composer-unused/symbol-parser/zipball/7c4d9d44abd0315146c3476d6e4d57ef7e0bfcd5", + "reference": "7c4d9d44abd0315146c3476d6e4d57ef7e0bfcd5", "shasum": "" }, "require": { "composer-unused/contracts": "^0.3", - "nikic/php-parser": "^4.18 || ^5.0", + "nikic/php-parser": "^5.0", "php": "^7.4 || ^8.0", "phpstan/phpdoc-parser": "^1.25 || ^2", "psr/container": "^1.0 || ^2.0", @@ -121,7 +121,7 @@ "type": "other" } ], - "time": "2025-03-16T12:14:35+00:00" + "time": "2025-03-17T14:39:15+00:00" }, { "name": "nikic/php-parser", @@ -4016,12 +4016,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "9e474e1c4987ea63445e2eaefed17e4a87acf2df" + "reference": "1fd2478f5f196be425357f9797048c94ec704135" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/9e474e1c4987ea63445e2eaefed17e4a87acf2df", - "reference": "9e474e1c4987ea63445e2eaefed17e4a87acf2df", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/1fd2478f5f196be425357f9797048c94ec704135", + "reference": "1fd2478f5f196be425357f9797048c94ec704135", "shasum": "" }, "conflict": { @@ -4250,7 +4250,7 @@ "funadmin/funadmin": "<=5.0.2", "gaoming13/wechat-php-sdk": "<=1.10.2", "genix/cms": "<=1.1.11", - "getformwork/formwork": "<=2.0.0.0-beta3", + "getformwork/formwork": "<1.13.1|>=2.0.0.0-beta1,<2.0.0.0-beta4", "getgrav/grav": "<1.7.46", "getkirby/cms": "<=3.6.6.5|>=3.7,<=3.7.5.4|>=3.8,<=3.8.4.3|>=3.9,<=3.9.8.1|>=3.10,<=3.10.1|>=4,<=4.3", "getkirby/kirby": "<=2.5.12", @@ -4885,7 +4885,7 @@ "type": "tidelift" } ], - "time": "2025-03-14T19:04:21+00:00" + "time": "2025-03-16T18:05:49+00:00" }, { "name": "sebastian/cli-parser", From 73ecbd4b5e3fdb50c7f20e4f9b0a5fad7967353b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Fr=C3=B6mer?= Date: Tue, 18 Mar 2025 07:37:18 +0100 Subject: [PATCH 04/10] chore: Add gpg key to phive installation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f40f7f25..2861c8b0 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ How do we check whether the provided *symbols* of a package are used in our code ### PHAR (PHP Archive) (recommended) Install via `phive` or grab the latest `composer-unused.phar` from the latest release: - phive install composer-unused + phive install composer-unused --trust-gpg-keys DB82D6DEA49B570163338FA33135AA4CB4F1AB0B curl -OL https://github.com/composer-unused/composer-unused/releases/latest/download/composer-unused.phar ### Local From 3a80f8f6a8fb318a0bfcd015cdd049bd17e2fbd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Fr=C3=B6mer?= Date: Tue, 18 Mar 2025 08:04:03 +0100 Subject: [PATCH 05/10] chore: Cleanup unused classes and tidy progress class --- src/Console/Command/UnusedCommand.php | 5 ----- src/Console/Progress/DefaultProgressBarDecorator.php | 12 ++++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Console/Command/UnusedCommand.php b/src/Console/Command/UnusedCommand.php index a0332e99..6c56121c 100644 --- a/src/Console/Command/UnusedCommand.php +++ b/src/Console/Command/UnusedCommand.php @@ -13,15 +13,12 @@ use ComposerUnused\ComposerUnused\Composer\LocalPackageInstalledPath; use ComposerUnused\ComposerUnused\Composer\LocalRepositoryFactory; use ComposerUnused\ComposerUnused\Composer\PackageFactory; -use ComposerUnused\ComposerUnused\Configuration\Configuration; use ComposerUnused\ComposerUnused\Configuration\ConfigurationProvider; use ComposerUnused\ComposerUnused\Configuration\NamedFilter; use ComposerUnused\ComposerUnused\Console\Progress\DefaultProgressBarDecorator; use ComposerUnused\ComposerUnused\Dependency\DependencyInterface; use ComposerUnused\ComposerUnused\Dependency\RequiredDependency; use ComposerUnused\ComposerUnused\Filter\FilterCollection; -use ComposerUnused\ComposerUnused\Output\FileOutput; -use ComposerUnused\ComposerUnused\Output\OutputStyleOutput; use ComposerUnused\ComposerUnused\OutputFormatter\FormatterFactory; use InvalidArgumentException; use Symfony\Component\Console\Command\Command; @@ -42,8 +39,6 @@ final class UnusedCommand extends Command { - public const VERSION = '0.8.7'; - private CollectConsumedSymbolsCommandHandler $collectConsumedSymbolsCommandHandler; private CollectRequiredDependenciesCommandHandler $collectRequiredDependenciesCommandHandler; private ConfigFactory $configFactory; diff --git a/src/Console/Progress/DefaultProgressBarDecorator.php b/src/Console/Progress/DefaultProgressBarDecorator.php index 32e381a6..9e288de9 100644 --- a/src/Console/Progress/DefaultProgressBarDecorator.php +++ b/src/Console/Progress/DefaultProgressBarDecorator.php @@ -16,40 +16,40 @@ class DefaultProgressBarDecorator implements ProgressBarInterface public function __construct(OutputInterface $io, int $max = 0, bool $noProgress = false) { $this->progressBar = new ProgressBar($io, $max); - $this->progressBar->setFormatDefinition('verbose', ' %current%/%max% [%bar%] %percent:3s%% %message%'); + $this->progressBar::setFormatDefinition('verbose', ' %current%/%max% [%bar%] %percent:3s%% %message%'); $this->noProgress = $noProgress; } public function start(): void { - if ($this->isSetProgress()) { + if ($this->shouldRenderProgress()) { $this->progressBar->start(); } } public function setMessage(string $message): void { - if ($this->isSetProgress()) { + if ($this->shouldRenderProgress()) { $this->progressBar->setMessage($message); } } public function advance(): void { - if ($this->isSetProgress()) { + if ($this->shouldRenderProgress()) { $this->progressBar->advance(); } } public function finish(): void { - if ($this->isSetProgress()) { + if ($this->shouldRenderProgress()) { $this->progressBar->finish(); $this->progressBar->clear(); } } - private function isSetProgress(): bool + private function shouldRenderProgress(): bool { return !$this->noProgress; } From 15d9c69262a7f29269204cee78eb835629d40ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Fr=C3=B6mer?= Date: Tue, 18 Mar 2025 08:07:41 +0100 Subject: [PATCH 06/10] chore: Update phpstan dependencies --- composer.json | 8 +++---- composer.lock | 63 ++++++++++++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/composer.json b/composer.json index 1f1bfb3b..7c219156 100644 --- a/composer.json +++ b/composer.json @@ -56,13 +56,13 @@ "codeception/verify": "^3.1", "dg/bypass-finals": "^1.6", "ergebnis/composer-normalize": "^2.42", - "jangregor/phpstan-prophecy": "^1.0", + "jangregor/phpstan-prophecy": "^2.1.1", "mikey179/vfsstream": "^1.6.10", "php-ds/php-ds": "^1.5", "phpspec/prophecy-phpunit": "^2.2.0", "phpstan/extension-installer": "^1.3", - "phpstan/phpstan": "^1.10", - "phpstan/phpstan-phpunit": "^1.3", + "phpstan/phpstan": "^2.1.8", + "phpstan/phpstan-phpunit": "^2.0.4", "phpunit/phpunit": "^9.6.13", "roave/security-advisories": "dev-master", "squizlabs/php_codesniffer": "^3.9" @@ -98,7 +98,7 @@ } }, "scripts": { - "analyse": "phpstan analyse --no-progress", + "analyse": "phpstan analyse --no-progress --memory-limit=512M", "check": [ "@cs-check", "@analyse", diff --git a/composer.lock b/composer.lock index 8701ae6a..85bea239 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": "1be3be3f05d0711fbd1cfa42459eef41", + "content-hash": "04929820a91ec72569e3ef093d4f64c0", "packages": [ { "name": "composer-unused/contracts", @@ -2585,32 +2585,34 @@ }, { "name": "jangregor/phpstan-prophecy", - "version": "1.0.2", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/Jan0707/phpstan-prophecy.git", - "reference": "5ee56c7db1d58f0578c82a35e3c1befe840e85a9" + "reference": "011df00b14561a7f87ed3b99897296937a0cb08b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Jan0707/phpstan-prophecy/zipball/5ee56c7db1d58f0578c82a35e3c1befe840e85a9", - "reference": "5ee56c7db1d58f0578c82a35e3c1befe840e85a9", + "url": "https://api.github.com/repos/Jan0707/phpstan-prophecy/zipball/011df00b14561a7f87ed3b99897296937a0cb08b", + "reference": "011df00b14561a7f87ed3b99897296937a0cb08b", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0", - "phpstan/phpstan": "^1.0.0" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.5" }, "conflict": { - "phpspec/prophecy": "<1.7.0 || >=2.0.0", - "phpunit/phpunit": "<6.0.0 || >=12.0.0" + "phpspec/prophecy": "<1.17.0 || >=2.0.0", + "phpspec/prophecy-phpunit": "<2.3.0 || >=3.0.0", + "phpunit/phpunit": "<9.1.0 || >=12.0.0" }, "require-dev": { "ergebnis/composer-normalize": "^2.1.1", - "ergebnis/license": "^1.0.0", - "ergebnis/php-cs-fixer-config": "~2.2.0", + "ergebnis/license": "^2.6.0", + "ergebnis/php-cs-fixer-config": "^4.0 || ^5.0 || ^6.0", "phpspec/prophecy": "^1.7.0", - "phpunit/phpunit": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0" + "phpspec/prophecy-phpunit": "^2.3", + "phpunit/phpunit": "^9.1.0" }, "type": "phpstan-extension", "extra": { @@ -2638,9 +2640,9 @@ "description": "Provides a phpstan/phpstan extension for phpspec/prophecy", "support": { "issues": "https://github.com/Jan0707/phpstan-prophecy/issues", - "source": "https://github.com/Jan0707/phpstan-prophecy/tree/1.0.2" + "source": "https://github.com/Jan0707/phpstan-prophecy/tree/2.1.1" }, - "time": "2024-04-03T08:15:54+00:00" + "time": "2025-02-13T13:42:03+00:00" }, { "name": "justinrainbow/json-schema", @@ -3480,20 +3482,20 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.21", + "version": "2.1.8", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "14276fdef70575106a3392a4ed553c06a984df28" + "reference": "f9adff3b87c03b12cc7e46a30a524648e497758f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/14276fdef70575106a3392a4ed553c06a984df28", - "reference": "14276fdef70575106a3392a4ed553c06a984df28", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/f9adff3b87c03b12cc7e46a30a524648e497758f", + "reference": "f9adff3b87c03b12cc7e46a30a524648e497758f", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -3534,34 +3536,33 @@ "type": "github" } ], - "time": "2025-03-09T09:24:50+00:00" + "time": "2025-03-09T09:30:48+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "1.4.2", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "72a6721c9b64b3e4c9db55abbc38f790b318267e" + "reference": "d09e152f403c843998d7a52b5d87040c937525dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/72a6721c9b64b3e4c9db55abbc38f790b318267e", - "reference": "72a6721c9b64b3e4c9db55abbc38f790b318267e", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/d09e152f403c843998d7a52b5d87040c937525dd", + "reference": "d09e152f403c843998d7a52b5d87040c937525dd", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0.4" }, "conflict": { "phpunit/phpunit": "<7.0" }, "require-dev": { - "nikic/php-parser": "^4.13.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-strict-rules": "^1.5.1", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", "extra": { @@ -3584,9 +3585,9 @@ "description": "PHPUnit extensions and rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.2" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.4" }, - "time": "2024-12-17T17:20:49+00:00" + "time": "2025-01-22T13:07:38+00:00" }, { "name": "phpunit/php-code-coverage", From cfbf47779974e44b0d1e0b533fa5b752cd46ef10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Fr=C3=B6mer?= Date: Wed, 19 Mar 2025 10:17:03 +0100 Subject: [PATCH 07/10] chore: Update symbol-parser to solve php8.4 issue --- .github/workflows/validate-code.yml | 2 +- composer.json | 2 +- composer.lock | 56 +++++++++++++++-------------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/.github/workflows/validate-code.yml b/.github/workflows/validate-code.yml index 875afb72..50c3b07b 100644 --- a/.github/workflows/validate-code.yml +++ b/.github/workflows/validate-code.yml @@ -38,7 +38,7 @@ jobs: strategy: fail-fast: true matrix: - php: [ "8.1" ] + php: [ "8.1", "8.2", "8.3", "8.4" ] os: [ "ubuntu-latest" ] steps: - name: Checkout diff --git a/composer.json b/composer.json index 7c219156..752ed840 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "ext-json": "*", "composer-runtime-api": "^2.0", "composer-unused/contracts": "^0.3", - "composer-unused/symbol-parser": "^0.3.0", + "composer-unused/symbol-parser": "^0.3.1", "nikic/php-parser": "^5.0", "ondram/ci-detector": "^4.1", "phpstan/phpdoc-parser": "^1.25 || ^2", diff --git a/composer.lock b/composer.lock index 85bea239..337e6cf2 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": "04929820a91ec72569e3ef093d4f64c0", + "content-hash": "7f554ea0fe2ff08f222a613f41efb630", "packages": [ { "name": "composer-unused/contracts", @@ -54,16 +54,16 @@ }, { "name": "composer-unused/symbol-parser", - "version": "0.3.0", + "version": "0.3.1", "source": { "type": "git", "url": "https://github.com/composer-unused/symbol-parser.git", - "reference": "7c4d9d44abd0315146c3476d6e4d57ef7e0bfcd5" + "reference": "a55ecd3c10867be27a2eabf31cd1600160d250ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer-unused/symbol-parser/zipball/7c4d9d44abd0315146c3476d6e4d57ef7e0bfcd5", - "reference": "7c4d9d44abd0315146c3476d6e4d57ef7e0bfcd5", + "url": "https://api.github.com/repos/composer-unused/symbol-parser/zipball/a55ecd3c10867be27a2eabf31cd1600160d250ae", + "reference": "a55ecd3c10867be27a2eabf31cd1600160d250ae", "shasum": "" }, "require": { @@ -76,12 +76,12 @@ "symfony/finder": "^5.3 || ^6.0 || ^7.0" }, "require-dev": { - "ergebnis/composer-normalize": "^2.42", + "ergebnis/composer-normalize": "^2.45", "ext-ds": "*", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^2.1", "phpunit/phpunit": "^9.6.10 || ^10.5", "roave/security-advisories": "dev-master", - "squizlabs/php_codesniffer": "^3.9.0", + "squizlabs/php_codesniffer": "^3.11.3", "symfony/serializer": "^5.4" }, "type": "library", @@ -121,7 +121,7 @@ "type": "other" } ], - "time": "2025-03-17T14:39:15+00:00" + "time": "2025-03-19T09:13:50+00:00" }, { "name": "nikic/php-parser", @@ -2646,16 +2646,16 @@ }, { "name": "justinrainbow/json-schema", - "version": "6.3.0", + "version": "6.3.1", "source": { "type": "git", "url": "https://github.com/jsonrainbow/json-schema.git", - "reference": "fbb4049557dbac6ff554985eed95ba763c37528a" + "reference": "c9f00dec766a67bf82c277b71d71d254357db92c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/fbb4049557dbac6ff554985eed95ba763c37528a", - "reference": "fbb4049557dbac6ff554985eed95ba763c37528a", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/c9f00dec766a67bf82c277b71d71d254357db92c", + "reference": "c9f00dec766a67bf82c277b71d71d254357db92c", "shasum": "" }, "require": { @@ -2715,9 +2715,9 @@ ], "support": { "issues": "https://github.com/jsonrainbow/json-schema/issues", - "source": "https://github.com/jsonrainbow/json-schema/tree/6.3.0" + "source": "https://github.com/jsonrainbow/json-schema/tree/6.3.1" }, - "time": "2025-03-14T11:57:01+00:00" + "time": "2025-03-18T19:03:56+00:00" }, { "name": "localheinz/diff", @@ -4017,12 +4017,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "1fd2478f5f196be425357f9797048c94ec704135" + "reference": "74f7ebd1c51cf5a6682c4fad1697cb1fab3c17cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/1fd2478f5f196be425357f9797048c94ec704135", - "reference": "1fd2478f5f196be425357f9797048c94ec704135", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/74f7ebd1c51cf5a6682c4fad1697cb1fab3c17cf", + "reference": "74f7ebd1c51cf5a6682c4fad1697cb1fab3c17cf", "shasum": "" }, "conflict": { @@ -4115,12 +4115,14 @@ "chriskacerguis/codeigniter-restserver": "<=2.7.1", "civicrm/civicrm-core": ">=4.2,<4.2.9|>=4.3,<4.3.3", "ckeditor/ckeditor": "<4.25", + "clickstorm/cs-seo": ">=6,<6.7|>=7,<7.4|>=8,<8.3|>=9,<9.2", "cockpit-hq/cockpit": "<2.7|==2.7", "codeception/codeception": "<3.1.3|>=4,<4.1.22", "codeigniter/framework": "<3.1.9", "codeigniter4/framework": "<4.5.8", "codeigniter4/shield": "<1.0.0.0-beta8", "codiad/codiad": "<=2.8.4", + "codingms/additional-tca": ">=1.7,<1.15.17|>=1.16,<1.16.9", "components/jquery": ">=1.0.3,<3.5", "composer/composer": "<1.10.27|>=2,<2.2.24|>=2.3,<2.7.7", "concrete5/concrete5": "<9.4.0.0-RC1-dev", @@ -4129,7 +4131,7 @@ "contao/comments-bundle": ">=2,<4.13.40|>=5.0.0.0-RC1-dev,<5.3.4", "contao/contao": "<=5.4.1", "contao/core": "<3.5.39", - "contao/core-bundle": "<4.13.49|>=5,<5.3.15|>=5.4,<5.4.3", + "contao/core-bundle": "<4.13.54|>=5,<5.3.30|>=5.4,<5.5.6", "contao/listing-bundle": ">=3,<=3.5.30|>=4,<4.4.8", "contao/managed-edition": "<=1.5", "corveda/phpsandbox": "<1.3.5", @@ -4651,7 +4653,7 @@ "sylius/admin-bundle": ">=1,<1.0.17|>=1.1,<1.1.9|>=1.2,<1.2.2", "sylius/grid": ">=1,<1.1.19|>=1.2,<1.2.18|>=1.3,<1.3.13|>=1.4,<1.4.5|>=1.5,<1.5.1", "sylius/grid-bundle": "<1.10.1", - "sylius/paypal-plugin": ">=1,<1.2.4|>=1.3,<1.3.1", + "sylius/paypal-plugin": "<1.6.1|>=1.7,<1.7.1|>=2,<2.0.1", "sylius/resource-bundle": ">=1,<1.3.14|>=1.4,<1.4.7|>=1.5,<1.5.2|>=1.6,<1.6.4", "sylius/sylius": "<1.12.19|>=1.13.0.0-alpha1,<1.13.4", "symbiote/silverstripe-multivaluefield": ">=3,<3.1", @@ -4886,7 +4888,7 @@ "type": "tidelift" } ], - "time": "2025-03-16T18:05:49+00:00" + "time": "2025-03-18T22:05:07+00:00" }, { "name": "sebastian/cli-parser", @@ -5853,16 +5855,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.11.3", + "version": "3.12.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10" + "reference": "2d1b63db139c3c6ea0c927698e5160f8b3b8d630" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", - "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/2d1b63db139c3c6ea0c927698e5160f8b3b8d630", + "reference": "2d1b63db139c3c6ea0c927698e5160f8b3b8d630", "shasum": "" }, "require": { @@ -5929,11 +5931,11 @@ "type": "open_collective" }, { - "url": "https://thanks.dev/phpcsstandards", + "url": "https://thanks.dev/u/gh/phpcsstandards", "type": "thanks_dev" } ], - "time": "2025-01-23T17:04:15+00:00" + "time": "2025-03-18T05:04:51+00:00" }, { "name": "theseer/tokenizer", From afa144bebc262ebd191b4f0cf09bd3db846a875d Mon Sep 17 00:00:00 2001 From: Marcin Gladkowski Date: Tue, 8 Apr 2025 18:51:07 +0200 Subject: [PATCH 08/10] =?UTF-8?q?Issue=5F#607:=20set=20unused=20command=20?= =?UTF-8?q?as=20default=20while=20not=20other=20commands=20ar=E2=80=A6=20(?= =?UTF-8?q?#608)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marcin Gladkowski --- bin/composer-unused | 11 ++++++++--- src/Console/Command/DebugConsumedSymbolsCommand.php | 6 +++--- src/Console/Command/DebugProvidedSymbolsCommand.php | 4 +++- src/Console/Command/UnusedCommand.php | 4 +++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/bin/composer-unused b/bin/composer-unused index 596230d1..e8c08f31 100755 --- a/bin/composer-unused +++ b/bin/composer-unused @@ -16,7 +16,7 @@ use Symfony\Component\Console\Input\ArgvInput; __DIR__ . '/../../vendor/autoload.php', __DIR__ . '/../../../autoload.php', ] as $file) { - if (file_exists($file)) { + if (!defined('UNUSED_COMPOSER_INSTALL') && file_exists($file)) { define('UNUSED_COMPOSER_INSTALL', $file); break; @@ -61,7 +61,12 @@ use Symfony\Component\Console\Input\ArgvInput; $application->add($container->get(UnusedCommand::class)); $application->add($container->get(DebugConsumedSymbolsCommand::class)); $application->add($container->get(DebugProvidedSymbolsCommand::class)); - $application->setDefaultCommand('unused'); - $application->run(new ArgvInput($argv)); + $argvInput = new ArgvInput($argv); + + if (!in_array($argvInput->getFirstArgument(), [DebugProvidedSymbolsCommand::getDefaultName(), DebugConsumedSymbolsCommand::getDefaultName()], true)) { + $application->setDefaultCommand('unused', true); + } + + $application->run($argvInput); })($argv); diff --git a/src/Console/Command/DebugConsumedSymbolsCommand.php b/src/Console/Command/DebugConsumedSymbolsCommand.php index d2cee668..837ecfa0 100644 --- a/src/Console/Command/DebugConsumedSymbolsCommand.php +++ b/src/Console/Command/DebugConsumedSymbolsCommand.php @@ -8,16 +8,16 @@ use ComposerUnused\ComposerUnused\Command\Handler\CollectConsumedSymbolsCommandHandler; use ComposerUnused\ComposerUnused\Composer\ConfigFactory; use ComposerUnused\ComposerUnused\Composer\PackageFactory; -use ComposerUnused\ComposerUnused\Configuration\Configuration; use ComposerUnused\ComposerUnused\Configuration\ConfigurationProvider; use ComposerUnused\SymbolParser\Symbol\SymbolInterface; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand(name: 'debug:consumed-symbols')] final class DebugConsumedSymbolsCommand extends Command { private CollectConsumedSymbolsCommandHandler $collectConsumedSymbolsCommandHandler; @@ -31,7 +31,7 @@ public function __construct( PackageFactory $packageFactory, ConfigurationProvider $configurationProvider ) { - parent::__construct('debug:consumed-symbols'); + parent::__construct(self::getDefaultName()); $this->collectConsumedSymbolsCommandHandler = $collectConsumedSymbolsCommandHandler; $this->packageFactory = $packageFactory; $this->configFactory = $configFactory; diff --git a/src/Console/Command/DebugProvidedSymbolsCommand.php b/src/Console/Command/DebugProvidedSymbolsCommand.php index 471783c1..2729fce8 100644 --- a/src/Console/Command/DebugProvidedSymbolsCommand.php +++ b/src/Console/Command/DebugProvidedSymbolsCommand.php @@ -13,6 +13,7 @@ use ComposerUnused\ComposerUnused\PackageResolver; use ComposerUnused\ComposerUnused\Symbol\ProvidedSymbolLoaderBuilder; use ComposerUnused\SymbolParser\Symbol\SymbolInterface; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -20,6 +21,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand(name: 'debug:provided-symbols')] final class DebugProvidedSymbolsCommand extends Command { private ConfigFactory $configFactory; @@ -35,7 +37,7 @@ public function __construct( LocalRepositoryFactory $localRepositoryFactory, ConfigurationProvider $configurationProvider ) { - parent::__construct('debug:provided-symbols'); + parent::__construct(self::getDefaultName()); $this->configFactory = $configFactory; $this->packageResolver = $packageResolver; $this->providedSymbolLoaderBuilder = $providedSymbolLoaderBuilder; diff --git a/src/Console/Command/UnusedCommand.php b/src/Console/Command/UnusedCommand.php index 6c56121c..d0cd4d6b 100644 --- a/src/Console/Command/UnusedCommand.php +++ b/src/Console/Command/UnusedCommand.php @@ -21,6 +21,7 @@ use ComposerUnused\ComposerUnused\Filter\FilterCollection; use ComposerUnused\ComposerUnused\OutputFormatter\FormatterFactory; use InvalidArgumentException; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -37,6 +38,7 @@ use const DIRECTORY_SEPARATOR; +#[AsCommand(name: 'unused')] final class UnusedCommand extends Command { private CollectConsumedSymbolsCommandHandler $collectConsumedSymbolsCommandHandler; @@ -56,7 +58,7 @@ public function __construct( PackageFactory $packageFactory, ConfigurationProvider $configurationProvider ) { - parent::__construct('unused'); + parent::__construct(self::getDefaultName()); $this->configFactory = $configFactory; $this->collectConsumedSymbolsCommandHandler = $collectConsumedSymbolsCommandHandler; $this->collectRequiredDependenciesCommandHandler = $collectRequiredDependenciesCommandHandler; From 61b965df12cbd6c84028befb72244eb2b684ec0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Fr=C3=B6mer?= Date: Wed, 9 Apr 2025 09:08:53 +0200 Subject: [PATCH 09/10] feat: Only run phar signature check on main repository PRs --- .github/workflows/validate-phar.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/validate-phar.yml b/.github/workflows/validate-phar.yml index 88587167..966218f2 100644 --- a/.github/workflows/validate-phar.yml +++ b/.github/workflows/validate-phar.yml @@ -57,6 +57,7 @@ jobs: run: "vendor/bin/box info ${{ env.COMPOSER_UNUSED_PHAR }}" - name: "Import GPG key" + if: github.event.pull_request.head.repo.full_name == github.repository id: "import_gpg" uses: "crazy-max/ghaction-import-gpg@v6" with: @@ -64,12 +65,15 @@ jobs: passphrase: "${{ secrets.GPG_PASSPHRASE }}" - name: "Sign composer-unused.phar" + if: github.event.pull_request.head.repo.full_name == github.repository run: "gpg --default-key ${{ steps.import_gpg.outputs.keyid }} --sign ${{ env.COMPOSER_UNUSED_PHAR }}" - name: "Detach signature" + if: github.event.pull_request.head.repo.full_name == github.repository run: "gpg --default-key ${{ steps.import_gpg.outputs.keyid }} --output ${{ env.COMPOSER_UNUSED_PHAR_SIGNATURE }} --detach-sig ${{ env.COMPOSER_UNUSED_PHAR }}" - name: "Verify signature" + if: github.event.pull_request.head.repo.full_name == github.repository run: "gpg --verify ${{ env.COMPOSER_UNUSED_PHAR_SIGNATURE }} ${{ env.COMPOSER_UNUSED_PHAR }}" - name: "Validate composer-unused.phar against code" From da5212b085d279ddeca19e007edf98e93b867724 Mon Sep 17 00:00:00 2001 From: Giso Stallenberg Date: Fri, 4 Apr 2025 14:11:56 +0200 Subject: [PATCH 10/10] Add a compact formatter Add a compact formatter, that only prints single lines with errors --- src/Console/Command/UnusedCommand.php | 2 +- src/OutputFormatter/CompactFormatter.php | 49 ++++++++++ src/OutputFormatter/FormatterFactory.php | 2 + .../CompactFormatter/CompactFormatterTest.php | 93 +++++++++++++++++++ 4 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 src/OutputFormatter/CompactFormatter.php create mode 100644 tests/Unit/OutputFormatter/CompactFormatter/CompactFormatterTest.php diff --git a/src/Console/Command/UnusedCommand.php b/src/Console/Command/UnusedCommand.php index d0cd4d6b..b214831b 100644 --- a/src/Console/Command/UnusedCommand.php +++ b/src/Console/Command/UnusedCommand.php @@ -85,7 +85,7 @@ protected function configure(): void 'output-format', 'o', InputOption::VALUE_REQUIRED, - 'Change output style (default, github, json, junit, gitlab)' + 'Change output style (default, compact, github, json, junit, gitlab)' ); $this->addOption( diff --git a/src/OutputFormatter/CompactFormatter.php b/src/OutputFormatter/CompactFormatter.php new file mode 100644 index 00000000..6ab1381f --- /dev/null +++ b/src/OutputFormatter/CompactFormatter.php @@ -0,0 +1,49 @@ +getName(); + } + if (count($unused) > 0) { + $output->text(sprintf('Unused packages: %s', implode(', ', $unused))); + } + + $zombies = []; + foreach ($filterCollection->getUnused() as $filter) { + $zombies[] = $filter->toString(); + } + if (count($zombies) > 0) { + $output->text(sprintf('Zombie exclusions: %s', implode(' / ', $zombies))); + } + + if ($unusedDependencyCollection->count() > 0 || count($filterCollection->getUnused()) > 0) { + return 1; + } + + return 0; + } +} diff --git a/src/OutputFormatter/FormatterFactory.php b/src/OutputFormatter/FormatterFactory.php index d60059bd..6991ac96 100644 --- a/src/OutputFormatter/FormatterFactory.php +++ b/src/OutputFormatter/FormatterFactory.php @@ -33,6 +33,8 @@ public function create(?string $type): OutputFormatterInterface } switch ($type) { + case 'compact': + return new CompactFormatter(); case 'github': return new GithubFormatter(); case 'json': diff --git a/tests/Unit/OutputFormatter/CompactFormatter/CompactFormatterTest.php b/tests/Unit/OutputFormatter/CompactFormatter/CompactFormatterTest.php new file mode 100644 index 00000000..1c5da026 --- /dev/null +++ b/tests/Unit/OutputFormatter/CompactFormatter/CompactFormatterTest.php @@ -0,0 +1,93 @@ +compactFormatter = new CompactFormatter(); + } + + /** + * @test + */ + public function itPrints(): void + { + $symfonyStringRequiredDependency = new RequiredDependency( + new Package('symfony/string'), + ); + $symfonyStringRequiredDependency->requiredBy(new TestDependency('symfony/event-dispatcher')); + $usedDependencyCollection = new DependencyCollection([$symfonyStringRequiredDependency]); + + $unusedDependencyCollection = new DependencyCollection([ + new RequiredDependency(new Package('symfony/console')) + ]); + + $bufferedOutput = new BufferedOutput(); + $outputStyle = new SymfonyStyle(new ArgvInput(), $bufferedOutput); + + $returnStatus = $this->compactFormatter->formatOutput( + $this->createMock(PackageInterface::class), + 'composer.json', + $usedDependencyCollection, + $unusedDependencyCollection, + new DependencyCollection(), + new FilterCollection([NamedFilter::fromString('symfony/zombie')], []), + $outputStyle + ); + $consoleOutput = $bufferedOutput->fetch(); + + self::assertSame(1, $returnStatus); + $lines = \explode(PHP_EOL, trim($consoleOutput)); + self::assertSame('Unused packages: symfony/console', trim($lines[0])); + self::assertSame('Zombie exclusions: NamedFilter(userProvided: true, string: symfony/zombie)', trim($lines[1])); + } + + + /** + * @test + */ + public function itPrintsNothingWhenNoErrors(): void + { + $symfonyStringRequiredDependency = new RequiredDependency( + new Package('symfony/string'), + ); + $symfonyStringRequiredDependency->requiredBy(new TestDependency('symfony/event-dispatcher')); + $usedDependencyCollection = new DependencyCollection([$symfonyStringRequiredDependency]); + + $bufferedOutput = new BufferedOutput(); + $outputStyle = new SymfonyStyle(new ArgvInput(), $bufferedOutput); + + $returnStatus = $this->compactFormatter->formatOutput( + $this->createMock(PackageInterface::class), + 'composer.json', + $usedDependencyCollection, + new DependencyCollection([]), + new DependencyCollection(), + new FilterCollection([], []), + $outputStyle + ); + $consoleOutput = $bufferedOutput->fetch(); + + self::assertSame(0, $returnStatus); + self::assertSame('', $consoleOutput); + } +}