Skip to content

Commit 33173ba

Browse files
committed
Upgrade mediawiki-codesniffer to latest version (45.0.0)
This repository is currently using version 34 of the Mediawiki coding style phpcs rules. If the code aims to comply with Mediawiki style guidelines, it makes sense that it continues to comply at current versions of the rules. Besides being simply different, the newer versions of the rules introduce, for example, MediaWiki.Usage.NullableType.ExplicitNullableTypes, which enforces compliance with coming deprecation rules in PHP 8.4 concerning nullable types. If the code does not remove the soon-to-be-deprecated form of nullable type declarations, the library will no longer be usable in Mediawiki for PHP 8.4 deployments. Note that mediawiki-codesniffer 45.0.0 requires PHP version 7.4 or later - PHP 7.3 support will be dropped with this change. PHP 7.3 has been out of support since 6. Dec 2021. Resolves #222 Bug: T379481
1 parent cce979e commit 33173ba

22 files changed

+76
-47
lines changed

.github/workflows/php.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
php:
16-
- '7.3'
1716
- '7.4'
1817
- '8.0'
1918
- '8.1'

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
},
4646
"require-dev": {
4747
"phpunit/phpunit": "^9.4.1",
48-
"mediawiki/mediawiki-codesniffer": "^34 || ^35 || ^36 || ^38",
48+
"mediawiki/mediawiki-codesniffer": "45.0.0",
4949
"ockcyp/covers-validator": "^1.3.3",
5050
"phpstan/phpstan": "^0.12.68 || ^1.0.0",
5151
"phpmd/phpmd": "^2.9.1",
@@ -83,5 +83,10 @@
8383
"@test",
8484
"@cs"
8585
]
86+
},
87+
"config": {
88+
"allow-plugins": {
89+
"dealerdirect/phpcodesniffer-composer-installer": true
90+
}
8691
}
8792
}

phpcs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
<rule ref="Generic.Metrics.CyclomaticComplexity" />
1313
<rule ref="Generic.Metrics.NestingLevel" />
1414
<rule ref="Squiz.Operators.ValidLogicalOperators" />
15+
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
1516
</ruleset>

src/Formatters/GlobeCoordinateFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class GlobeCoordinateFormatter implements ValueFormatter {
3030
*/
3131
private $formatter;
3232

33-
public function __construct( FormatterOptions $options = null ) {
33+
public function __construct( ?FormatterOptions $options = null ) {
3434
$this->formatter = new LatLongFormatter( $options );
3535
}
3636

src/Formatters/LatLongFormatter.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ class LatLongFormatter implements ValueFormatter {
9393

9494
private const DEFAULT_PRECISION = 1 / 3600;
9595

96+
/** @var FormatterOptions */
9697
private $options;
9798

98-
public function __construct( FormatterOptions $options = null ) {
99+
public function __construct( ?FormatterOptions $options = null ) {
99100
$this->options = $options ?? new FormatterOptions();
100101

101102
$this->defaultOption( self::OPT_NORTH_SYMBOL, 'N' );
@@ -211,7 +212,6 @@ private function formatLongitude( float $longitude, float $precision ): string {
211212

212213
private function makeDirectionalIfNeeded( string $coordinate, string $positiveSymbol,
213214
string $negativeSymbol ): string {
214-
215215
if ( $this->options->getOption( self::OPT_DIRECTIONAL ) ) {
216216
return $this->makeDirectional( $coordinate, $positiveSymbol, $negativeSymbol );
217217
}
@@ -221,7 +221,6 @@ private function makeDirectionalIfNeeded( string $coordinate, string $positiveSy
221221

222222
private function makeDirectional( string $coordinate, string $positiveSymbol,
223223
string $negativeSymbol ): string {
224-
225224
$isNegative = substr( $coordinate, 0, 1 ) === '-';
226225

227226
if ( $isNegative ) {

src/GlobeMath.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function normalizeGlobeCoordinate( GlobeCoordinateValue $value ): GlobeCo
5959
*
6060
* @return LatLongValue
6161
*/
62-
public function normalizeGlobeLatLong( LatLongValue $value, string $globe = null ): LatLongValue {
62+
public function normalizeGlobeLatLong( LatLongValue $value, ?string $globe = null ): LatLongValue {
6363
switch ( $this->normalizeGlobe( $globe ) ) {
6464
case GlobeCoordinateValue::GLOBE_EARTH:
6565
case self::GLOBE_MOON:

src/PackagePrivate/DmPrecisionDetector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
class DmPrecisionDetector extends PrecisionDetector {
88

9+
/** @var DmsPrecisionDetector the precision detector */
910
private $dmsPrecisionDetector;
1011

1112
public function __construct() {

src/PackagePrivate/LatLongPrecisionParser.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111

1212
class LatLongPrecisionParser {
1313

14+
/** @var ?ParserOptions the parser options */
1415
private $options;
16+
17+
/** @var ?array array of parsers in use */
1518
private $parsers;
1619

17-
public function __construct( ParserOptions $options = null ) {
20+
public function __construct( ?ParserOptions $options = null ) {
1821
$this->options = $options;
1922
}
2023

src/PackagePrivate/PreciseLatLong.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
class PreciseLatLong {
1010

11+
/** @var LatLongValue the latitude/longitude value */
1112
private $latLong;
13+
/** @var Precision the precision */
1214
private $precision;
1315

1416
public function __construct( LatLongValue $latLong, Precision $precision ) {

src/PackagePrivate/Precision.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
class Precision {
88

9+
/** @var float the precision in degrees */
910
private $precision;
1011

1112
public function __construct( float $precisionInDegrees ) {

0 commit comments

Comments
 (0)