diff --git a/composer.json b/composer.json
index e7f7d6c..299266b 100644
--- a/composer.json
+++ b/composer.json
@@ -30,7 +30,7 @@
"require-dev": {
"phpunit/phpunit": "~8.0",
"ockcyp/covers-validator": "^1.3.3",
- "mediawiki/mediawiki-codesniffer": "^34"
+ "mediawiki/mediawiki-codesniffer": "45.0.0"
},
"extra": {
"branch-alias": {
@@ -67,5 +67,10 @@
"@cs",
"@test"
]
+ },
+ "config": {
+ "allow-plugins": {
+ "dealerdirect/phpcodesniffer-composer-installer": true
+ }
}
}
diff --git a/phpcs.xml b/phpcs.xml
index 8649f80..52b4a07 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -7,4 +7,5 @@
+
diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php
index 03eb876..e331064 100644
--- a/src/DataValues/MonolingualTextValue.php
+++ b/src/DataValues/MonolingualTextValue.php
@@ -65,7 +65,7 @@ public function unserialize( $value ) {
}
public function __unserialize( array $data ): void {
- list( $languageCode, $text ) = $data;
+ [ $languageCode, $text ] = $data;
$this->__construct( $languageCode, $text );
}
diff --git a/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php b/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php
index 549c79d..1c25dec 100644
--- a/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php
+++ b/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php
@@ -36,7 +36,7 @@ public function __construct(
$expectedValueType,
$dataValueType,
$message = '',
- Exception $previous = null
+ ?Exception $previous = null
) {
$this->expectedValueType = $expectedValueType;
$this->dataValueType = $dataValueType;
diff --git a/src/ValueParsers/BoolParser.php b/src/ValueParsers/BoolParser.php
index 5583073..99faf7f 100644
--- a/src/ValueParsers/BoolParser.php
+++ b/src/ValueParsers/BoolParser.php
@@ -18,6 +18,10 @@ class BoolParser extends StringValueParser {
private const FORMAT_NAME = 'bool';
+ /**
+ * @var Mapping from possible string values to their
+ * boolean equivalents
+ */
private static $values = [
'yes' => true,
'on' => true,
diff --git a/src/ValueParsers/StringParser.php b/src/ValueParsers/StringParser.php
index 3efb4bf..4827694 100644
--- a/src/ValueParsers/StringParser.php
+++ b/src/ValueParsers/StringParser.php
@@ -26,7 +26,7 @@ class StringParser implements ValueParser {
/**
* @param StringNormalizer|null $normalizer
*/
- public function __construct( StringNormalizer $normalizer = null ) {
+ public function __construct( ?StringNormalizer $normalizer = null ) {
$this->normalizer = $normalizer ?: new NullStringNormalizer();
}
diff --git a/src/ValueParsers/StringValueParser.php b/src/ValueParsers/StringValueParser.php
index c80e3c3..ac638c0 100644
--- a/src/ValueParsers/StringValueParser.php
+++ b/src/ValueParsers/StringValueParser.php
@@ -28,7 +28,7 @@ abstract class StringValueParser implements ValueParser {
/**
* @param ParserOptions|null $options
*/
- public function __construct( ParserOptions $options = null ) {
+ public function __construct( ?ParserOptions $options = null ) {
$this->options = $options ?: new ParserOptions();
$this->defaultOption( ValueParser::OPT_LANG, 'en' );
diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php
index 0a547a7..7d42056 100644
--- a/tests/ValueParsers/DispatchingValueParserTest.php
+++ b/tests/ValueParsers/DispatchingValueParserTest.php
@@ -22,17 +22,17 @@
*/
class DispatchingValueParserTest extends TestCase {
- private function getParser( $invocation ) : ValueParser {
+ private function getParser( $invocation ): ValueParser {
$mock = $this->createMock( ValueParser::class );
$mock->expects( $invocation )
->method( 'parse' )
- ->will( $this->returnCallback( function( $value ) {
+ ->willReturnCallback( static function ( $value ) {
if ( $value === 'invalid' ) {
throw new ParseException( 'failed' );
}
return $value;
- } ) );
+ } );
return $mock;
}
diff --git a/tests/ValueParsers/NullParserTest.php b/tests/ValueParsers/NullParserTest.php
index 68a2af5..1f1573e 100644
--- a/tests/ValueParsers/NullParserTest.php
+++ b/tests/ValueParsers/NullParserTest.php
@@ -55,7 +55,7 @@ public function invalidInputProvider() {
*
* @dataProvider invalidInputProvider
*/
- public function testParseWithInvalidInputs( $value, ValueParser $parser = null ) {
+ public function testParseWithInvalidInputs( $value, ?ValueParser $parser = null ) {
$this->markTestSkipped( 'NullParser has no invalid inputs' );
}
diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php
index 410f2d4..c707846 100644
--- a/tests/ValueParsers/StringParserTest.php
+++ b/tests/ValueParsers/StringParserTest.php
@@ -26,9 +26,9 @@ public function provideParse() {
$normalizer = $this->createMock( StringNormalizer::class );
$normalizer->expects( $this->once() )
->method( 'normalize' )
- ->will( $this->returnCallback( function( $value ) {
+ ->willReturnCallback( static function ( $value ) {
return strtolower( trim( $value ) );
- } ) );
+ } );
return [
'simple' => [ 'hello world', null, new StringValue( 'hello world' ) ],
diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php
index 6e57c32..cf5fdd9 100644
--- a/tests/ValueParsers/ValueParserTestBase.php
+++ b/tests/ValueParsers/ValueParserTestBase.php
@@ -44,7 +44,7 @@ abstract protected function getInstance();
* @param mixed $expected
* @param ValueParser|null $parser
*/
- public function testParseWithValidInputs( $value, $expected, ValueParser $parser = null ) {
+ public function testParseWithValidInputs( $value, $expected, ?ValueParser $parser = null ) {
if ( $parser === null ) {
$parser = $this->getInstance();
}
@@ -77,7 +77,7 @@ private function assertSmartEquals( $expected, $actual ) {
* @param mixed $value
* @param ValueParser|null $parser
*/
- public function testParseWithInvalidInputs( $value, ValueParser $parser = null ) {
+ public function testParseWithInvalidInputs( $value, ?ValueParser $parser = null ) {
if ( $parser === null ) {
$parser = $this->getInstance();
}