Skip to content

Commit f5e02d4

Browse files
authored
Allow specifying a list of extensions to ignore
1 parent 3f3d1ba commit f5e02d4

File tree

12 files changed

+139
-7
lines changed

12 files changed

+139
-7
lines changed

.github/workflows/integration-tests.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
COMPOSER_ROOT_VERSION: "1.2.x-dev"
1313

1414
jobs:
15-
test:
15+
integration-test:
1616
name: "Integration test"
1717
runs-on: "ubuntu-latest"
1818

@@ -40,16 +40,52 @@ jobs:
4040
tools: "composer:${{ matrix.composer-version }}"
4141

4242
- name: "Install dependencies"
43-
working-directory: "e2e"
43+
working-directory: "e2e/integration"
4444
run: "composer install --no-interaction --no-progress --no-suggest"
4545

4646
- name: "Test"
47-
working-directory: "e2e"
47+
working-directory: "e2e/integration"
4848
run: "vendor/bin/phpstan analyse -l 8 FooTest.php"
4949

5050
- name: "Rename directory"
51-
run: "mv e2e e3e"
51+
working-directory: "e2e"
52+
run: "mv integration integration-copy"
5253

5354
- name: "Test relative paths - after renaming"
54-
working-directory: "e3e"
55+
working-directory: "e2e/integration-copy"
5556
run: "vendor/bin/phpstan analyse -l 8 FooTest.php"
57+
58+
ignore-test:
59+
name: "Ignore test"
60+
runs-on: "ubuntu-latest"
61+
62+
strategy:
63+
matrix:
64+
php-version:
65+
- "7.4"
66+
- "8.0"
67+
- "8.1"
68+
- "8.2"
69+
composer-version:
70+
- "v2"
71+
- "preview"
72+
- "snapshot"
73+
74+
steps:
75+
- name: "Checkout"
76+
uses: actions/checkout@v3
77+
78+
- name: "Install PHP"
79+
uses: "shivammathur/setup-php@v2"
80+
with:
81+
coverage: "none"
82+
php-version: "${{ matrix.php-version }}"
83+
tools: "composer:${{ matrix.composer-version }}"
84+
85+
- name: "Install dependencies"
86+
working-directory: "e2e/ignore"
87+
run: "composer install --no-interaction --no-progress --no-suggest"
88+
89+
- name: "Test"
90+
working-directory: "e2e/ignore"
91+
run: "vendor/bin/phpstan analyse -l 8 IgnoreTest.php"

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ Add `phpstan` key in the extension `composer.json`'s `extra` section:
7272
}
7373
```
7474

75+
## Ignoring a particular extension
76+
77+
You may want to disable auto-installation of a particular extension to handle installation manually. Ignore an extension by adding an `extra.phpstan/extension-installer.ignore` array in `composer.json` that specifies a list of packages to ignore:
78+
79+
```json
80+
{
81+
"extra": {
82+
"phpstan/extension-installer": {
83+
"ignore": [
84+
"phpstan/phpstan-phpunit"
85+
]
86+
}
87+
}
88+
}
89+
```
90+
7591
## Limitations
7692

7793
The extension installer depends on Composer script events, therefore you cannot use `--no-scripts` flag.

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
}
2323
},
2424
"extra": {
25-
"class": "PHPStan\\ExtensionInstaller\\Plugin"
25+
"class": "PHPStan\\ExtensionInstaller\\Plugin",
26+
"phpstan/extension-installer": {
27+
"ignore": ["phpstan/phpstan-phpunit"]
28+
}
2629
},
2730
"autoload": {
2831
"psr-4": {
File renamed without changes.

e2e/ignore/IgnoreTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace App;
4+
5+
class IgnoreTest
6+
{
7+
}

e2e/ignore/composer.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"require": {
3+
"phpstan/phpstan": "^1.8.0",
4+
"phpstan/extension-installer": "1.2.x-dev",
5+
"testing/test-extension": "^1.0"
6+
},
7+
"repositories": [
8+
{
9+
"type": "path",
10+
"url": "../..",
11+
"options": {
12+
"symlink": false
13+
}
14+
},
15+
{
16+
"type": "path",
17+
"url": "../test-extension",
18+
"options": {
19+
"symlink": false
20+
}
21+
}
22+
],
23+
"config": {
24+
"allow-plugins": {
25+
"phpstan/extension-installer": true
26+
}
27+
},
28+
"extra": {
29+
"phpstan/extension-installer": {
30+
"ignore": [
31+
"testing/test-extension"
32+
]
33+
}
34+
}
35+
}

e2e/integration/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/composer.lock
2+
/vendor
File renamed without changes.

e2e/composer.json renamed to e2e/integration/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"repositories": [
99
{
1010
"type": "path",
11-
"url": "..",
11+
"url": "../..",
1212
"options": {
1313
"symlink": false
1414
}

e2e/test-extension/composer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "1.0",
3+
"name": "testing/test-extension",
4+
"extra": {
5+
"phpstan": {
6+
"includes": [
7+
"extension.neon"
8+
]
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)