Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
fail-fast: false
matrix:
php:
- '7.2'
- '7.3'
- '7.4'

steps:
Expand Down
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"irc": "irc://irc.freenode.net/wikidata"
},
"require": {
"php": ">=7.2.0",
"php": ">=7.4",
"data-values/data-values": "~3.0|~2.0|~1.0|~0.1",
"data-values/interfaces": "~1.0|~0.2.0"
},
"require-dev": {
"phpunit/phpunit": "~8.0",
"ockcyp/covers-validator": "^1.3.3",
"mediawiki/mediawiki-codesniffer": "^34"
"mediawiki/mediawiki-codesniffer": "^45"
},
"extra": {
"branch-alias": {
Expand Down Expand Up @@ -67,5 +67,10 @@
"@cs",
"@test"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="Generic.Files.LineLength.MaxExceeded" />
</rule>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
</ruleset>
2 changes: 1 addition & 1 deletion src/DataValues/MonolingualTextValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
$expectedValueType,
$dataValueType,
$message = '',
Exception $previous = null
?Exception $previous = null
) {
$this->expectedValueType = $expectedValueType;
$this->dataValueType = $dataValueType;
Expand Down
4 changes: 4 additions & 0 deletions src/ValueParsers/BoolParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/ValueParsers/StringParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion src/ValueParsers/StringValueParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
6 changes: 3 additions & 3 deletions tests/ValueParsers/DispatchingValueParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ValueParsers/NullParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ValueParsers/StringParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) ],
Expand Down
4 changes: 2 additions & 2 deletions tests/ValueParsers/ValueParserTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down
Loading