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 .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"irc": "irc://irc.freenode.net/wikidata"
},
"require": {
"php": ">=5.3.0",
"php": ">=5.5.9",
"data-values/data-values": "~1.0|~0.1",
"data-values/interfaces": "~0.2.0|~0.1.5"
},
Expand Down
1 change: 0 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<ruleset name="DataValuesCommon">
<!-- See https://github.com/wikimedia/mediawiki-tools-codesniffer/blob/master/MediaWiki/ruleset.xml -->
<rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="Generic.Arrays.DisallowLongArraySyntax" />
<exclude name="PSR2.Methods.MethodDeclaration" />
</rule>

Expand Down
8 changes: 4 additions & 4 deletions src/DataValues/MonolingualTextValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct( $languageCode, $text ) {
* @return string
*/
public function serialize() {
return serialize( array( $this->languageCode, $this->text ) );
return serialize( [ $this->languageCode, $this->text ] );
}

/**
Expand Down Expand Up @@ -113,10 +113,10 @@ public function getLanguageCode() {
* @return string[]
*/
public function getArrayValue() {
return array(
return [
'text' => $this->text,
'language' => $this->languageCode,
);
];
}

/**
Expand All @@ -131,7 +131,7 @@ public function getArrayValue() {
* @throws IllegalValueException
*/
public static function newFromArray( array $data ) {
self::requireArrayFields( $data, array( 'language', 'text' ) );
self::requireArrayFields( $data, [ 'language', 'text' ] );

return new static( $data['language'], $data['text'] );
}
Expand Down
6 changes: 3 additions & 3 deletions src/DataValues/MultilingualTextValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MultilingualTextValue extends DataValueObject {
*
* @var MonolingualTextValue[]
*/
private $texts = array();
private $texts = [];

/**
* @since 0.1
Expand Down Expand Up @@ -105,7 +105,7 @@ public function getValue() {
* @return mixed
*/
public function getArrayValue() {
$values = array();
$values = [];

/**
* @var MonolingualTextValue $text
Expand Down Expand Up @@ -134,7 +134,7 @@ public static function newFromArray( $data ) {
throw new IllegalValueException( "array expected" );
}

$values = array();
$values = [];

foreach ( $data as $monolingualValue ) {
$values[] = MonolingualTextValue::newFromArray( $monolingualValue );
Expand Down
4 changes: 2 additions & 2 deletions src/ValueParsers/BoolParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BoolParser extends StringValueParser {

const FORMAT_NAME = 'bool';

private static $values = array(
private static $values = [
'yes' => true,
'on' => true,
'1' => true,
Expand All @@ -25,7 +25,7 @@ class BoolParser extends StringValueParser {
'off' => false,
'0' => false,
'false' => false,
);
];

/**
* @see StringValueParser::stringParse
Expand Down
28 changes: 14 additions & 14 deletions tests/DataValues/MonolingualTextValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ public function getClass() {
}

public function validConstructorArgumentsProvider() {
$argLists = array();
$argLists = [];

$argLists[] = array( 'en', 'foo' );
$argLists[] = array( 'en', ' foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz ' );
$argLists[] = [ 'en', 'foo' ];
$argLists[] = [ 'en', ' foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz ' ];

return $argLists;
}

public function invalidConstructorArgumentsProvider() {
$argLists = array();
$argLists = [];

$argLists[] = array( 42, null );
$argLists[] = array( array(), null );
$argLists[] = array( false, null );
$argLists[] = array( true, null );
$argLists[] = array( null, null );
$argLists[] = array( 'en', 42 );
$argLists[] = array( 'en', false );
$argLists[] = array( 'en', array() );
$argLists[] = array( 'en', null );
$argLists[] = array( '', 'foo' );
$argLists[] = [ 42, null ];
$argLists[] = [ [], null ];
$argLists[] = [ false, null ];
$argLists[] = [ true, null ];
$argLists[] = [ null, null ];
$argLists[] = [ 'en', 42 ];
$argLists[] = [ 'en', false ];
$argLists[] = [ 'en', [] ];
$argLists[] = [ 'en', null ];
$argLists[] = [ '', 'foo' ];

return $argLists;
}
Expand Down
52 changes: 26 additions & 26 deletions tests/DataValues/MultilingualTextValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,40 @@ public function getClass() {
}

public function validConstructorArgumentsProvider() {
$argLists = array();
$argLists = [];

$argLists[] = array( array() );
$argLists[] = array( array( new MonolingualTextValue( 'en', 'foo' ) ) );
$argLists[] = array( array( new MonolingualTextValue( 'en', 'foo' ), new MonolingualTextValue( 'de', 'foo' ) ) );
$argLists[] = array( array( new MonolingualTextValue( 'en', 'foo' ), new MonolingualTextValue( 'de', 'bar' ) ) );
$argLists[] = array( array(
$argLists[] = [ [] ];
$argLists[] = [ [ new MonolingualTextValue( 'en', 'foo' ) ] ];
$argLists[] = [ [ new MonolingualTextValue( 'en', 'foo' ), new MonolingualTextValue( 'de', 'foo' ) ] ];
$argLists[] = [ [ new MonolingualTextValue( 'en', 'foo' ), new MonolingualTextValue( 'de', 'bar' ) ] ];
$argLists[] = [ [
new MonolingualTextValue( 'en', 'foo' ),
new MonolingualTextValue( 'de', ' foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz ' )
) );
] ];

return $argLists;
}

public function invalidConstructorArgumentsProvider() {
$argLists = array();

$argLists[] = array( array( 42 ) );
$argLists[] = array( array( false ) );
$argLists[] = array( array( true ) );
$argLists[] = array( array( null ) );
$argLists[] = array( array( array() ) );
$argLists[] = array( array( 'foo' ) );

$argLists[] = array( array( 42 => 'foo' ) );
$argLists[] = array( array( '' => 'foo' ) );
$argLists[] = array( array( 'en' => 42 ) );
$argLists[] = array( array( 'en' => null ) );
$argLists[] = array( array( 'en' => true ) );
$argLists[] = array( array( 'en' => array() ) );
$argLists[] = array( array( 'en' => 4.2 ) );

$argLists[] = array( array( new MonolingualTextValue( 'en', 'foo' ), false ) );
$argLists[] = array( array( new MonolingualTextValue( 'en', 'foo' ), 'foobar' ) );
$argLists = [];

$argLists[] = [ [ 42 ] ];
$argLists[] = [ [ false ] ];
$argLists[] = [ [ true ] ];
$argLists[] = [ [ null ] ];
$argLists[] = [ [ [] ] ];
$argLists[] = [ [ 'foo' ] ];

$argLists[] = [ [ 42 => 'foo' ] ];
$argLists[] = [ [ '' => 'foo' ] ];
$argLists[] = [ [ 'en' => 42 ] ];
$argLists[] = [ [ 'en' => null ] ];
$argLists[] = [ [ 'en' => true ] ];
$argLists[] = [ [ 'en' => [] ] ];
$argLists[] = [ [ 'en' => 4.2 ] ];

$argLists[] = [ [ new MonolingualTextValue( 'en', 'foo' ), false ] ];
$argLists[] = [ [ new MonolingualTextValue( 'en', 'foo' ), 'foobar' ] ];

return $argLists;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public function testConstructorWithAllArguments( $expectedType, $actualType ) {
}

public function constructorProvider() {
return array(
array( 'string', 'time' ),
array( 'globecoordinate', 'string' )
);
return [
[ 'string', 'time' ],
[ 'globecoordinate', 'string' ]
];
}

}
8 changes: 4 additions & 4 deletions tests/ValueFormatters/StringFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ protected function getInstance( FormatterOptions $options = null ) {
* @see ValueFormatterTestBase::validProvider
*/
public function validProvider() {
$strings = array(
$strings = [
'ice cream',
'cake',
'',
' a ',
' ',
);
];

$argLists = array();
$argLists = [];

foreach ( $strings as $string ) {
$argLists[] = array( new StringValue( $string ), $string );
$argLists[] = [ new StringValue( $string ), $string ];
}

return $argLists;
Expand Down
14 changes: 7 additions & 7 deletions tests/ValueParsers/BoolParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ protected function getInstance() {
* @see ValueParserTestBase::validInputProvider
*/
public function validInputProvider() {
$argLists = array();
$argLists = [];

$valid = array(
$valid = [
'yes' => true,
'on' => true,
'1' => true,
Expand All @@ -45,11 +45,11 @@ public function validInputProvider() {
'ON' => true,
'No' => false,
'OfF' => false,
);
];

foreach ( $valid as $value => $expected ) {
$expected = new BooleanValue( $expected );
$argLists[] = array( (string)$value, $expected );
$argLists[] = [ (string)$value, $expected ];
}

return $argLists;
Expand All @@ -61,13 +61,13 @@ public function validInputProvider() {
public function invalidInputProvider() {
$argLists = parent::invalidInputProvider();

$invalid = array(
$invalid = [
'foo',
'2',
);
];

foreach ( $invalid as $value ) {
$argLists[] = array( $value );
$argLists[] = [ $value ];
}

return $argLists;
Expand Down
22 changes: 11 additions & 11 deletions tests/ValueParsers/DispatchingValueParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,23 @@ public function testGivenInvalidConstructorArguments_constructorThrowsException(
}

public function invalidConstructorArgumentsProvider() {
$parsers = array(
$parsers = [
$this->getParser( $this->never() ),
);
];

return array(
array( array(), 'format' ),
array( $parsers, null ),
array( $parsers, '' ),
);
return [
[ [], 'format' ],
[ $parsers, null ],
[ $parsers, '' ],
];
}

public function testParse() {
$parser = new DispatchingValueParser(
array(
[
$this->getParser( $this->once() ),
$this->getParser( $this->never() ),
),
],
'format'
);

Expand All @@ -75,9 +75,9 @@ public function testParse() {

public function testParseThrowsException() {
$parser = new DispatchingValueParser(
array(
[
$this->getParser( $this->once() ),
),
],
'format'
);

Expand Down
14 changes: 7 additions & 7 deletions tests/ValueParsers/FloatParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ protected function getInstance() {
* @see ValueParserTestBase::validInputProvider
*/
public function validInputProvider() {
$argLists = array();
$argLists = [];

$valid = array(
$valid = [
// Ignoring a single trailing newline is an intended PCRE feature
"0\n" => 0,

Expand All @@ -50,7 +50,7 @@ public function validInputProvider() {
'90.01' => 90.01,
'-1.0' => -1,
'-4.2' => -4.2,
);
];

foreach ( $valid as $value => $expected ) {
// Because PHP turns them into ints/floats using black magic
Expand All @@ -60,7 +60,7 @@ public function validInputProvider() {
$expected = (float)$expected;

$expected = new NumberValue( $expected );
$argLists[] = array( $value, $expected );
$argLists[] = [ $value, $expected ];
}

return $argLists;
Expand All @@ -72,7 +72,7 @@ public function validInputProvider() {
public function invalidInputProvider() {
$argLists = parent::invalidInputProvider();

$invalid = array(
$invalid = [
// Trimming is currently not supported
' 0 ',

Expand All @@ -90,10 +90,10 @@ public function invalidInputProvider() {
'1+1',
'1-1',
'1.2.3',
);
];

foreach ( $invalid as $value ) {
$argLists[] = array( $value );
$argLists[] = [ $value ];
}

return $argLists;
Expand Down
Loading