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 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
16 | * |
17 | */ |
18 | |
19 | namespace MediaWiki\Composer; |
20 | |
21 | use Composer\Composer; |
22 | use RuntimeException; |
23 | |
24 | /** |
25 | * Checks the version of Composer that this is being run on, and aborts if not version 2 or later |
26 | * |
27 | * @internal |
28 | * @since 1.42 |
29 | */ |
30 | class VersionChecker { |
31 | public static function onEvent() { |
32 | $version = Composer::VERSION; |
33 | if ( $version === '@package_version@' ) { |
34 | // In Composer 1.9+, unreleased git branches have this value in Composer::VERSION, |
35 | // and Composer::getVersion() was introduced to work around this. |
36 | $version = Composer::getVersion(); |
37 | } |
38 | if ( version_compare( $version, '2.0.0', '<' ) ) { |
39 | throw new RuntimeException( |
40 | "MediaWiki requires Composer version 2 or later; version 1" |
41 | . " has been considered end of life since October 2020!" |
42 | ); |
43 | } |
44 | } |
45 | } |