Skip to content

Commit b299c06

Browse files
authored
Add Composer Dependency Analyser (#60)
1 parent 17f6949 commit b299c06

4 files changed

Lines changed: 95 additions & 1 deletion

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: composer dependency analyser
2+
3+
on:
4+
pull_request:
5+
paths: &paths
6+
- 'src/**'
7+
- 'tests/**'
8+
- '.github/workflows/composer-dependency-analyser.yml'
9+
- 'composer.json'
10+
- 'composer-dependency-analyser.php'
11+
push:
12+
branches: ['master']
13+
paths: *paths
14+
15+
permissions:
16+
contents: read
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
composer-dependency-analyser:
24+
name: PHP ${{ matrix.php }}
25+
runs-on: windows-latest
26+
strategy:
27+
matrix:
28+
php:
29+
- 7.4
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
34+
with:
35+
persist-credentials: false
36+
37+
- name: Install PHP
38+
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
39+
with:
40+
php-version: ${{ matrix.php }}
41+
tools: composer:v2
42+
coverage: none
43+
44+
- name: Choco install 7zip
45+
uses: crazy-max/ghaction-chocolatey@dfdcf5bba9c0a16358a21c13a06ec5c89024b3ac # v4.1.0
46+
with:
47+
args: install 7zip
48+
49+
- uses: suisei-cn/actions-download-file@9f75b8c2dad5ccced7509c44a3b881c5613abde2 # v1.6.1
50+
id: wincache
51+
name: Download WinCache
52+
with:
53+
url: "https://downloads.sourceforge.net/project/wincache/development/wincache-2.0.0.8-dev-7.4-nts-vc15-x64.exe"
54+
target: C:\tools\php\ext
55+
56+
- name: Install WinCache
57+
run: |
58+
cd C:\tools\php\ext
59+
7z e -y wincache-2.0.0.8-dev-7.4-nts-vc15-x64.exe
60+
61+
- name: Update php.ini
62+
run: |
63+
cd C:\tools\php
64+
echo extension=php_wincache.dll >> php.ini
65+
echo wincache.enablecli=1 >> php.ini
66+
67+
- name: Install Composer dependencies
68+
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
69+
70+
- name: Check dependencies
71+
run: vendor/bin/composer-dependency-analyser

composer-dependency-analyser.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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__ . '/src', false)
12+
->addPathToScan(__DIR__ . '/tests', true);

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@
3636
},
3737
"require-dev": {
3838
"friendsofphp/php-cs-fixer": "^3.92.5",
39-
"rector/rector": "^2.3.0",
4039
"phpunit/phpunit": "^9.5",
40+
"rector/rector": "^2.3.0",
4141
"roave/infection-static-analysis-plugin": "^1.16",
42+
"shipmonk/composer-dependency-analyser": "^1.8.4",
4243
"spatie/phpunit-watcher": "^1.23",
4344
"vimeo/psalm": "^4.18"
4445
},
@@ -63,6 +64,7 @@
6364
}
6465
},
6566
"scripts": {
67+
"dependency-analyser": "composer-dependency-analyser",
6668
"test": "phpunit --testdox --no-interaction",
6769
"test-watch": "phpunit-watcher watch"
6870
}

docs/internals.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ The code is statically analyzed with [Psalm](https://psalm.dev/). To run static
2424
```shell
2525
./vendor/bin/psalm
2626
```
27+
28+
## Dependencies
29+
30+
Use [Composer Dependency Analyser](https://github.com/shipmonk-rnd/composer-dependency-analyser) to detect unknown,
31+
shadow, and unused [Composer](https://getcomposer.org) dependencies:
32+
33+
```shell
34+
./vendor/bin/composer-dependency-analyser
35+
```

0 commit comments

Comments
 (0)