Skip to content

Commit f2a0782

Browse files
authored
Add Composer Dependency Analyser (#324)
1 parent 7d381f8 commit f2a0782

6 files changed

Lines changed: 56 additions & 53 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: composer dependency analyser
2+
3+
on:
4+
pull_request:
5+
paths: &paths
6+
- 'config/**'
7+
- 'src/**'
8+
- 'stubs/**'
9+
- 'tests/**'
10+
- '.github/workflows/composer-dependency-analyser.yml'
11+
- 'composer.json'
12+
- 'composer-dependency-analyser.php'
13+
push:
14+
branches: ['master']
15+
paths: *paths
16+
17+
permissions:
18+
contents: read
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
composer-dependency-analyser:
26+
uses: yiisoft/actions/.github/workflows/composer-dependency-analyser.yml@master
27+
with:
28+
php: >-
29+
['8.1', '8.2', '8.3', '8.4', '8.5']

‎.github/workflows/composer-require-checker.yml‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎composer-dependency-analyser.php‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
6+
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;
7+
8+
return (new Configuration())
9+
->disableComposerAutoloadPathScan()
10+
->setFileExtensions(['php'])
11+
->addPathToScan(__DIR__ . '/config', isDev: false)
12+
->addPathToScan(__DIR__ . '/src', isDev: false)
13+
->addPathToScan(__DIR__ . '/stubs', isDev: false)
14+
->addPathToScan(__DIR__ . '/tests', isDev: true)
15+
// ext-pcntl / ext-posix are optional (see "suggest" in composer.json): only needed when
16+
// using `Yiisoft\Queue\Cli\SignalLoop` and its tests, not for the package to function.
17+
->ignoreErrorsOnExtensions(['ext-pcntl', 'ext-posix'], [ErrorType::SHADOW_DEPENDENCY])
18+
// yiisoft/yii-debug integration in src/Debug is an optional debug panel collector, only
19+
// loaded when the consumer wires up yiisoft/yii-debug themselves.
20+
->ignoreErrorsOnPackages(['yiisoft/yii-debug'], [ErrorType::DEV_DEPENDENCY_IN_PROD]);

‎composer-require-checker.json‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎composer.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
},
4949
"require-dev": {
5050
"friendsofphp/php-cs-fixer": "^3.95.11",
51-
"maglnet/composer-require-checker": "^4.7.1",
5251
"phpbench/phpbench": "^1.4.3",
5352
"phpunit/phpunit": "^10.5.63",
5453
"rector/rector": "^2.5.2",
5554
"roave/infection-static-analysis-plugin": "^1.35",
55+
"shipmonk/composer-dependency-analyser": "^1.8",
5656
"vimeo/psalm": "^5.26.1 || ^6.16.1",
5757
"yiisoft/code-style": "^1.0",
5858
"yiisoft/test-support": "^3.2.0",
@@ -91,5 +91,8 @@
9191
"composer/package-versions-deprecated": true,
9292
"yiisoft/config": false
9393
}
94+
},
95+
"scripts": {
96+
"dependency-analyser": "composer-dependency-analyser"
9497
}
9598
}

‎docs/internals.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ use either newest or any specific version of PHP:
3636

3737
## Dependencies
3838

39-
This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if
40-
all dependencies are correctly defined in `composer.json`. To run the checker, execute the following command:
39+
Use [Composer Dependency Analyser](https://github.com/shipmonk-rnd/composer-dependency-analyser) to detect unknown,
40+
shadow, and unused [Composer](https://getcomposer.org) dependencies:
4141

4242
```shell
43-
./vendor/bin/composer-require-checker
43+
./vendor/bin/composer-dependency-analyser
4444
```

0 commit comments

Comments
 (0)