Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| VersionChecker | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| onEvent | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | */ |
| 5 | |
| 6 | namespace MediaWiki\Composer; |
| 7 | |
| 8 | use Composer\Composer; |
| 9 | use RuntimeException; |
| 10 | |
| 11 | /** |
| 12 | * Checks the version of Composer that this is being run on, and aborts if not version 2 or later |
| 13 | * |
| 14 | * @internal |
| 15 | * @since 1.42 |
| 16 | */ |
| 17 | class VersionChecker { |
| 18 | public static function onEvent() { |
| 19 | $version = Composer::VERSION; |
| 20 | if ( $version === '@package_version@' ) { |
| 21 | // In Composer 1.9+, unreleased git branches have this value in Composer::VERSION, |
| 22 | // and Composer::getVersion() was introduced to work around this. |
| 23 | $version = Composer::getVersion(); |
| 24 | } |
| 25 | if ( version_compare( $version, '2.0.0', '<' ) ) { |
| 26 | throw new RuntimeException( |
| 27 | "MediaWiki requires Composer version 2 or later; version 1" |
| 28 | . " has been considered end of life since October 2020!" |
| 29 | ); |
| 30 | } |
| 31 | } |
| 32 | } |