Skip to content

Commit ae70d19

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. Resolves #62 Bug: T379481
1 parent 7c54a89 commit ae70d19

File tree

16 files changed

+35
-32
lines changed

16 files changed

+35
-32
lines changed

.github/workflows/php.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
php:
16-
- '7.2'
17-
- '7.3'
1816
- '7.4'
1917
- '8.0'
2018

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
}
2121
],
2222
"require": {
23-
"php": ">=7.2"
23+
"php": ">=7.4"
2424
},
2525
"require-dev": {
2626
"phpunit/phpunit": "~8.5",
27-
"mediawiki/mediawiki-codesniffer": "^34",
27+
"mediawiki/mediawiki-codesniffer": "^45",
2828
"ockcyp/covers-validator": "~1.0",
2929
"phpstan/phpstan": "^0.12.68",
3030
"phpmd/phpmd": "^2.9.1"
@@ -51,5 +51,10 @@
5151
"@test",
5252
"@cs"
5353
]
54+
},
55+
"config": {
56+
"allow-plugins": {
57+
"dealerdirect/phpcodesniffer-composer-installer": true
58+
}
5459
}
5560
}

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/ValueFormatters/FormatterOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use RuntimeException;
1010

1111
/**
12-
* @license GPL-2.0+
12+
* @license GPL-2.0-or-later
1313
* @author Jeroen De Dauw < [email protected] >
1414
*/
1515
final class FormatterOptions {

src/ValueFormatters/FormattingException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use RuntimeException;
88

99
/**
10-
* @license GPL-2.0+
10+
* @license GPL-2.0-or-later
1111
* @author Jeroen De Dauw < [email protected] >
1212
*/
1313
class FormattingException extends RuntimeException {

src/ValueFormatters/ValueFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Interface for value formatters, typically (but not limited to) expecting a DataValue object and
99
* returning a string.
1010
*
11-
* @license GPL-2.0+
11+
* @license GPL-2.0-or-later
1212
* @author Jeroen De Dauw < [email protected] >
1313
*/
1414
interface ValueFormatter {
@@ -17,7 +17,7 @@ interface ValueFormatter {
1717
* Identifier for the option that holds the code of the language in which the formatter should
1818
* operate.
1919
*/
20-
const OPT_LANG = 'lang';
20+
public const OPT_LANG = 'lang';
2121

2222
/**
2323
* @param mixed $value

src/ValueParsers/ParseException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use RuntimeException;
88

99
/**
10-
* @license GPL-2.0+
10+
* @license GPL-2.0-or-later
1111
* @author Jeroen De Dauw < [email protected] >
1212
*/
1313
class ParseException extends RuntimeException {
@@ -23,11 +23,11 @@ class ParseException extends RuntimeException {
2323
private $rawValue;
2424

2525
/**
26-
* @param string $message A plain english message describing the error
26+
* @param string $message A plain english message describing the error
2727
* @param string|null $rawValue The raw value that failed to be parsed.
2828
* @param string|null $expectedFormat An identifier for the format the raw value did not match
2929
*/
30-
public function __construct( string $message, string $rawValue = null, string $expectedFormat = null ) {
30+
public function __construct( string $message, ?string $rawValue = null, ?string $expectedFormat = null ) {
3131
parent::__construct( $message );
3232
$this->expectedFormat = $expectedFormat;
3333
$this->rawValue = $rawValue;

src/ValueParsers/ParserOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use RuntimeException;
99

1010
/**
11-
* @license GPL-2.0+
11+
* @license GPL-2.0-or-later
1212
* @author Jeroen De Dauw < [email protected] >
1313
*/
1414
final class ParserOptions {

src/ValueParsers/ValueParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Interface for value parsers, typically (but not limited to) expecting a string and returning a
99
* DataValue object.
1010
*
11-
* @license GPL-2.0+
11+
* @license GPL-2.0-or-later
1212
* @author Jeroen De Dauw < [email protected] >
1313
*/
1414
interface ValueParser {

src/ValueValidators/Error.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@
55
namespace ValueValidators;
66

77
/**
8-
* @license GPL-2.0+
8+
* @license GPL-2.0-or-later
99
* @author Jeroen De Dauw < [email protected] >
1010
*/
1111
class Error {
1212

1313
public const SEVERITY_ERROR = 9;
1414
public const SEVERITY_WARNING = 4;
1515

16-
private $text;
17-
private $severity;
18-
private $property;
16+
private string $text;
17+
private int $severity;
18+
private ?string $property;
19+
private string $code;
20+
private array $params;
1921

20-
private $code;
21-
private $params;
22-
23-
public static function newError( string $text = '', string $property = null, string $code = 'invalid', array $params = [] ): self {
22+
public static function newError( string $text = '', ?string $property = null, string $code = 'invalid', array $params = [] ): self {
2423
return new self( $text, self::SEVERITY_ERROR, $property, $code, $params );
2524
}
2625

@@ -37,7 +36,7 @@ public function getText(): string {
3736
}
3837

3938
/**
40-
* @return integer, element of the ValueValidatorError::SEVERITY_ enum
39+
* @return int element of the ValueValidatorError::SEVERITY_ enum
4140
*/
4241
public function getSeverity(): int {
4342
return $this->severity;

0 commit comments

Comments
 (0)