Skip to content

Commit 8a275c4

Browse files
committed
Setup mediawiki/mediawiki-phan-config
Use phan-suppress-next-line on a couple of lines where it needs composer 1.x code; expect phan to be tested against composer 2.x.
1 parent 4f111aa commit 8a275c4

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

.github/workflows/php.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
uses: shivammathur/setup-php@v2
2929
with:
3030
php-version: ${{ matrix.php-version }}
31+
extensions: ast
3132
coverage: xdebug
3233
tools: composer:v2
3334

@@ -48,6 +49,7 @@ jobs:
4849
dependency-versions: "${{ matrix.composer-dependencies }}"
4950

5051
- run: composer test
52+
- run: composer phan
5153

5254
ocular-push:
5355
runs-on: ubuntu-latest

.phan/config.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
$cfg = require __DIR__ . '/../vendor/mediawiki/mediawiki-phan-config/src/config.php';
4+
5+
$cfg['directory_list'] = array_merge(
6+
$cfg['directory_list'],
7+
[
8+
'vendor/composer/composer/src/Composer/',
9+
'vendor/composer/semver/src/',
10+
11+
]
12+
);
13+
14+
$cfg['exclude_analysis_directory_list'] = array_merge(
15+
$cfg['exclude_analysis_directory_list'],
16+
[
17+
'vendor/composer/composer/src/Composer/',
18+
'vendor/composer/semver/src/',
19+
]
20+
);
21+
22+
return $cfg;

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
},
1818
"require-dev": {
1919
"composer/composer": "^1.1||^2.0",
20+
"mediawiki/mediawiki-phan-config": "0.10.6",
2021
"php-parallel-lint/php-parallel-lint": "~1.2.0",
2122
"phpunit/phpunit": "^8.5||^9.0",
2223
"squizlabs/php_codesniffer": "~3.5.8"
@@ -41,6 +42,7 @@
4142
"phpunit --log-junit=reports/unitreport.xml --coverage-text --coverage-html=reports/coverage --coverage-clover=reports/coverage.xml",
4243
"phpcs --encoding=utf-8 --standard=PSR2 --report-checkstyle=reports/checkstyle-phpcs.xml --report-full --extensions=php src/* tests/phpunit/*"
4344
],
45+
"phan": "phan -d . --long-progress-bar",
4446
"test": [
4547
"composer validate --no-interaction",
4648
"parallel-lint src tests",

src/MergePlugin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ public function onPostInstallOrUpdate(ScriptEvent $event)
373373
$installer->setUpdate(true);
374374

375375
if ($this->state->isComposer1()) {
376+
// setUpdateWhitelist() only exists in composer 1.x. Configure as to run phan against composer 2.x
377+
// @phan-suppress-next-line PhanUndeclaredMethod
376378
$installer->setUpdateWhitelist($requirements);
377379
} else {
378380
$installer->setUpdateAllowList($requirements);

src/MultiConstraint.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class MultiConstraint extends SemverMultiConstraint
3636
public static function create(array $constraints, $conjunctive = true)
3737
{
3838
if (\count($constraints) === 0) {
39+
// EmptyConstraint only exists in composer 1.x. Configure as to run phan against composer 2.x
40+
// @phan-suppress-next-line PhanTypeMismatchReturn, PhanUndeclaredClassMethod
3941
return new EmptyConstraint();
4042
}
4143

0 commit comments

Comments
 (0)