From 13ac281175b5b0c30747beed52759105ceb3bf8d Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 4 Aug 2017 00:46:08 +0900 Subject: [PATCH 01/70] Add .editorconfig (#69) Add .editorconfig --- .editorconfig | 10 ++++++++++ .gitattributes | 1 + 2 files changed, 11 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9934e81 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true + +[*.php] +indent_style = tab +indent_size = 8 diff --git a/.gitattributes b/.gitattributes index e8ad548..dcd303f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ +.editorconfig export-ignore .gitattributes export-ignore .gitignore export-ignore .scrutinizer.yml export-ignore From 8ae8c2af7a323d4ee094bd1db14f2417720c3fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Thu, 3 Aug 2017 17:49:49 +0200 Subject: [PATCH 02/70] Update .editorconfig --- .editorconfig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9934e81..db9cba3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,10 +1,16 @@ +# http://editorconfig.org root = true [*] charset = utf-8 +indent_style = tab +indent_size = 4 end_of_line = lf +trim_trailing_whitespace = true insert_final_newline = true [*.php] -indent_style = tab -indent_size = 8 +quote_type = single +spaces_around_operators = true +spaces_around_brackets = inside +indent_brace_style = K&R From c98cb31b60cede60bfc839428d0e3af08549411e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Wed, 9 Aug 2017 13:58:35 -0400 Subject: [PATCH 03/70] Added missing 0.4.0 release notes --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index c130d5b..c07e074 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,14 @@ employees for the [Wikidata project](https://wikidata.org/). ## Release notes +### 0.4.0 (2017-08-09) + +* Deprecated `newFromArray` in `MonolingualTextValue` and `MultilingualTextValue`. +* Changed `MismatchingDataValueTypeException` not amending custom messages any more. +* Updated inline documentation throughout the code. +* Updated the MediaWiki entry point to use the extension.json format. +* Updated minimal required PHP version from 5.3 to 5.5.9. + ### 0.3.1 (2015-08-14) * The component can now be installed together with DataValues Interfaces 0.1.5 From 39f2a7cd54c6452759910fb8c3e5c53188983a8d Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Wed, 9 Aug 2017 14:01:31 -0400 Subject: [PATCH 04/70] Remove MediaWiki integration (#71) --- Common.php | 4 ---- mediawiki-extension.json | 13 ------------- 2 files changed, 17 deletions(-) delete mode 100644 mediawiki-extension.json diff --git a/Common.php b/Common.php index 4302be8..060efec 100644 --- a/Common.php +++ b/Common.php @@ -16,7 +16,3 @@ } define( 'DATAVALUES_COMMON_VERSION', '0.3.1' ); - -if ( defined( 'MEDIAWIKI' ) && function_exists( 'wfLoadExtension' ) ) { - wfLoadExtension( 'DataValuesCommon', __DIR__ . '/mediawiki-extension.json' ); -} diff --git a/mediawiki-extension.json b/mediawiki-extension.json deleted file mode 100644 index 8e5099a..0000000 --- a/mediawiki-extension.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "DataValues Common", - "version": "0.3.1", - "author": [ - "[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]" - ], - "url": "https://github.com/DataValues/Common", - "description": "Contains common implementations of the interfaces defined by DataValuesInterfaces", - "license-name": "GPL-2.0+", - "type": "datavalues", - "load_composer_autoloader": true, - "manifest_version": 1 -} From 16c325478707fb3aa9bb3ee7d0e24319cd1fc34c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Thu, 18 Feb 2016 13:11:52 +0100 Subject: [PATCH 05/70] Add missing tests and simplify providers --- tests/DataValues/MonolingualTextValueTest.php | 64 ++++++--- .../DataValues/MultilingualTextValueTest.php | 124 +++++++++++++----- tests/ValueFormatters/StringFormatterTest.php | 33 +++-- tests/ValueParsers/BoolParserTest.php | 36 ++--- tests/ValueParsers/FloatParserTest.php | 52 +++----- tests/ValueParsers/IntParserTest.php | 29 ++-- tests/ValueParsers/NullParserTest.php | 33 ++--- tests/ValueParsers/StringValueParserTest.php | 14 +- 8 files changed, 208 insertions(+), 177 deletions(-) diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index 6687e47..b2913bc 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -27,35 +27,59 @@ public function getClass() { } public function validConstructorArgumentsProvider() { - $argLists = []; + return [ + [ 'en', 'foo' ], + [ '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 ' ]; + public function invalidConstructorArgumentsProvider() { + return [ + [ 42, null ], + [ [], null ], + [ false, null ], + [ true, null ], + [ null, null ], + [ 'en', 42 ], + [ 'en', false ], + [ 'en', [] ], + [ 'en', null ], + [ '', 'foo' ], + ]; + } - return $argLists; + public function testNewFromArray() { + $array = [ 'text' => 'foo', 'language' => 'en' ]; + $value = MonolingualTextValue::newFromArray( $array ); + $this->assertSame( $array, $value->getArrayValue() ); } - public function invalidConstructorArgumentsProvider() { - $argLists = []; + /** + * @dataProvider invalidArrayProvider + */ + public function testNewFromArrayWithInvalidArray( array $array ) { + $this->setExpectedException( 'DataValues\IllegalValueException' ); + MonolingualTextValue::newFromArray( $array ); + } - $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' ]; + public function invalidArrayProvider() { + return [ + [ [] ], + [ [ null ] ], + [ [ '' ] ], + [ [ 'en', 'foo' ] ], + [ [ 'language' => 'en' ] ], + [ [ 'text' => 'foo' ] ], + ]; + } - return $argLists; + public function testGetSortKey() { + $value = new MonolingualTextValue( 'en', 'foo' ); + $this->assertSame( 'enfoo', $value->getSortKey() ); } /** * @dataProvider instanceProvider - * @param MonolingualTextValue $text - * @param array $arguments */ public function testGetText( MonolingualTextValue $text, array $arguments ) { $this->assertEquals( $arguments[1], $text->getText() ); @@ -63,8 +87,6 @@ public function testGetText( MonolingualTextValue $text, array $arguments ) { /** * @dataProvider instanceProvider - * @param MonolingualTextValue $text - * @param array $arguments */ public function testGetLanguageCode( MonolingualTextValue $text, array $arguments ) { $this->assertEquals( $arguments[0], $text->getLanguageCode() ); diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index de19748..20a86e7 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -28,42 +28,100 @@ public function getClass() { } public function validConstructorArgumentsProvider() { - $argLists = []; - - $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; + return [ + [ [] ], + [ [ + new MonolingualTextValue( 'en', 'foo' ), + ] ], + [ [ + new MonolingualTextValue( 'en', 'foo' ), + new MonolingualTextValue( 'de', 'foo' ), + ] ], + [ [ + new MonolingualTextValue( 'en', 'foo' ), + new MonolingualTextValue( 'de', 'bar' ), + ] ], + [ [ + 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 ' ), + ] ], + ]; } public function invalidConstructorArgumentsProvider() { - $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; + return [ + [ [ 42 ] ], + [ [ false ] ], + [ [ true ] ], + [ [ null ] ], + [ [ [] ] ], + [ [ 'foo' ] ], + + [ [ 42 => 'foo' ] ], + [ [ '' => 'foo' ] ], + [ [ 'en' => 42 ] ], + [ [ 'en' => null ] ], + [ [ 'en' => true ] ], + [ [ 'en' => [] ] ], + [ [ 'en' => 4.2 ] ], + + [ [ + new MonolingualTextValue( 'en', 'foo' ), + false, + ] ], + [ [ + new MonolingualTextValue( 'en', 'foo' ), + 'foobar', + ] ], + [ [ + new MonolingualTextValue( 'en', 'foo' ), + new MonolingualTextValue( 'en', 'bar' ), + ] ], + ]; + } + + public function testNewFromArray() { + $array = [ [ 'text' => 'foo', 'language' => 'en' ] ]; + $value = MultilingualTextValue::newFromArray( $array ); + $this->assertSame( $array, $value->getArrayValue() ); + } + + /** + * @dataProvider invalidArrayProvider + */ + public function testNewFromArrayWithInvalidArray( array $array ) { + $this->setExpectedException( 'DataValues\IllegalValueException' ); + MultilingualTextValue::newFromArray( $array ); + } + + public function invalidArrayProvider() { + return [ + [ [ null ] ], + [ [ '' ] ], + [ [ [] ] ], + [ [ [ 'en', 'foo' ] ] ], + ]; + } + + /** + * @dataProvider getSortKeyProvider + */ + public function testGetSortKey( array $monolingualValues, $expected ) { + $value = new MultilingualTextValue( $monolingualValues ); + $this->assertSame( $expected, $value->getSortKey() ); + } + + public function getSortKeyProvider() { + return [ + [ [], '' ], + [ [ + new MonolingualTextValue( 'en', 'foo' ), + ], 'enfoo' ], + [ [ + new MonolingualTextValue( 'en', 'foo' ), + new MonolingualTextValue( 'de', 'bar' ), + ], 'enfoo' ], + ]; } /** diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index d66d710..a06ee61 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -39,21 +39,30 @@ protected function getInstance( FormatterOptions $options = null ) { * @see ValueFormatterTestBase::validProvider */ public function validProvider() { - $strings = [ - 'ice cream', - 'cake', - '', - ' a ', - ' ', + return [ + [ new StringValue( 'ice cream' ), 'ice cream' ], + [ new StringValue( 'cake' ), 'cake' ], + [ new StringValue( '' ), '' ], + [ new StringValue( ' a ' ), ' a ' ], + [ new StringValue( ' ' ), ' ' ], ]; + } - $argLists = []; - - foreach ( $strings as $string ) { - $argLists[] = [ new StringValue( $string ), $string ]; - } + /** + * @dataProvider invalidProvider + */ + public function testInvalidFormat( $value ) { + $formatter = new StringFormatter(); + $this->setExpectedException( 'InvalidArgumentException' ); + $formatter->format( $value ); + } - return $argLists; + public function invalidProvider() { + return [ + [ null ], + [ 0 ], + [ '' ], + ]; } } diff --git a/tests/ValueParsers/BoolParserTest.php b/tests/ValueParsers/BoolParserTest.php index ea06387..e365c76 100644 --- a/tests/ValueParsers/BoolParserTest.php +++ b/tests/ValueParsers/BoolParserTest.php @@ -7,6 +7,7 @@ /** * @covers ValueParsers\BoolParser + * @covers ValueParsers\StringValueParser * * @group ValueParsers * @group DataValueExtensions @@ -29,30 +30,21 @@ protected function getInstance() { * @see ValueParserTestBase::validInputProvider */ public function validInputProvider() { - $argLists = []; + return [ + [ 'yes', new BooleanValue( true ) ], + [ 'on', new BooleanValue( true ) ], + [ '1', new BooleanValue( true ) ], + [ 'true', new BooleanValue( true ) ], + [ 'no', new BooleanValue( false ) ], + [ 'off', new BooleanValue( false ) ], + [ '0', new BooleanValue( false ) ], + [ 'false', new BooleanValue( false ) ], - $valid = [ - 'yes' => true, - 'on' => true, - '1' => true, - 'true' => true, - 'no' => false, - 'off' => false, - '0' => false, - 'false' => false, - - 'YeS' => true, - 'ON' => true, - 'No' => false, - 'OfF' => false, + [ 'YeS', new BooleanValue( true ) ], + [ 'ON', new BooleanValue( true ) ], + [ 'No', new BooleanValue( false ) ], + [ 'OfF', new BooleanValue( false ) ], ]; - - foreach ( $valid as $value => $expected ) { - $expected = new BooleanValue( $expected ); - $argLists[] = [ (string)$value, $expected ]; - } - - return $argLists; } /** diff --git a/tests/ValueParsers/FloatParserTest.php b/tests/ValueParsers/FloatParserTest.php index b3ef453..c89d906 100644 --- a/tests/ValueParsers/FloatParserTest.php +++ b/tests/ValueParsers/FloatParserTest.php @@ -7,6 +7,7 @@ /** * @covers ValueParsers\FloatParser + * @covers ValueParsers\StringValueParser * * @group ValueParsers * @group DataValueExtensions @@ -29,41 +30,26 @@ protected function getInstance() { * @see ValueParserTestBase::validInputProvider */ public function validInputProvider() { - $argLists = []; - - $valid = [ + return [ // Ignoring a single trailing newline is an intended PCRE feature - "0\n" => 0, - - '0' => 0, - '1' => 1, - '42' => 42, - '01' => 01, - '9001' => 9001, - '-1' => -1, - '-42' => -42, - - '0.0' => 0, - '1.0' => 1, - '4.2' => 4.2, - '0.1' => 0.1, - '90.01' => 90.01, - '-1.0' => -1, - '-4.2' => -4.2, + [ "0\n", new NumberValue( 0.0 ) ], + + [ '0', new NumberValue( 0.0 ) ], + [ '1', new NumberValue( 1.0 ) ], + [ '42', new NumberValue( 42.0 ) ], + [ '01', new NumberValue( 1.0 ) ], + [ '9001', new NumberValue( 9001.0 ) ], + [ '-1', new NumberValue( -1.0 ) ], + [ '-42', new NumberValue( -42.0 ) ], + + [ '0.0', new NumberValue( 0.0 ) ], + [ '1.0', new NumberValue( 1.0 ) ], + [ '4.2', new NumberValue( 4.2 ) ], + [ '0.1', new NumberValue( 0.1 ) ], + [ '90.01', new NumberValue( 90.01 ) ], + [ '-1.0', new NumberValue( -1.0 ) ], + [ '-4.2', new NumberValue( -4.2 ) ], ]; - - foreach ( $valid as $value => $expected ) { - // Because PHP turns them into ints/floats using black magic - $value = (string)$value; - - // Because 1 is an int but will come out as a float - $expected = (float)$expected; - - $expected = new NumberValue( $expected ); - $argLists[] = [ $value, $expected ]; - } - - return $argLists; } /** diff --git a/tests/ValueParsers/IntParserTest.php b/tests/ValueParsers/IntParserTest.php index 3b6c608..eab8d89 100644 --- a/tests/ValueParsers/IntParserTest.php +++ b/tests/ValueParsers/IntParserTest.php @@ -7,6 +7,7 @@ /** * @covers ValueParsers\IntParser + * @covers ValueParsers\StringValueParser * * @group ValueParsers * @group DataValueExtensions @@ -29,27 +30,15 @@ protected function getInstance() { * @see ValueParserTestBase::validInputProvider */ public function validInputProvider() { - $argLists = []; - - $valid = [ - '0' => 0, - '1' => 1, - '42' => 42, - '01' => 01, - '9001' => 9001, - '-1' => -1, - '-42' => -42, + return [ + [ '0', new NumberValue( 0 ) ], + [ '1', new NumberValue( 1 ) ], + [ '42', new NumberValue( 42 ) ], + [ '01', new NumberValue( 01 ) ], + [ '9001', new NumberValue( 9001 ) ], + [ '-1', new NumberValue( -1 ) ], + [ '-42', new NumberValue( -42 ) ], ]; - - foreach ( $valid as $value => $expected ) { - // Because PHP turns them into ints using black magic - $value = (string)$value; - - $expected = new NumberValue( $expected ); - $argLists[] = [ $value, $expected ]; - } - - return $argLists; } /** diff --git a/tests/ValueParsers/NullParserTest.php b/tests/ValueParsers/NullParserTest.php index ed1372a..fbea499 100644 --- a/tests/ValueParsers/NullParserTest.php +++ b/tests/ValueParsers/NullParserTest.php @@ -30,43 +30,28 @@ protected function getInstance() { * @see ValueParserTestBase::validInputProvider */ public function validInputProvider() { - $argLists = []; - - $values = [ - '42', - 42, - false, - [], - 'ohi there!', - null, - 4.2, + return [ + [ '42', new UnknownValue( '42' ) ], + [ 42, new UnknownValue( 42 ) ], + [ false, new UnknownValue( false ) ], + [ [], new UnknownValue( [] ) ], + [ 'ohi there!', new UnknownValue( 'ohi there!' ) ], + [ null, new UnknownValue( null ) ], + [ 4.2, new UnknownValue( 4.2 ) ], ]; - - foreach ( $values as $value ) { - $argLists[] = [ - $value, - new UnknownValue( $value ) - ]; - } - - return $argLists; } /** * @see ValueParserTestBase::invalidInputProvider */ public function invalidInputProvider() { - return [ - [ null ] - ]; + return [ [ null ] ]; } /** * @see ValueParserTestBase::testParseWithInvalidInputs * * @dataProvider invalidInputProvider - * @param mixed $value - * @param ValueParser|null $parser */ public function testParseWithInvalidInputs( $value, ValueParser $parser = null ) { $this->markTestSkipped( 'NullParser has no invalid inputs' ); diff --git a/tests/ValueParsers/StringValueParserTest.php b/tests/ValueParsers/StringValueParserTest.php index 331250a..f07b8a4 100644 --- a/tests/ValueParsers/StringValueParserTest.php +++ b/tests/ValueParsers/StringValueParserTest.php @@ -33,21 +33,11 @@ public function invalidInputProvider() { } public function testSetAndGetOptions() { - /** - * @var StringValueParser $parser - */ + /** @var StringValueParser $parser */ $parser = $this->getInstance(); - - $parser->setOptions( new ParserOptions() ); - - $this->assertEquals( new ParserOptions(), $parser->getOptions() ); - $options = new ParserOptions(); - $options->setOption( '~=[,,_,,]:3', '~=[,,_,,]:3' ); - $parser->setOptions( $options ); - - $this->assertEquals( $options, $parser->getOptions() ); + $this->assertSame( $options, $parser->getOptions() ); } } From a8c5b87ee608093b7bf46150ebf5a226b21ae71a Mon Sep 17 00:00:00 2001 From: addshore Date: Wed, 9 Aug 2017 14:16:32 -0400 Subject: [PATCH 06/70] Update version number to 0.4.1 --- Common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common.php b/Common.php index 060efec..92efd45 100644 --- a/Common.php +++ b/Common.php @@ -15,4 +15,4 @@ return 1; } -define( 'DATAVALUES_COMMON_VERSION', '0.3.1' ); +define( 'DATAVALUES_COMMON_VERSION', '0.4.1' ); From f51a57d40823af90f7109373a8f856890d25d6de Mon Sep 17 00:00:00 2001 From: addshore Date: Wed, 9 Aug 2017 14:21:28 -0400 Subject: [PATCH 07/70] Revert "Update version number to 0.4.1" This reverts commit a8c5b87ee608093b7bf46150ebf5a226b21ae71a. --- Common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common.php b/Common.php index 92efd45..060efec 100644 --- a/Common.php +++ b/Common.php @@ -15,4 +15,4 @@ return 1; } -define( 'DATAVALUES_COMMON_VERSION', '0.4.1' ); +define( 'DATAVALUES_COMMON_VERSION', '0.3.1' ); From 21e7adcbeb66051d5a17b17cd1dca46a4200c32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Wed, 2 Aug 2017 14:41:47 +0200 Subject: [PATCH 08/70] Release 1.0.0 --- Common.php | 2 +- README.md | 18 +++++++++++++----- composer.json | 12 ++++++------ phpcs.xml | 6 +++--- src/DataValues/MonolingualTextValue.php | 2 +- src/DataValues/MultilingualTextValue.php | 2 +- src/ValueParsers/StringValueParser.php | 8 ++++---- tests/ValueFormatters/StringFormatterTest.php | 7 ------- tests/ValueParsers/StringValueParserTest.php | 4 +--- tests/ValueParsers/ValueParserTestBase.php | 6 +++--- 10 files changed, 33 insertions(+), 34 deletions(-) diff --git a/Common.php b/Common.php index 060efec..58ca463 100644 --- a/Common.php +++ b/Common.php @@ -15,4 +15,4 @@ return 1; } -define( 'DATAVALUES_COMMON_VERSION', '0.3.1' ); +define( 'DATAVALUES_COMMON_VERSION', '1.0.0' ); diff --git a/README.md b/README.md index c07e074..f1939b9 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ The recommended way to use this library is via [Composer](http://getcomposer.org To add this package as a local, per-project dependency to your project, simply add a dependency on `data-values/common` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on -version 0.3 of this package: +version 1.0 of this package: { "require": { - "data-values/common": "0.3.*" + "data-values/common": "^1.0.0" } } @@ -55,13 +55,21 @@ employees for the [Wikidata project](https://wikidata.org/). ## Release notes -### 0.4.0 (2017-08-09) +### 1.0.0 (dev) * Deprecated `newFromArray` in `MonolingualTextValue` and `MultilingualTextValue`. * Changed `MismatchingDataValueTypeException` not amending custom messages any more. -* Updated inline documentation throughout the code. -* Updated the MediaWiki entry point to use the extension.json format. +* Dropped backwards compatibility with DataValues Interfaces 0.1. * Updated minimal required PHP version from 5.3 to 5.5.9. +* Updated inline documentation throughout the code. + +### 0.4.1 (2017-08-09) + +* Fixed version number not updated before. + +### 0.4.0 (2017-08-09) + +* Removed MediaWiki integration ### 0.3.1 (2015-08-14) diff --git a/composer.json b/composer.json index 302e06f..6364867 100644 --- a/composer.json +++ b/composer.json @@ -25,16 +25,16 @@ "require": { "php": ">=5.5.9", "data-values/data-values": "~1.0|~0.1", - "data-values/interfaces": "~0.2.0|~0.1.5" + "data-values/interfaces": "~0.2.0" }, "require-dev": { - "phpunit/phpunit": "~4.8", "ockcyp/covers-validator": "~0.4", + "phpunit/phpunit": "~4.8", "wikibase/wikibase-codesniffer": "^0.1.0" }, "extra": { "branch-alias": { - "dev-master": "0.3.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { @@ -52,7 +52,7 @@ }, "scripts": { "cs": [ - "phpcs src/* tests/* --standard=phpcs.xml -sp" + "phpcs -p -s" ], "test": [ "@validate --no-interaction", @@ -60,8 +60,8 @@ "phpunit" ], "ci": [ - "@test", - "@cs" + "@cs", + "@test" ] } } diff --git a/phpcs.xml b/phpcs.xml index 033a4eb..ac20681 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,12 +1,12 @@ - - - + + + . diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index e5a280e..5cf35fc 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -117,7 +117,7 @@ public function getArrayValue() { * Constructs a new instance from the provided data. Required for @see DataValueDeserializer. * This is expected to round-trip with @see getArrayValue. * - * @deprecated since 0.3.2. Static DataValue::newFromArray constructors like this are + * @deprecated since 1.0.0. Static DataValue::newFromArray constructors like this are * underspecified (not in the DataValue interface), and misleadingly named (should be named * newFromArrayValue). Instead, use DataValue builder callbacks in @see DataValueDeserializer. * diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index 46bcc54..864ed90 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -117,7 +117,7 @@ public function getArrayValue() { * Constructs a new instance from the provided data. Required for @see DataValueDeserializer. * This is expected to round-trip with @see getArrayValue. * - * @deprecated since 0.3.2. Static DataValue::newFromArray constructors like this are + * @deprecated since 1.0.0. Static DataValue::newFromArray constructors like this are * underspecified (not in the DataValue interface), and misleadingly named (should be named * newFromArrayValue). Instead, use DataValue builder callbacks in @see DataValueDeserializer. * diff --git a/src/ValueParsers/StringValueParser.php b/src/ValueParsers/StringValueParser.php index 7176a74..a93c5f4 100644 --- a/src/ValueParsers/StringValueParser.php +++ b/src/ValueParsers/StringValueParser.php @@ -58,7 +58,7 @@ public function parse( $value ) { * * @return mixed */ - protected abstract function stringParse( $value ); + abstract protected function stringParse( $value ); /** * @since 0.1 @@ -88,7 +88,7 @@ public function getOptions() { * @throws InvalidArgumentException * @return mixed */ - protected final function getOption( $option ) { + final protected function getOption( $option ) { return $this->options->getOption( $option ); } @@ -101,7 +101,7 @@ protected final function getOption( $option ) { * * @throws RuntimeException */ - protected final function requireOption( $option ) { + final protected function requireOption( $option ) { $this->options->requireOption( $option ); } @@ -113,7 +113,7 @@ protected final function requireOption( $option ) { * @param string $option * @param mixed $default */ - protected final function defaultOption( $option, $default ) { + final protected function defaultOption( $option, $default ) { $this->options->defaultOption( $option, $default ); } diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index d66d710..8a6440b 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -17,13 +17,6 @@ */ class StringFormatterTest extends ValueFormatterTestBase { - /** - * @deprecated since DataValues Interfaces 0.2, just use getInstance. - */ - protected function getFormatterClass() { - throw new \LogicException( 'Should not be called, use getInstance' ); - } - /** * @see ValueFormatterTestBase::getInstance * diff --git a/tests/ValueParsers/StringValueParserTest.php b/tests/ValueParsers/StringValueParserTest.php index 331250a..006c75b 100644 --- a/tests/ValueParsers/StringValueParserTest.php +++ b/tests/ValueParsers/StringValueParserTest.php @@ -6,9 +6,7 @@ use ValueParsers\StringValueParser; /** - * Unit test StringValueParser class. - * - * @since 0.1 + * @covers ValueParsers\StringValueParser * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php index 3646899..00a0a1d 100644 --- a/tests/ValueParsers/ValueParserTestBase.php +++ b/tests/ValueParsers/ValueParserTestBase.php @@ -25,21 +25,21 @@ abstract class ValueParserTestBase extends PHPUnit_Framework_TestCase { * * @return array[] */ - public abstract function validInputProvider(); + abstract public function validInputProvider(); /** * @since 0.1 * * @return array[] */ - public abstract function invalidInputProvider(); + abstract public function invalidInputProvider(); /** * @since 0.1 * * @return ValueParser */ - protected abstract function getInstance(); + abstract protected function getInstance(); /** * @since 0.1 From 220a31087aa5e0d5f1eff06d2ae9c5fcf4c82319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Fri, 1 Sep 2017 11:36:10 +0200 Subject: [PATCH 09/70] Remove unused options from StringFormatter --- README.md | 5 +++++ src/ValueFormatters/StringFormatter.php | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c07e074..d9246e3 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,11 @@ employees for the [Wikidata project](https://wikidata.org/). ## Release notes +### 0.5.0 (dev) + +#### Breaking changes +* The `StringFormatter` constructor does not accept options any more. + ### 0.4.0 (2017-08-09) * Deprecated `newFromArray` in `MonolingualTextValue` and `MultilingualTextValue`. diff --git a/src/ValueFormatters/StringFormatter.php b/src/ValueFormatters/StringFormatter.php index 5581df6..c5ebaf9 100644 --- a/src/ValueFormatters/StringFormatter.php +++ b/src/ValueFormatters/StringFormatter.php @@ -6,14 +6,15 @@ use InvalidArgumentException; /** - * Formatter for string values + * Trivial formatter for StringValue objects that does nothing but returning the string value as it + * is. * * @since 0.1 * * @license GPL-2.0+ * @author Katie Filbert < aude.wiki@gmail.com > */ -class StringFormatter extends ValueFormatterBase { +class StringFormatter implements ValueFormatter { /** * @see ValueFormatter::format From 384a44888cfb7f861d2a0cf2fbb129c83a6bfe41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Thu, 14 Sep 2017 11:42:10 +0200 Subject: [PATCH 10/70] Can't abbreviate composer validate as @validate --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 302e06f..caa2798 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "phpcs src/* tests/* --standard=phpcs.xml -sp" ], "test": [ - "@validate --no-interaction", + "composer validate --no-interaction", "covers-validator", "phpunit" ], From 6dc8deb4763426ce8100afa0f23566d70ca978f1 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Thu, 28 Sep 2017 08:00:50 +0200 Subject: [PATCH 11/70] Update README.md [skip ci] --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c07e074..d8ffea3 100644 --- a/README.md +++ b/README.md @@ -57,11 +57,10 @@ employees for the [Wikidata project](https://wikidata.org/). ### 0.4.0 (2017-08-09) -* Deprecated `newFromArray` in `MonolingualTextValue` and `MultilingualTextValue`. -* Changed `MismatchingDataValueTypeException` not amending custom messages any more. -* Updated inline documentation throughout the code. -* Updated the MediaWiki entry point to use the extension.json format. -* Updated minimal required PHP version from 5.3 to 5.5.9. +* Deprecated `MonolingualTextValue::newFromArray` and `MultilingualTextValue::newFromArray` +* `MismatchingDataValueTypeException` no longer modifies custom error messages in its constructor +* Updated minimal required PHP version from 5.3 to 5.5.9 +* Updated the MediaWiki entry point to use the extension.json format ### 0.3.1 (2015-08-14) From 7f2d7cb83c40fc963784fbdf02b341cfeb464074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Thu, 28 Sep 2017 11:21:38 +0200 Subject: [PATCH 12/70] Improve the abstract StringValueParser documentation --- src/ValueParsers/StringValueParser.php | 28 +++++----------------- tests/ValueParsers/ValueParserTestBase.php | 12 ---------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/src/ValueParsers/StringValueParser.php b/src/ValueParsers/StringValueParser.php index 7176a74..4bc9cfe 100644 --- a/src/ValueParsers/StringValueParser.php +++ b/src/ValueParsers/StringValueParser.php @@ -6,7 +6,10 @@ use RuntimeException; /** - * ValueParser that parses the string representation of something. + * Basic implementation for DataValue parsers that share one or more of the following aspects: + * - The provided input must be a string. + * - The parser utilizes ParserOptions. + * - The parser utilizes a "lang" option, which defaults to "en". * * @since 0.1 * @@ -16,15 +19,11 @@ abstract class StringValueParser implements ValueParser { /** - * @since 0.1 - * * @var ParserOptions */ protected $options; /** - * @since 0.1 - * * @param ParserOptions|null $options */ public function __construct( ParserOptions $options = null ) { @@ -36,10 +35,10 @@ public function __construct( ParserOptions $options = null ) { /** * @see ValueParser::parse * - * @param mixed $value + * @param string $value * * @return mixed - * @throws ParseException + * @throws ParseException if the provided value is not a string */ public function parse( $value ) { if ( is_string( $value ) ) { @@ -52,26 +51,17 @@ public function parse( $value ) { /** * Parses the provided string and returns the result. * - * @since 0.1 - * * @param string $value * * @return mixed */ protected abstract function stringParse( $value ); - /** - * @since 0.1 - * - * @param ParserOptions $options - */ public function setOptions( ParserOptions $options ) { $this->options = $options; } /** - * @since 0.1 - * * @return ParserOptions */ public function getOptions() { @@ -81,8 +71,6 @@ public function getOptions() { /** * Shortcut to $this->options->getOption. * - * @since 0.1 - * * @param string $option * * @throws InvalidArgumentException @@ -95,8 +83,6 @@ protected final function getOption( $option ) { /** * Shortcut to $this->options->requireOption. * - * @since 0.1 - * * @param string $option * * @throws RuntimeException @@ -108,8 +94,6 @@ protected final function requireOption( $option ) { /** * Shortcut to $this->options->defaultOption. * - * @since 0.1 - * * @param string $option * @param mixed $default */ diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php index 3646899..e4e8e87 100644 --- a/tests/ValueParsers/ValueParserTestBase.php +++ b/tests/ValueParsers/ValueParserTestBase.php @@ -21,29 +21,21 @@ abstract class ValueParserTestBase extends PHPUnit_Framework_TestCase { /** - * @since 0.1 - * * @return array[] */ public abstract function validInputProvider(); /** - * @since 0.1 - * * @return array[] */ public abstract function invalidInputProvider(); /** - * @since 0.1 - * * @return ValueParser */ protected abstract function getInstance(); /** - * @since 0.1 - * * @dataProvider validInputProvider * @param mixed $value * @param mixed $expected @@ -78,8 +70,6 @@ private function assertSmartEquals( $expected, $actual ) { } /** - * @since 0.1 - * * @dataProvider invalidInputProvider * @param mixed $value * @param ValueParser|null $parser @@ -96,8 +86,6 @@ public function testParseWithInvalidInputs( $value, ValueParser $parser = null ) /** * Returns if the result of the parsing process should be checked to be a DataValue. * - * @since 0.1 - * * @return bool */ protected function requireDataValue() { From b81e7851870a68a6df9160282c87d8f6077acf1f Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Thu, 28 Sep 2017 11:22:35 +0200 Subject: [PATCH 13/70] Remove version constant (#73) Remove version constant --- Common.php | 18 ------------------ README.md | 3 ++- composer.json | 3 --- 3 files changed, 2 insertions(+), 22 deletions(-) delete mode 100644 Common.php diff --git a/Common.php b/Common.php deleted file mode 100644 index 58ca463..0000000 --- a/Common.php +++ /dev/null @@ -1,18 +0,0 @@ - - */ - -if ( defined( 'DATAVALUES_COMMON_VERSION' ) ) { - // Do not initialize more than once. - return 1; -} - -define( 'DATAVALUES_COMMON_VERSION', '1.0.0' ); diff --git a/README.md b/README.md index f8291a9..97ac50c 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,8 @@ employees for the [Wikidata project](https://wikidata.org/). ### 1.0.0 (dev) -* The `StringFormatter` constructor does not accept options any more. +* Removed the `DATAVALUES_COMMON_VERSION` constant +* The `StringFormatter` constructor does not accept options any more ### 0.4.1 (2017-08-09) diff --git a/composer.json b/composer.json index 91bf2f8..0a97825 100644 --- a/composer.json +++ b/composer.json @@ -38,9 +38,6 @@ } }, "autoload": { - "files" : [ - "Common.php" - ], "psr-4": { "DataValues\\": "src/DataValues/", "ValueFormatters\\": "src/ValueFormatters/", From a5104531a9bc7ab87171beda808d4ebd36b932ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Thu, 28 Sep 2017 11:25:44 +0200 Subject: [PATCH 14/70] Fix StringParser::parse not throwing expected ParseException --- src/ValueParsers/StringParser.php | 5 ++--- tests/ValueParsers/StringParserTest.php | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ValueParsers/StringParser.php b/src/ValueParsers/StringParser.php index d07f91f..f7b408b 100644 --- a/src/ValueParsers/StringParser.php +++ b/src/ValueParsers/StringParser.php @@ -3,7 +3,6 @@ namespace ValueParsers; use DataValues\StringValue; -use InvalidArgumentException; use ValueParsers\Normalizers\NullStringNormalizer; use ValueParsers\Normalizers\StringNormalizer; @@ -34,12 +33,12 @@ public function __construct( StringNormalizer $normalizer = null ) { * * @param string $value * - * @throws InvalidArgumentException if $value is not a string + * @throws ParseException if the provided value is not a string * @return StringValue */ public function parse( $value ) { if ( !is_string( $value ) ) { - throw new InvalidArgumentException( 'Parameter $value must be a string' ); + throw new ParseException( 'Parameter $value must be a string' ); } $value = $this->normalizer->normalize( $value ); diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index 42b90bc..2a67f0a 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -5,6 +5,7 @@ use DataValues\DataValue; use DataValues\StringValue; use ValueParsers\Normalizers\StringNormalizer; +use ValueParsers\ParseException; use ValueParsers\StringParser; /** @@ -56,7 +57,7 @@ public function nonStringProvider() { */ public function testGivenNonString_parseThrowsException( $input ) { $parser = new StringParser(); - $this->setExpectedException( 'InvalidArgumentException' ); + $this->setExpectedException( ParseException::class ); $parser->parse( $input ); } From f36bfd0e88d4a3a0102a64fbc07ea958a0d0454e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Thu, 28 Sep 2017 11:48:12 +0200 Subject: [PATCH 15/70] =?UTF-8?q?Make=20use=20of=20the=20=E2=80=A6::class?= =?UTF-8?q?=20feature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/DataValues/MonolingualTextValueTest.php | 5 +++-- tests/DataValues/MultilingualTextValueTest.php | 7 ++++--- tests/ValueFormatters/StringFormatterTest.php | 3 ++- tests/ValueParsers/DispatchingValueParserTest.php | 4 ++-- .../ValueParsers/Normalizers/NullStringNormalizerTest.php | 3 ++- tests/ValueParsers/StringParserTest.php | 4 ++-- tests/ValueParsers/ValueParserTestBase.php | 3 ++- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index b2913bc..38e69fc 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -2,6 +2,7 @@ namespace DataValues\Tests; +use DataValues\IllegalValueException; use DataValues\MonolingualTextValue; /** @@ -23,7 +24,7 @@ class MonolingualTextValueTest extends DataValueTest { * @return string */ public function getClass() { - return 'DataValues\MonolingualTextValue'; + return MonolingualTextValue::class; } public function validConstructorArgumentsProvider() { @@ -58,7 +59,7 @@ public function testNewFromArray() { * @dataProvider invalidArrayProvider */ public function testNewFromArrayWithInvalidArray( array $array ) { - $this->setExpectedException( 'DataValues\IllegalValueException' ); + $this->setExpectedException( IllegalValueException::class ); MonolingualTextValue::newFromArray( $array ); } diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index 20a86e7..89f3760 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -2,6 +2,7 @@ namespace DataValues\Tests; +use DataValues\IllegalValueException; use DataValues\MonolingualTextValue; use DataValues\MultilingualTextValue; @@ -24,7 +25,7 @@ class MultilingualTextValueTest extends DataValueTest { * @return string */ public function getClass() { - return 'DataValues\MultilingualTextValue'; + return MultilingualTextValue::class; } public function validConstructorArgumentsProvider() { @@ -90,7 +91,7 @@ public function testNewFromArray() { * @dataProvider invalidArrayProvider */ public function testNewFromArrayWithInvalidArray( array $array ) { - $this->setExpectedException( 'DataValues\IllegalValueException' ); + $this->setExpectedException( IllegalValueException::class ); MultilingualTextValue::newFromArray( $array ); } @@ -131,7 +132,7 @@ public function testGetTexts( MultilingualTextValue $texts, array $arguments ) { $actual = $texts->getTexts(); $this->assertInternalType( 'array', $actual ); - $this->assertContainsOnlyInstancesOf( '\DataValues\MonolingualTextValue', $actual ); + $this->assertContainsOnlyInstancesOf( MonolingualTextValue::class, $actual ); $this->assertEquals( $arguments[0], array_values( $actual ) ); } diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index ac1bc06..bf90701 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -3,6 +3,7 @@ namespace ValueFormatters\Test; use DataValues\StringValue; +use InvalidArgumentException; use ValueFormatters\FormatterOptions; use ValueFormatters\StringFormatter; @@ -46,7 +47,7 @@ public function validProvider() { */ public function testInvalidFormat( $value ) { $formatter = new StringFormatter(); - $this->setExpectedException( 'InvalidArgumentException' ); + $this->setExpectedException( InvalidArgumentException::class ); $formatter->format( $value ); } diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php index 964e5ac..0ca8450 100644 --- a/tests/ValueParsers/DispatchingValueParserTest.php +++ b/tests/ValueParsers/DispatchingValueParserTest.php @@ -27,7 +27,7 @@ class DispatchingValueParserTest extends PHPUnit_Framework_TestCase { * @return ValueParser */ private function getParser( PHPUnit_Framework_MockObject_Matcher_Invocation $invocation ) { - $mock = $this->getMock( 'ValueParsers\ValueParser' ); + $mock = $this->getMock( ValueParser::class ); $mock->expects( $invocation ) ->method( 'parse' ) @@ -81,7 +81,7 @@ public function testParseThrowsException() { 'format' ); - $this->setExpectedException( 'ValueParsers\ParseException' ); + $this->setExpectedException( ParseException::class ); $parser->parse( 'invalid' ); } diff --git a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php index 7d244b4..788fa34 100644 --- a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php @@ -3,6 +3,7 @@ namespace ValueParsers\Normalizers\Test; use DataValues\StringValue; +use InvalidArgumentException; use PHPUnit_Framework_TestCase; use ValueParsers\Normalizers\NullStringNormalizer; @@ -38,7 +39,7 @@ public function stringProvider() { */ public function testNormalizeException( $value ) { $normalizer = new NullStringNormalizer(); - $this->setExpectedException( 'InvalidArgumentException' ); + $this->setExpectedException( InvalidArgumentException::class ); $normalizer->normalize( $value ); } diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index 42b90bc..47f01be 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -19,7 +19,7 @@ class StringParserTest extends \PHPUnit_Framework_TestCase { public function provideParse() { - $normalizer = $this->getMock( 'ValueParsers\Normalizers\StringNormalizer' ); + $normalizer = $this->getMock( StringNormalizer::class ); $normalizer->expects( $this->once() ) ->method( 'normalize' ) ->will( $this->returnCallback( function( $value ) { @@ -39,7 +39,7 @@ public function testParse( $input, StringNormalizer $normalizer = null, DataValu $parser = new StringParser( $normalizer ); $value = $parser->parse( $input ); - $this->assertInstanceOf( 'DataValues\StringValue', $value ); + $this->assertInstanceOf( StringValue::class, $value ); $this->assertEquals( $expected->toArray(), $value->toArray() ); } diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php index 00a0a1d..bc6311d 100644 --- a/tests/ValueParsers/ValueParserTestBase.php +++ b/tests/ValueParsers/ValueParserTestBase.php @@ -5,6 +5,7 @@ use Comparable; use DataValues\DataValue; use PHPUnit_Framework_TestCase; +use ValueParsers\ParseException; use ValueParsers\ValueParser; /** @@ -89,7 +90,7 @@ public function testParseWithInvalidInputs( $value, ValueParser $parser = null ) $parser = $this->getInstance(); } - $this->setExpectedException( 'ValueParsers\ParseException' ); + $this->setExpectedException( ParseException::class ); $parser->parse( $value ); } From e3c5531dbe5816bb91159d659f5b1a552daf4c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Fri, 24 Nov 2017 17:00:17 +0100 Subject: [PATCH 16/70] Family name of Thiemo changed --- .../Exceptions/MismatchingDataValueTypeException.php | 2 +- src/ValueParsers/DispatchingValueParser.php | 2 +- .../Exceptions/MismatchingDataValueTypeExceptionTest.php | 2 +- tests/ValueParsers/DispatchingValueParserTest.php | 2 +- tests/ValueParsers/Normalizers/NullStringNormalizerTest.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php b/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php index 147eb9f..f041e17 100644 --- a/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php +++ b/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php @@ -10,7 +10,7 @@ * * @license GPL-2.0+ * @author Katie Filbert < aude.wiki@gmail.com > - * @author Thiemo Mättig + * @author Thiemo Kreuz */ class MismatchingDataValueTypeException extends FormattingException { diff --git a/src/ValueParsers/DispatchingValueParser.php b/src/ValueParsers/DispatchingValueParser.php index 235da84..fb34287 100644 --- a/src/ValueParsers/DispatchingValueParser.php +++ b/src/ValueParsers/DispatchingValueParser.php @@ -11,7 +11,7 @@ * @since 0.3 * * @license GPL-2.0+ - * @author Thiemo Mättig + * @author Thiemo Kreuz */ class DispatchingValueParser implements ValueParser { diff --git a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php index 5c8d45b..44af779 100644 --- a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php +++ b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php @@ -14,7 +14,7 @@ * * @license GPL-2.0+ * @author Katie Filbert < aude.wiki@gmail.com > - * @author Thiemo Mättig + * @author Thiemo Kreuz */ class MismatchingDataValueTypeExceptionTest extends PHPUnit_Framework_TestCase { diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php index 0ca8450..b328660 100644 --- a/tests/ValueParsers/DispatchingValueParserTest.php +++ b/tests/ValueParsers/DispatchingValueParserTest.php @@ -17,7 +17,7 @@ * @group ValueParsers * * @license GPL-2.0+ - * @author Thiemo Mättig + * @author Thiemo Kreuz */ class DispatchingValueParserTest extends PHPUnit_Framework_TestCase { diff --git a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php index 788fa34..72b9956 100644 --- a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php @@ -14,7 +14,7 @@ * @group DataValueExtensions * * @license GPL-2.0+ - * @author Thiemo Mättig + * @author Thiemo Kreuz */ class NullStringNormalizerTest extends PHPUnit_Framework_TestCase { From 720cc49a5471a76d1b52c53dea429aae5474c795 Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Mon, 22 Jan 2018 13:39:18 +0100 Subject: [PATCH 17/70] License according to https://spdx.org/licenses/ --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0a97825..2137465 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "wikidata" ], "homepage": "https://github.com/DataValues/Common", - "license": "GPL-2.0+", + "license": "GPL-2.0-or-later", "authors": [ { "name": "Jeroen De Dauw", From 2a57e911dc1a5d04493acfd26a832f9800012807 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Thu, 8 Feb 2018 17:40:05 +0100 Subject: [PATCH 18/70] Document keys of MultilingualTextValue::getTexts() (#77) The useful detail that texts are indexed by language codes was not previously documented. --- src/DataValues/MultilingualTextValue.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index 864ed90..0335f84 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -77,7 +77,8 @@ public function getSortKey() { } /** - * Returns the texts as an array of monolingual text values. + * Returns the texts as an array of monolingual text values, + * with the language codes as array keys. * * @return MonolingualTextValue[] */ From 0e00387c5fbdd5d1689fe3acf9838abbeafadcbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Thu, 13 Aug 2015 18:09:31 +0200 Subject: [PATCH 19/70] Add TrimmingStringNormalizer --- README.md | 1 + .../Normalizers/TrimmingStringNormalizer.php | 32 +++++++++++ .../TrimmingStringNormalizerTest.php | 56 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 src/ValueParsers/Normalizers/TrimmingStringNormalizer.php create mode 100644 tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php diff --git a/README.md b/README.md index 97ac50c..3503808 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ employees for the [Wikidata project](https://wikidata.org/). ### 1.0.0 (dev) +* Added `TrimmingStringNormalizer` * Removed the `DATAVALUES_COMMON_VERSION` constant * The `StringFormatter` constructor does not accept options any more diff --git a/src/ValueParsers/Normalizers/TrimmingStringNormalizer.php b/src/ValueParsers/Normalizers/TrimmingStringNormalizer.php new file mode 100644 index 0000000..3ad6d86 --- /dev/null +++ b/src/ValueParsers/Normalizers/TrimmingStringNormalizer.php @@ -0,0 +1,32 @@ +assertSame( $expected, $normalizer->normalize( $value ) ); + } + + public function stringProvider() { + return [ + 'Empty' => [ '', '' ], + 'Trimmed' => [ 'a', 'a' ], + 'Spaces' => [ ' a ', 'a' ], + 'Controls' => [ "\n\r\ta\n\r\t", 'a' ], + 'Paragraph separator' => [ "\xE2\x80\xA9a\xE2\x80\xA9", 'a' ], + ]; + } + + /** + * @dataProvider invalidValueProvider + */ + public function testNormalizeException( $value ) { + $normalizer = new TrimmingStringNormalizer(); + $this->setExpectedException( 'InvalidArgumentException' ); + $normalizer->normalize( $value ); + } + + public function invalidValueProvider() { + return [ + [ null ], + [ true ], + [ 1 ], + [ new StringValue( '' ) ], + ]; + } + +} From e3a035cb65c771c97874cc4848b9d0a4b7278a3a Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 10 Aug 2018 14:01:51 +0200 Subject: [PATCH 20/70] Allow installation with DV 2.x --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2137465..755a727 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=5.5.9", - "data-values/data-values": "~1.0|~0.1", + "data-values/data-values": "~2.0|~1.0|~0.1", "data-values/interfaces": "~0.2.0" }, "require-dev": { From a3c1c50784a804848f0988690b0ac554b0088cbb Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Thu, 16 Aug 2018 10:17:13 +0200 Subject: [PATCH 21/70] Update README.md [skip ci] --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 3503808..86d8361 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,10 @@ employees for the [Wikidata project](https://wikidata.org/). * Removed the `DATAVALUES_COMMON_VERSION` constant * The `StringFormatter` constructor does not accept options any more +### 0.4.2 (2018-08-16) + +* The component can now be installed together with DataValues 2.x + ### 0.4.1 (2017-08-09) * Fixed version number not updated before. From 76ad7573fe00304731c591bce9fe86c9ee0fcabd Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Thu, 16 Aug 2018 10:19:14 +0200 Subject: [PATCH 22/70] Also test against PHP 7.2 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 74748b6..b40890f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: - 5.6 - 7 - 7.1 + - 7.2 - hhvm sudo: false From 86a85597f7065da4a254badcc37f55219f6e80f7 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 17 May 2019 07:25:35 +0200 Subject: [PATCH 23/70] Update .scrutinizer.yml --- .scrutinizer.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index d3e813a..18ed129 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -3,7 +3,6 @@ inherit: true tools: external_code_coverage: true - php_code_coverage: true php_code_sniffer: true php_cpd: true php_cs_fixer: true From d2ee49bbc80e59d9180b2f44029f13635e060434 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 17 May 2019 07:25:47 +0200 Subject: [PATCH 24/70] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b40890f..63ee174 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ php: - 7 - 7.1 - 7.2 - - hhvm + - 7.3 sudo: false From 95a0b2428501b75fe89b18a38d3e58bffdceb83b Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Mon, 29 Jul 2019 20:45:39 +0200 Subject: [PATCH 25/70] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 86d8361..7a40a59 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ The recommended way to use this library is via [Composer](http://getcomposer.org To add this package as a local, per-project dependency to your project, simply add a dependency on `data-values/common` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on -version 1.0 of this package: +version 0.4.2 of this package: { "require": { - "data-values/common": "^1.0.0" + "data-values/common": "^0.4.2" } } From 7ad3f02f2a2c6eb97fbc754784fedf9c50a3d4f2 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Mon, 29 Jul 2019 20:46:13 +0200 Subject: [PATCH 26/70] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 63ee174..e5104fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ install: travis_retry composer install script: composer ci after_success: - - if [[ "`phpenv version-name`" != "7.1" ]]; then exit 0; fi + - if [[ "`phpenv version-name`" != "7.3" ]]; then exit 0; fi - vendor/bin/phpunit --coverage-clover coverage.clover - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover coverage.clover From 2edfb55e7047ddb036db59fa4e907590169ed4f4 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Thu, 19 Sep 2019 12:42:21 +0200 Subject: [PATCH 27/70] Do not exclude tests directory from releases Some of the code in there is package public See https://github.com/DataValues/Common/blob/master/composer.json#L47 --- .gitattributes | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index dcd303f..3f150e3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,4 +6,3 @@ composer.json export-ignore phpcs.xml export-ignore phpunit.xml.dist export-ignore -tests export-ignore From 00d7acad5d15f3815fb785905ef31658b3123c23 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 20 Sep 2019 14:30:32 +0200 Subject: [PATCH 28/70] Explicitly use local PHPUnit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 755a727..b6cee92 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,7 @@ "test": [ "composer validate --no-interaction", "covers-validator", - "phpunit" + "vendor/bin/phpunit" ], "ci": [ "@cs", From 9f3979f873e3b315f202f31bf80bb6c24ec564c5 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 20 Sep 2019 14:34:08 +0200 Subject: [PATCH 29/70] FQNs for @covers tags --- tests/DataValues/MonolingualTextValueTest.php | 2 +- tests/DataValues/MultilingualTextValueTest.php | 2 +- .../Exceptions/MismatchingDataValueTypeExceptionTest.php | 2 +- tests/ValueFormatters/StringFormatterTest.php | 2 +- tests/ValueParsers/BoolParserTest.php | 4 ++-- tests/ValueParsers/DispatchingValueParserTest.php | 2 +- tests/ValueParsers/FloatParserTest.php | 4 ++-- tests/ValueParsers/IntParserTest.php | 4 ++-- tests/ValueParsers/Normalizers/NullStringNormalizerTest.php | 2 +- .../ValueParsers/Normalizers/TrimmingStringNormalizerTest.php | 2 +- tests/ValueParsers/NullParserTest.php | 2 +- tests/ValueParsers/StringParserTest.php | 2 +- tests/ValueParsers/StringValueParserTest.php | 2 +- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index 38e69fc..3891208 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -6,7 +6,7 @@ use DataValues\MonolingualTextValue; /** - * @covers DataValues\MonolingualTextValue + * @covers \DataValues\MonolingualTextValue * * @since 0.1 * diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index 89f3760..192caf7 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -7,7 +7,7 @@ use DataValues\MultilingualTextValue; /** - * @covers DataValues\MultilingualTextValue + * @covers \DataValues\MultilingualTextValue * * @since 0.1 * diff --git a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php index 44af779..231fe5d 100644 --- a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php +++ b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php @@ -7,7 +7,7 @@ use ValueFormatters\Exceptions\MismatchingDataValueTypeException; /** - * @covers ValueFormatters\Exceptions\MismatchingDataValueTypeException + * @covers \ValueFormatters\Exceptions\MismatchingDataValueTypeException * * @group ValueFormatters * @group DataValueExtensions diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index bf90701..a227a52 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -8,7 +8,7 @@ use ValueFormatters\StringFormatter; /** - * @covers ValueFormatters\StringFormatter + * @covers \ValueFormatters\StringFormatter * * @group ValueFormatters * @group DataValueExtensions diff --git a/tests/ValueParsers/BoolParserTest.php b/tests/ValueParsers/BoolParserTest.php index e365c76..f53fce8 100644 --- a/tests/ValueParsers/BoolParserTest.php +++ b/tests/ValueParsers/BoolParserTest.php @@ -6,8 +6,8 @@ use ValueParsers\BoolParser; /** - * @covers ValueParsers\BoolParser - * @covers ValueParsers\StringValueParser + * @covers \ValueParsers\BoolParser + * @covers \ValueParsers\StringValueParser * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php index b328660..93c214d 100644 --- a/tests/ValueParsers/DispatchingValueParserTest.php +++ b/tests/ValueParsers/DispatchingValueParserTest.php @@ -10,7 +10,7 @@ use ValueParsers\ValueParser; /** - * @covers ValueParsers\DispatchingValueParser + * @covers \ValueParsers\DispatchingValueParser * * @group DataValue * @group DataValueExtensions diff --git a/tests/ValueParsers/FloatParserTest.php b/tests/ValueParsers/FloatParserTest.php index c89d906..2983aee 100644 --- a/tests/ValueParsers/FloatParserTest.php +++ b/tests/ValueParsers/FloatParserTest.php @@ -6,8 +6,8 @@ use ValueParsers\FloatParser; /** - * @covers ValueParsers\FloatParser - * @covers ValueParsers\StringValueParser + * @covers \ValueParsers\FloatParser + * @covers \ValueParsers\StringValueParser * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/IntParserTest.php b/tests/ValueParsers/IntParserTest.php index eab8d89..46cc94d 100644 --- a/tests/ValueParsers/IntParserTest.php +++ b/tests/ValueParsers/IntParserTest.php @@ -6,8 +6,8 @@ use ValueParsers\IntParser; /** - * @covers ValueParsers\IntParser - * @covers ValueParsers\StringValueParser + * @covers \ValueParsers\IntParser + * @covers \ValueParsers\StringValueParser * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php index 72b9956..c58fd2e 100644 --- a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php @@ -8,7 +8,7 @@ use ValueParsers\Normalizers\NullStringNormalizer; /** - * @covers ValueParsers\Normalizers\NullStringNormalizer + * @covers \ValueParsers\Normalizers\NullStringNormalizer * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php index 3d69681..dc13a09 100644 --- a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php @@ -7,7 +7,7 @@ use ValueParsers\Normalizers\TrimmingStringNormalizer; /** - * @covers ValueParsers\Normalizers\TrimmingStringNormalizer + * @covers \ValueParsers\Normalizers\TrimmingStringNormalizer * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/NullParserTest.php b/tests/ValueParsers/NullParserTest.php index fbea499..c17eb58 100644 --- a/tests/ValueParsers/NullParserTest.php +++ b/tests/ValueParsers/NullParserTest.php @@ -7,7 +7,7 @@ use ValueParsers\ValueParser; /** - * @covers ValueParsers\NullParser + * @covers \ValueParsers\NullParser * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index 47f01be..b72d15b 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -8,7 +8,7 @@ use ValueParsers\StringParser; /** - * @covers ValueParsers\StringParser + * @covers \ValueParsers\StringParser * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/StringValueParserTest.php b/tests/ValueParsers/StringValueParserTest.php index 5fcd989..7e05608 100644 --- a/tests/ValueParsers/StringValueParserTest.php +++ b/tests/ValueParsers/StringValueParserTest.php @@ -6,7 +6,7 @@ use ValueParsers\StringValueParser; /** - * @covers ValueParsers\StringValueParser + * @covers \ValueParsers\StringValueParser * * @group ValueParsers * @group DataValueExtensions From b8c0412a85c67727684c55846c8e1417b628b5a5 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 20 Sep 2019 14:37:17 +0200 Subject: [PATCH 30/70] Make tests package private Allows for https://github.com/DataValues/Common/pull/84 Wikibase Repo has 3 usages of StringValueParserTest: https://github.com/wikimedia/mediawiki-extensions-Wikibase/search?q=StringValueParserTest These can easily be fixed by using a copy of the class (or better yet: refactoring away from this inheritance abuse pattern). --- README.md | 3 ++- composer.json | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7a40a59..e462a6c 100644 --- a/README.md +++ b/README.md @@ -57,9 +57,10 @@ employees for the [Wikidata project](https://wikidata.org/). ### 1.0.0 (dev) -* Added `TrimmingStringNormalizer` * Removed the `DATAVALUES_COMMON_VERSION` constant +* Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` * The `StringFormatter` constructor does not accept options any more +* Added `TrimmingStringNormalizer` ### 0.4.2 (2018-08-16) diff --git a/composer.json b/composer.json index 755a727..ac8cdb7 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,9 @@ "DataValues\\": "src/DataValues/", "ValueFormatters\\": "src/ValueFormatters/", "ValueParsers\\": "src/ValueParsers/" - }, + } + }, + "autoload-dev": { "classmap": [ "tests/ValueParsers" ] From 6702b0465d62716880efa7a6c59285b05f91bb71 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 25 Sep 2020 15:36:52 +0200 Subject: [PATCH 31/70] =?UTF-8?q?Don=E2=80=99t=20declare=20support=20for?= =?UTF-8?q?=20unsupported=20PHP=20versions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHP upstream doesn’t support any versions older than 7.2. (In fact even 7.2 is barely supported anymore, but we still expect to use it in Wikimedia production for a while, so the library should stay compatible for the time being.) --- .travis.yml | 4 ---- README.md | 1 + composer.json | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index e5104fa..bd64dfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,6 @@ language: php dist: trusty php: - - 5.5 - - 5.6 - - 7 - - 7.1 - 7.2 - 7.3 diff --git a/README.md b/README.md index e462a6c..a5bde67 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ employees for the [Wikidata project](https://wikidata.org/). * Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` * The `StringFormatter` constructor does not accept options any more * Added `TrimmingStringNormalizer` +* Updated minimal required PHP version from 5.5.9 to 7.2 ### 0.4.2 (2018-08-16) diff --git a/composer.json b/composer.json index 6025a0c..cf5779f 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "irc": "irc://irc.freenode.net/wikidata" }, "require": { - "php": ">=5.5.9", + "php": ">=7.2.0", "data-values/data-values": "~2.0|~1.0|~0.1", "data-values/interfaces": "~0.2.0" }, From a9ef75f215fd077ee159b99c714a697ace185382 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 25 Sep 2020 15:38:04 +0200 Subject: [PATCH 32/70] Update PHPUnit, DataValues and Interfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a lot of changes at once, but I don’t think they can be split. The most important changes are: * The DataValueTest class was removed from DataValues. The release notes advise to “refactor away the bad design”, so I tried to rewrite the tests in a way that makes sense to me: instead of having one test per method (where many tests will end up calling other methods anyways, e. g. most test methods will also effectively test the constructor), test scenarios of how methods might be used in conjunction, e. g. serialize+unserialize. * The ValueFormatterTestBase class was removed from Interfaces. Its use can be substituted in the individual test classes relatively easily. * PHPUnit_Framework_TestCase is now PHPUnit\Framework\TestCase. PHPUnit_Framework_MockObject_Matcher_Invocation seems to have no replacement that’s not marked @internal, so leave that parameter untyped. * getMock() is now createMock(). * @expectedException or setExpectedException() is now expectException(). --- composer.json | 8 +- tests/DataValues/MonolingualTextValueTest.php | 69 +++++------ .../DataValues/MultilingualTextValueTest.php | 117 +++++++----------- .../MismatchingDataValueTypeExceptionTest.php | 4 +- tests/ValueFormatters/StringFormatterTest.php | 22 ++-- .../DispatchingValueParserTest.php | 18 +-- .../Normalizers/NullStringNormalizerTest.php | 6 +- .../TrimmingStringNormalizerTest.php | 7 +- tests/ValueParsers/StringParserTest.php | 8 +- tests/ValueParsers/ValueParserTestBase.php | 6 +- 10 files changed, 110 insertions(+), 155 deletions(-) diff --git a/composer.json b/composer.json index cf5779f..7fa44a4 100644 --- a/composer.json +++ b/composer.json @@ -24,12 +24,12 @@ }, "require": { "php": ">=7.2.0", - "data-values/data-values": "~2.0|~1.0|~0.1", - "data-values/interfaces": "~0.2.0" + "data-values/data-values": "~3.0|~2.0|~1.0|~0.1", + "data-values/interfaces": "~1.0|~0.2.0" }, "require-dev": { - "ockcyp/covers-validator": "~0.4", - "phpunit/phpunit": "~4.8", + "ockcyp/covers-validator": "~1.2", + "phpunit/phpunit": "~8.0", "wikibase/wikibase-codesniffer": "^0.1.0" }, "extra": { diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index 3891208..73c4b7e 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -4,6 +4,8 @@ use DataValues\IllegalValueException; use DataValues\MonolingualTextValue; +use Exception; +use PHPUnit\Framework\TestCase; /** * @covers \DataValues\MonolingualTextValue @@ -16,22 +18,38 @@ * @license GPL-2.0+ * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -class MonolingualTextValueTest extends DataValueTest { +class MonolingualTextValueTest extends TestCase { + + public function testGetters() { + $value = new MonolingualTextValue( 'en', 'foo' ); + $this->assertSame( 'monolingualtext', $value->getType() ); + $this->assertSame( 'enfoo', $value->getSortKey() ); + $this->assertSame( 'foo', $value->getText() ); + $this->assertSame( 'en', $value->getLanguageCode() ); + } + + public function testArrayAndEquals() { + $value = new MonolingualTextValue( 'en', 'foo' ); + $array = $value->getArrayValue(); + $value2 = MonolingualTextValue::newFromArray( $array ); + $this->assertTrue( $value->equals( $value2 ) ); + $this->assertEquals( $value, $value2 ); + } + + public function testSerialize() { + $value = new MonolingualTextValue( 'en', 'foo' ); + $serialization = serialize( $value ); + $value2 = unserialize( $serialization ); + $this->assertEquals( $value, $value2 ); + } /** - * @see DataValueTest::getClass - * - * @return string + * @dataProvider invalidConstructorArgumentsProvider */ - public function getClass() { - return MonolingualTextValue::class; - } + public function testConstructorWithInvalidArguments( $languageCode, $text ) { + $this->expectException( Exception::class ); - public function validConstructorArgumentsProvider() { - return [ - [ 'en', 'foo' ], - [ 'en', ' foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz ' ], - ]; + $dataItem = new MonolingualTextValue( $languageCode, $text ); } public function invalidConstructorArgumentsProvider() { @@ -49,17 +67,11 @@ public function invalidConstructorArgumentsProvider() { ]; } - public function testNewFromArray() { - $array = [ 'text' => 'foo', 'language' => 'en' ]; - $value = MonolingualTextValue::newFromArray( $array ); - $this->assertSame( $array, $value->getArrayValue() ); - } - /** * @dataProvider invalidArrayProvider */ public function testNewFromArrayWithInvalidArray( array $array ) { - $this->setExpectedException( IllegalValueException::class ); + $this->expectException( IllegalValueException::class ); MonolingualTextValue::newFromArray( $array ); } @@ -74,23 +86,4 @@ public function invalidArrayProvider() { ]; } - public function testGetSortKey() { - $value = new MonolingualTextValue( 'en', 'foo' ); - $this->assertSame( 'enfoo', $value->getSortKey() ); - } - - /** - * @dataProvider instanceProvider - */ - public function testGetText( MonolingualTextValue $text, array $arguments ) { - $this->assertEquals( $arguments[1], $text->getText() ); - } - - /** - * @dataProvider instanceProvider - */ - public function testGetLanguageCode( MonolingualTextValue $text, array $arguments ) { - $this->assertEquals( $arguments[0], $text->getLanguageCode() ); - } - } diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index 192caf7..f9ac1f0 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -5,6 +5,8 @@ use DataValues\IllegalValueException; use DataValues\MonolingualTextValue; use DataValues\MultilingualTextValue; +use Exception; +use PHPUnit\Framework\TestCase; /** * @covers \DataValues\MultilingualTextValue @@ -17,36 +19,52 @@ * @license GPL-2.0+ * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -class MultilingualTextValueTest extends DataValueTest { +class MultilingualTextValueTest extends TestCase { + + public function testGetters() { + $monolingualTextValue1 = new MonolingualTextValue( 'en', 'foo' ); + $monolingualTextValue2 = new MonolingualTextValue( 'de', 'foo' ); + $value = new MultilingualTextValue( [ $monolingualTextValue1, $monolingualTextValue2 ] ); + $this->assertSame( 'multilingualtext', $value->getType() ); + $this->assertSame( 'enfoo', $value->getSortKey() ); + $this->assertSame( + [ 'en' => $monolingualTextValue1, 'de' => $monolingualTextValue2 ], + $value->getTexts() + ); + } + + public function testGetters_empty() { + $value = new MultilingualTextValue( [] ); + $this->assertSame( '', $value->getSortKey() ); + $this->assertSame( [], $value->getTexts() ); + } + + public function testArrayAndEquals() { + $monolingualTextValue1 = new MonolingualTextValue( 'en', 'foo' ); + $monolingualTextValue2 = new MonolingualTextValue( 'de', 'foo' ); + $value = new MultilingualTextValue( [ $monolingualTextValue1, $monolingualTextValue2 ] ); + $array = $value->getArrayValue(); + $value2 = MultilingualTextValue::newFromArray( $array ); + $this->assertTrue( $value->equals( $value2 ) ); + $this->assertEquals( $value, $value2 ); + } + + public function testSerialize() { + $monolingualTextValue1 = new MonolingualTextValue( 'en', 'foo' ); + $monolingualTextValue2 = new MonolingualTextValue( 'de', 'foo' ); + $value = new MultilingualTextValue( [ $monolingualTextValue1, $monolingualTextValue2 ] ); + $serialization = serialize( $value ); + $value2 = unserialize( $serialization ); + $this->assertEquals( $value, $value2 ); + } /** - * @see DataValueTest::getClass - * - * @return string + * @dataProvider invalidConstructorArgumentsProvider */ - public function getClass() { - return MultilingualTextValue::class; - } + public function testConstructorWithInvalidArguments( $monolingualValues ) { + $this->expectException( Exception::class ); - public function validConstructorArgumentsProvider() { - return [ - [ [] ], - [ [ - new MonolingualTextValue( 'en', 'foo' ), - ] ], - [ [ - new MonolingualTextValue( 'en', 'foo' ), - new MonolingualTextValue( 'de', 'foo' ), - ] ], - [ [ - new MonolingualTextValue( 'en', 'foo' ), - new MonolingualTextValue( 'de', 'bar' ), - ] ], - [ [ - 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 ' ), - ] ], - ]; + $dataItem = new MultilingualTextValue( $monolingualValues ); } public function invalidConstructorArgumentsProvider() { @@ -81,17 +99,11 @@ public function invalidConstructorArgumentsProvider() { ]; } - public function testNewFromArray() { - $array = [ [ 'text' => 'foo', 'language' => 'en' ] ]; - $value = MultilingualTextValue::newFromArray( $array ); - $this->assertSame( $array, $value->getArrayValue() ); - } - /** * @dataProvider invalidArrayProvider */ public function testNewFromArrayWithInvalidArray( array $array ) { - $this->setExpectedException( IllegalValueException::class ); + $this->expectException( IllegalValueException::class ); MultilingualTextValue::newFromArray( $array ); } @@ -104,43 +116,4 @@ public function invalidArrayProvider() { ]; } - /** - * @dataProvider getSortKeyProvider - */ - public function testGetSortKey( array $monolingualValues, $expected ) { - $value = new MultilingualTextValue( $monolingualValues ); - $this->assertSame( $expected, $value->getSortKey() ); - } - - public function getSortKeyProvider() { - return [ - [ [], '' ], - [ [ - new MonolingualTextValue( 'en', 'foo' ), - ], 'enfoo' ], - [ [ - new MonolingualTextValue( 'en', 'foo' ), - new MonolingualTextValue( 'de', 'bar' ), - ], 'enfoo' ], - ]; - } - - /** - * @dataProvider instanceProvider - */ - public function testGetTexts( MultilingualTextValue $texts, array $arguments ) { - $actual = $texts->getTexts(); - - $this->assertInternalType( 'array', $actual ); - $this->assertContainsOnlyInstancesOf( MonolingualTextValue::class, $actual ); - $this->assertEquals( $arguments[0], array_values( $actual ) ); - } - - /** - * @dataProvider instanceProvider - */ - public function testGetValue( MultilingualTextValue $texts, array $arguments ) { - $this->assertInstanceOf( $this->getClass(), $texts->getValue() ); - } - } diff --git a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php index 231fe5d..e963d8e 100644 --- a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php +++ b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php @@ -3,7 +3,7 @@ namespace ValueFormatters\Tests\Exceptions; use Exception; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use ValueFormatters\Exceptions\MismatchingDataValueTypeException; /** @@ -16,7 +16,7 @@ * @author Katie Filbert < aude.wiki@gmail.com > * @author Thiemo Kreuz */ -class MismatchingDataValueTypeExceptionTest extends PHPUnit_Framework_TestCase { +class MismatchingDataValueTypeExceptionTest extends TestCase { /** * @dataProvider constructorProvider diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index a227a52..9b664c4 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -4,7 +4,7 @@ use DataValues\StringValue; use InvalidArgumentException; -use ValueFormatters\FormatterOptions; +use PHPUnit\Framework\TestCase; use ValueFormatters\StringFormatter; /** @@ -16,22 +16,14 @@ * @license GPL-2.0+ * @author Katie Filbert < aude.wiki@gmail.com > */ -class StringFormatterTest extends ValueFormatterTestBase { +class StringFormatterTest extends TestCase { - /** - * @see ValueFormatterTestBase::getInstance - * - * @param FormatterOptions|null $options - * - * @return StringFormatter - */ - protected function getInstance( FormatterOptions $options = null ) { - return new StringFormatter( $options ); + /** @dataProvider validProvider */ + public function testValidFormat( StringValue $value, string $expected ) { + $formatter = new StringFormatter(); + $this->assertSame( $expected, $formatter->format( $value ) ); } - /** - * @see ValueFormatterTestBase::validProvider - */ public function validProvider() { return [ [ new StringValue( 'ice cream' ), 'ice cream' ], @@ -47,7 +39,7 @@ public function validProvider() { */ public function testInvalidFormat( $value ) { $formatter = new StringFormatter(); - $this->setExpectedException( InvalidArgumentException::class ); + $this->expectException( InvalidArgumentException::class ); $formatter->format( $value ); } diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php index 93c214d..d4e8e6c 100644 --- a/tests/ValueParsers/DispatchingValueParserTest.php +++ b/tests/ValueParsers/DispatchingValueParserTest.php @@ -3,8 +3,7 @@ namespace ValueParsers\Test; use InvalidArgumentException; -use PHPUnit_Framework_MockObject_Matcher_Invocation; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use ValueParsers\DispatchingValueParser; use ValueParsers\ParseException; use ValueParsers\ValueParser; @@ -19,15 +18,10 @@ * @license GPL-2.0+ * @author Thiemo Kreuz */ -class DispatchingValueParserTest extends PHPUnit_Framework_TestCase { +class DispatchingValueParserTest extends TestCase { - /** - * @param PHPUnit_Framework_MockObject_Matcher_Invocation $invocation - * - * @return ValueParser - */ - private function getParser( PHPUnit_Framework_MockObject_Matcher_Invocation $invocation ) { - $mock = $this->getMock( ValueParser::class ); + private function getParser( $invocation ) : ValueParser { + $mock = $this->createMock( ValueParser::class ); $mock->expects( $invocation ) ->method( 'parse' ) @@ -43,9 +37,9 @@ private function getParser( PHPUnit_Framework_MockObject_Matcher_Invocation $inv /** * @dataProvider invalidConstructorArgumentsProvider - * @expectedException InvalidArgumentException */ public function testGivenInvalidConstructorArguments_constructorThrowsException( $parsers, $format ) { + $this->expectException( InvalidArgumentException::class ); new DispatchingValueParser( $parsers, $format ); } @@ -81,7 +75,7 @@ public function testParseThrowsException() { 'format' ); - $this->setExpectedException( ParseException::class ); + $this->expectException( ParseException::class ); $parser->parse( 'invalid' ); } diff --git a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php index c58fd2e..3462457 100644 --- a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php @@ -4,7 +4,7 @@ use DataValues\StringValue; use InvalidArgumentException; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use ValueParsers\Normalizers\NullStringNormalizer; /** @@ -16,7 +16,7 @@ * @license GPL-2.0+ * @author Thiemo Kreuz */ -class NullStringNormalizerTest extends PHPUnit_Framework_TestCase { +class NullStringNormalizerTest extends TestCase { /** * @dataProvider stringProvider @@ -39,7 +39,7 @@ public function stringProvider() { */ public function testNormalizeException( $value ) { $normalizer = new NullStringNormalizer(); - $this->setExpectedException( InvalidArgumentException::class ); + $this->expectException( InvalidArgumentException::class ); $normalizer->normalize( $value ); } diff --git a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php index dc13a09..3c1dcbe 100644 --- a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php @@ -3,7 +3,8 @@ namespace ValueParsers\Normalizers\Test; use DataValues\StringValue; -use PHPUnit_Framework_TestCase; +use InvalidArgumentException; +use PHPUnit\Framework\TestCase; use ValueParsers\Normalizers\TrimmingStringNormalizer; /** @@ -15,7 +16,7 @@ * @license GPL-2.0-or-later * @author Thiemo Kreuz */ -class TrimmingStringNormalizerTest extends PHPUnit_Framework_TestCase { +class TrimmingStringNormalizerTest extends TestCase { /** * @dataProvider stringProvider @@ -40,7 +41,7 @@ public function stringProvider() { */ public function testNormalizeException( $value ) { $normalizer = new TrimmingStringNormalizer(); - $this->setExpectedException( 'InvalidArgumentException' ); + $this->expectException( InvalidArgumentException::class ); $normalizer->normalize( $value ); } diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index b72d15b..fd44bd7 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -4,6 +4,8 @@ use DataValues\DataValue; use DataValues\StringValue; +use InvalidArgumentException; +use PHPUnit\Framework\TestCase; use ValueParsers\Normalizers\StringNormalizer; use ValueParsers\StringParser; @@ -16,10 +18,10 @@ * @license GPL-2.0+ * @author Daniel Kinzler */ -class StringParserTest extends \PHPUnit_Framework_TestCase { +class StringParserTest extends TestCase { public function provideParse() { - $normalizer = $this->getMock( StringNormalizer::class ); + $normalizer = $this->createMock( StringNormalizer::class ); $normalizer->expects( $this->once() ) ->method( 'normalize' ) ->will( $this->returnCallback( function( $value ) { @@ -56,7 +58,7 @@ public function nonStringProvider() { */ public function testGivenNonString_parseThrowsException( $input ) { $parser = new StringParser(); - $this->setExpectedException( 'InvalidArgumentException' ); + $this->expectException( InvalidArgumentException::class ); $parser->parse( $input ); } diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php index e19addc..8cfd78f 100644 --- a/tests/ValueParsers/ValueParserTestBase.php +++ b/tests/ValueParsers/ValueParserTestBase.php @@ -4,7 +4,7 @@ use Comparable; use DataValues\DataValue; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use ValueParsers\ParseException; use ValueParsers\ValueParser; @@ -19,7 +19,7 @@ * @license GPL-2.0+ * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -abstract class ValueParserTestBase extends PHPUnit_Framework_TestCase { +abstract class ValueParserTestBase extends TestCase { /** * @return array[] @@ -80,7 +80,7 @@ public function testParseWithInvalidInputs( $value, ValueParser $parser = null ) $parser = $this->getInstance(); } - $this->setExpectedException( ParseException::class ); + $this->expectException( ParseException::class ); $parser->parse( $value ); } From c1f33d7c21316f6dc3272c85bc05bbef420601f1 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 25 Sep 2020 15:49:30 +0200 Subject: [PATCH 33/70] Remove getSortKey() and getCopy() Removed from DataValues in 3.0.0. --- README.md | 1 + src/DataValues/MonolingualTextValue.php | 10 ---------- src/DataValues/MultilingualTextValue.php | 9 --------- tests/DataValues/MonolingualTextValueTest.php | 1 - tests/DataValues/MultilingualTextValueTest.php | 2 -- 5 files changed, 1 insertion(+), 22 deletions(-) diff --git a/README.md b/README.md index a5bde67..123bdd8 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ employees for the [Wikidata project](https://wikidata.org/). ### 1.0.0 (dev) * Removed the `DATAVALUES_COMMON_VERSION` constant +* Removed `getCopy` and `getSortKey` methods from `DataValue` implementations * Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` * The `StringFormatter` constructor does not accept options any more * Added `TrimmingStringNormalizer` diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index 5cf35fc..369a14d 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -68,16 +68,6 @@ public static function getType() { return 'monolingualtext'; } - /** - * @see DataValue::getSortKey - * - * @return string - */ - public function getSortKey() { - // TODO: we might want to re-think this key. Perhaps the language should simply be omitted. - return $this->languageCode . $this->text; - } - /** * @see DataValue::getValue * diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index 0335f84..54b2cb9 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -67,15 +67,6 @@ public static function getType() { return 'multilingualtext'; } - /** - * @see DataValue::getSortKey - * - * @return string|float|int - */ - public function getSortKey() { - return empty( $this->texts ) ? '' : reset( $this->texts )->getSortKey(); - } - /** * Returns the texts as an array of monolingual text values, * with the language codes as array keys. diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index 73c4b7e..1c49e25 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -23,7 +23,6 @@ class MonolingualTextValueTest extends TestCase { public function testGetters() { $value = new MonolingualTextValue( 'en', 'foo' ); $this->assertSame( 'monolingualtext', $value->getType() ); - $this->assertSame( 'enfoo', $value->getSortKey() ); $this->assertSame( 'foo', $value->getText() ); $this->assertSame( 'en', $value->getLanguageCode() ); } diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index f9ac1f0..291d37b 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -26,7 +26,6 @@ public function testGetters() { $monolingualTextValue2 = new MonolingualTextValue( 'de', 'foo' ); $value = new MultilingualTextValue( [ $monolingualTextValue1, $monolingualTextValue2 ] ); $this->assertSame( 'multilingualtext', $value->getType() ); - $this->assertSame( 'enfoo', $value->getSortKey() ); $this->assertSame( [ 'en' => $monolingualTextValue1, 'de' => $monolingualTextValue2 ], $value->getTexts() @@ -35,7 +34,6 @@ public function testGetters() { public function testGetters_empty() { $value = new MultilingualTextValue( [] ); - $this->assertSame( '', $value->getSortKey() ); $this->assertSame( [], $value->getTexts() ); } From dd563dbeee39654cf5c6db499b76d6ce9e179017 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 25 Sep 2020 17:23:17 +0200 Subject: [PATCH 34/70] Update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e462a6c..a680f86 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ employees for the [Wikidata project](https://wikidata.org/). * Removed the `DATAVALUES_COMMON_VERSION` constant * Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` * The `StringFormatter` constructor does not accept options any more +* `StringParser::parse` now throws a `ParseException` instead of an `InvalidArgumentException` * Added `TrimmingStringNormalizer` ### 0.4.2 (2018-08-16) From e9ecad4ba8dadddb74e22541705bd0641ddb9c1f Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Mon, 28 Sep 2020 13:32:18 +0200 Subject: [PATCH 35/70] Revert "Remove getSortKey() and getCopy()" If we want to declare compatibility with older DataValues versions, we need to keep them around. Mark them as deprecated instead. This reverts commit c1f33d7c21316f6dc3272c85bc05bbef420601f1. --- README.md | 2 +- src/DataValues/MonolingualTextValue.php | 11 +++++++++++ src/DataValues/MultilingualTextValue.php | 10 ++++++++++ tests/DataValues/MonolingualTextValueTest.php | 1 + tests/DataValues/MultilingualTextValueTest.php | 2 ++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 30c52f4..5ed34fd 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ employees for the [Wikidata project](https://wikidata.org/). ### 1.0.0 (dev) * Removed the `DATAVALUES_COMMON_VERSION` constant -* Removed `getCopy` and `getSortKey` methods from `DataValue` implementations +* Deprecated `getSortKey` methods from `DataValue` implementations * Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` * The `StringFormatter` constructor does not accept options any more * `StringParser::parse` now throws a `ParseException` instead of an `InvalidArgumentException` diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index 369a14d..f575c4c 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -68,6 +68,17 @@ public static function getType() { return 'monolingualtext'; } + /** + * @deprecated Kept for compatibility with older DataValues versions. + * Do not use. + * + * @return string + */ + public function getSortKey() { + // TODO: we might want to re-think this key. Perhaps the language should simply be omitted. + return $this->languageCode . $this->text; + } + /** * @see DataValue::getValue * diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index 54b2cb9..a6ee131 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -67,6 +67,16 @@ public static function getType() { return 'multilingualtext'; } + /** + * @deprecated Kept for compatibility with older DataValues versions. + * Do not use. + * + * @return string|float|int + */ + public function getSortKey() { + return empty( $this->texts ) ? '' : reset( $this->texts )->getSortKey(); + } + /** * Returns the texts as an array of monolingual text values, * with the language codes as array keys. diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index 1c49e25..73c4b7e 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -23,6 +23,7 @@ class MonolingualTextValueTest extends TestCase { public function testGetters() { $value = new MonolingualTextValue( 'en', 'foo' ); $this->assertSame( 'monolingualtext', $value->getType() ); + $this->assertSame( 'enfoo', $value->getSortKey() ); $this->assertSame( 'foo', $value->getText() ); $this->assertSame( 'en', $value->getLanguageCode() ); } diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index 291d37b..f9ac1f0 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -26,6 +26,7 @@ public function testGetters() { $monolingualTextValue2 = new MonolingualTextValue( 'de', 'foo' ); $value = new MultilingualTextValue( [ $monolingualTextValue1, $monolingualTextValue2 ] ); $this->assertSame( 'multilingualtext', $value->getType() ); + $this->assertSame( 'enfoo', $value->getSortKey() ); $this->assertSame( [ 'en' => $monolingualTextValue1, 'de' => $monolingualTextValue2 ], $value->getTexts() @@ -34,6 +35,7 @@ public function testGetters() { public function testGetters_empty() { $value = new MultilingualTextValue( [] ); + $this->assertSame( '', $value->getSortKey() ); $this->assertSame( [], $value->getTexts() ); } From 5858cb12282811fe1298258093fe24f16c206e2e Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Mon, 28 Sep 2020 15:33:27 +0200 Subject: [PATCH 36/70] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ed34fd..68bf8ab 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ employees for the [Wikidata project](https://wikidata.org/). * The `StringFormatter` constructor does not accept options any more * `StringParser::parse` now throws a `ParseException` instead of an `InvalidArgumentException` * Added `TrimmingStringNormalizer` -* Updated minimal required PHP version from 5.5.9 to 7.2 +* Updated minimum required PHP version from 5.5.9 to 7.2 ### 0.4.2 (2018-08-16) From db0c7619d49f2c502af2d9198ef54878b1e489b8 Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:01:33 +0000 Subject: [PATCH 37/70] Update wikibase-codesniffer to v1.2.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7fa44a4..5e3f65b 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "require-dev": { "ockcyp/covers-validator": "~1.2", "phpunit/phpunit": "~8.0", - "wikibase/wikibase-codesniffer": "^0.1.0" + "wikibase/wikibase-codesniffer": "^1.2.0" }, "extra": { "branch-alias": { From 02d57f0794b86494273a0bf95257736be4590706 Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:03:17 +0000 Subject: [PATCH 38/70] Add fix script --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 5e3f65b..e543513 100644 --- a/composer.json +++ b/composer.json @@ -50,6 +50,9 @@ ] }, "scripts": { + "fix": [ + "phpcbf" + ], "cs": [ "phpcs -p -s" ], From add25fdacc482066dae02e72cca45895cc70b215 Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:03:38 +0000 Subject: [PATCH 39/70] Autofix cs violations --- tests/ValueParsers/StringParserTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index e7ee54d..153a3f5 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -4,7 +4,6 @@ use DataValues\DataValue; use DataValues\StringValue; -use InvalidArgumentException; use PHPUnit\Framework\TestCase; use ValueParsers\Normalizers\StringNormalizer; use ValueParsers\ParseException; From 4139b35af87793bad411ac23d7297ff03e51a32e Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:20:36 +0000 Subject: [PATCH 40/70] Update license identifier --- src/DataValues/MonolingualTextValue.php | 2 +- src/DataValues/MultilingualTextValue.php | 2 +- .../Exceptions/MismatchingDataValueTypeException.php | 2 +- src/ValueFormatters/StringFormatter.php | 2 +- src/ValueParsers/BoolParser.php | 2 +- src/ValueParsers/DispatchingValueParser.php | 2 +- src/ValueParsers/FloatParser.php | 2 +- src/ValueParsers/IntParser.php | 2 +- src/ValueParsers/Normalizers/NullStringNormalizer.php | 2 +- src/ValueParsers/Normalizers/StringNormalizer.php | 2 +- src/ValueParsers/NullParser.php | 2 +- src/ValueParsers/StringParser.php | 2 +- src/ValueParsers/StringValueParser.php | 2 +- tests/DataValues/MonolingualTextValueTest.php | 2 +- tests/DataValues/MultilingualTextValueTest.php | 2 +- .../Exceptions/MismatchingDataValueTypeExceptionTest.php | 2 +- tests/ValueFormatters/StringFormatterTest.php | 2 +- tests/ValueParsers/BoolParserTest.php | 2 +- tests/ValueParsers/DispatchingValueParserTest.php | 2 +- tests/ValueParsers/FloatParserTest.php | 2 +- tests/ValueParsers/IntParserTest.php | 2 +- tests/ValueParsers/Normalizers/NullStringNormalizerTest.php | 2 +- tests/ValueParsers/NullParserTest.php | 2 +- tests/ValueParsers/StringParserTest.php | 2 +- tests/ValueParsers/StringValueParserTest.php | 2 +- tests/ValueParsers/ValueParserTestBase.php | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index f575c4c..e65d408 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -7,7 +7,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class MonolingualTextValue extends DataValueObject { diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index a6ee131..ba3393e 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -7,7 +7,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class MultilingualTextValue extends DataValueObject { diff --git a/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php b/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php index f041e17..7595164 100644 --- a/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php +++ b/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php @@ -8,7 +8,7 @@ /** * @since 0.2.2 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Katie Filbert < aude.wiki@gmail.com > * @author Thiemo Kreuz */ diff --git a/src/ValueFormatters/StringFormatter.php b/src/ValueFormatters/StringFormatter.php index c5ebaf9..eeb947b 100644 --- a/src/ValueFormatters/StringFormatter.php +++ b/src/ValueFormatters/StringFormatter.php @@ -11,7 +11,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Katie Filbert < aude.wiki@gmail.com > */ class StringFormatter implements ValueFormatter { diff --git a/src/ValueParsers/BoolParser.php b/src/ValueParsers/BoolParser.php index 2835e66..b30f926 100644 --- a/src/ValueParsers/BoolParser.php +++ b/src/ValueParsers/BoolParser.php @@ -9,7 +9,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class BoolParser extends StringValueParser { diff --git a/src/ValueParsers/DispatchingValueParser.php b/src/ValueParsers/DispatchingValueParser.php index fb34287..2626d5c 100644 --- a/src/ValueParsers/DispatchingValueParser.php +++ b/src/ValueParsers/DispatchingValueParser.php @@ -10,7 +10,7 @@ * * @since 0.3 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Thiemo Kreuz */ class DispatchingValueParser implements ValueParser { diff --git a/src/ValueParsers/FloatParser.php b/src/ValueParsers/FloatParser.php index 5845cbb..c24999a 100644 --- a/src/ValueParsers/FloatParser.php +++ b/src/ValueParsers/FloatParser.php @@ -9,7 +9,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class FloatParser extends StringValueParser { diff --git a/src/ValueParsers/IntParser.php b/src/ValueParsers/IntParser.php index 93547b0..964b02c 100644 --- a/src/ValueParsers/IntParser.php +++ b/src/ValueParsers/IntParser.php @@ -9,7 +9,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class IntParser extends StringValueParser { diff --git a/src/ValueParsers/Normalizers/NullStringNormalizer.php b/src/ValueParsers/Normalizers/NullStringNormalizer.php index 3f14402..7fe57bb 100644 --- a/src/ValueParsers/Normalizers/NullStringNormalizer.php +++ b/src/ValueParsers/Normalizers/NullStringNormalizer.php @@ -9,7 +9,7 @@ * * @since 0.3 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Daniel Kinzler */ class NullStringNormalizer implements StringNormalizer { diff --git a/src/ValueParsers/Normalizers/StringNormalizer.php b/src/ValueParsers/Normalizers/StringNormalizer.php index 36a1755..9888a6f 100644 --- a/src/ValueParsers/Normalizers/StringNormalizer.php +++ b/src/ValueParsers/Normalizers/StringNormalizer.php @@ -9,7 +9,7 @@ * * @since 0.3 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Daniel Kinzler */ interface StringNormalizer { diff --git a/src/ValueParsers/NullParser.php b/src/ValueParsers/NullParser.php index b5d3ae9..56ce6c5 100644 --- a/src/ValueParsers/NullParser.php +++ b/src/ValueParsers/NullParser.php @@ -9,7 +9,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class NullParser implements ValueParser { diff --git a/src/ValueParsers/StringParser.php b/src/ValueParsers/StringParser.php index f7b408b..b074af7 100644 --- a/src/ValueParsers/StringParser.php +++ b/src/ValueParsers/StringParser.php @@ -11,7 +11,7 @@ * * @since 0.3 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Daniel Kinzler */ class StringParser implements ValueParser { diff --git a/src/ValueParsers/StringValueParser.php b/src/ValueParsers/StringValueParser.php index 6ea7f1d..2915177 100644 --- a/src/ValueParsers/StringValueParser.php +++ b/src/ValueParsers/StringValueParser.php @@ -13,7 +13,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ abstract class StringValueParser implements ValueParser { diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index 73c4b7e..65d87de 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -15,7 +15,7 @@ * @group DataValue * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class MonolingualTextValueTest extends TestCase { diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index f9ac1f0..cf6c578 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -16,7 +16,7 @@ * @group DataValue * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class MultilingualTextValueTest extends TestCase { diff --git a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php index e963d8e..1cd3824 100644 --- a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php +++ b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php @@ -12,7 +12,7 @@ * @group ValueFormatters * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Katie Filbert < aude.wiki@gmail.com > * @author Thiemo Kreuz */ diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index 9b664c4..57f4989 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -13,7 +13,7 @@ * @group ValueFormatters * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Katie Filbert < aude.wiki@gmail.com > */ class StringFormatterTest extends TestCase { diff --git a/tests/ValueParsers/BoolParserTest.php b/tests/ValueParsers/BoolParserTest.php index f53fce8..44eaf66 100644 --- a/tests/ValueParsers/BoolParserTest.php +++ b/tests/ValueParsers/BoolParserTest.php @@ -12,7 +12,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class BoolParserTest extends StringValueParserTest { diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php index d4e8e6c..4b21986 100644 --- a/tests/ValueParsers/DispatchingValueParserTest.php +++ b/tests/ValueParsers/DispatchingValueParserTest.php @@ -15,7 +15,7 @@ * @group DataValueExtensions * @group ValueParsers * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Thiemo Kreuz */ class DispatchingValueParserTest extends TestCase { diff --git a/tests/ValueParsers/FloatParserTest.php b/tests/ValueParsers/FloatParserTest.php index 2983aee..e5206a9 100644 --- a/tests/ValueParsers/FloatParserTest.php +++ b/tests/ValueParsers/FloatParserTest.php @@ -12,7 +12,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class FloatParserTest extends StringValueParserTest { diff --git a/tests/ValueParsers/IntParserTest.php b/tests/ValueParsers/IntParserTest.php index 46cc94d..c859ea7 100644 --- a/tests/ValueParsers/IntParserTest.php +++ b/tests/ValueParsers/IntParserTest.php @@ -12,7 +12,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class IntParserTest extends StringValueParserTest { diff --git a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php index 3462457..e988748 100644 --- a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php @@ -13,7 +13,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Thiemo Kreuz */ class NullStringNormalizerTest extends TestCase { diff --git a/tests/ValueParsers/NullParserTest.php b/tests/ValueParsers/NullParserTest.php index c17eb58..2c5afd0 100644 --- a/tests/ValueParsers/NullParserTest.php +++ b/tests/ValueParsers/NullParserTest.php @@ -12,7 +12,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class NullParserTest extends ValueParserTestBase { diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index 153a3f5..724546f 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -15,7 +15,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Daniel Kinzler */ class StringParserTest extends TestCase { diff --git a/tests/ValueParsers/StringValueParserTest.php b/tests/ValueParsers/StringValueParserTest.php index 7e05608..91c828e 100644 --- a/tests/ValueParsers/StringValueParserTest.php +++ b/tests/ValueParsers/StringValueParserTest.php @@ -11,7 +11,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ abstract class StringValueParserTest extends ValueParserTestBase { diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php index 8cfd78f..477eb1e 100644 --- a/tests/ValueParsers/ValueParserTestBase.php +++ b/tests/ValueParsers/ValueParserTestBase.php @@ -16,7 +16,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ abstract class ValueParserTestBase extends TestCase { From 046eb994204aa3d375b0df5e92782cef096257eb Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:23:08 +0000 Subject: [PATCH 41/70] Fix nullable paramater code style --- tests/ValueParsers/StringParserTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index 724546f..66c7e36 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -37,7 +37,7 @@ public function provideParse() { /** * @dataProvider provideParse */ - public function testParse( $input, StringNormalizer $normalizer = null, DataValue $expected ) { + public function testParse( $input, ?StringNormalizer $normalizer, DataValue $expected ) { $parser = new StringParser( $normalizer ); $value = $parser->parse( $input ); From 3f4c744567b53f537ee27666978a6c2b6b3fac7f Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:45:19 +0000 Subject: [PATCH 42/70] Fix line limit violations --- src/DataValues/MultilingualTextValue.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index ba3393e..44d601f 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -27,13 +27,17 @@ class MultilingualTextValue extends DataValueObject { public function __construct( array $monolingualValues ) { foreach ( $monolingualValues as $monolingualValue ) { if ( !( $monolingualValue instanceof MonolingualTextValue ) ) { - throw new IllegalValueException( 'Can only construct MultilingualTextValue from MonolingualTextValue objects' ); + throw new IllegalValueException( + 'Can only construct MultilingualTextValue from MonolingualTextValue objects' + ); } $languageCode = $monolingualValue->getLanguageCode(); if ( array_key_exists( $languageCode, $this->texts ) ) { - throw new IllegalValueException( 'Can only add a single MonolingualTextValue per language to a MultilingualTextValue' ); + throw new IllegalValueException( + 'Can only add a single MonolingualTextValue per language to a MultilingualTextValue' + ); } $this->texts[$languageCode] = $monolingualValue; From 9994130462bf7bb65490912fe8bbb9ce74e41239 Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:47:51 +0000 Subject: [PATCH 43/70] Decalre visibility on consts --- src/ValueParsers/BoolParser.php | 2 +- src/ValueParsers/FloatParser.php | 2 +- src/ValueParsers/IntParser.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ValueParsers/BoolParser.php b/src/ValueParsers/BoolParser.php index b30f926..d9321d5 100644 --- a/src/ValueParsers/BoolParser.php +++ b/src/ValueParsers/BoolParser.php @@ -14,7 +14,7 @@ */ class BoolParser extends StringValueParser { - const FORMAT_NAME = 'bool'; + private const FORMAT_NAME = 'bool'; private static $values = [ 'yes' => true, diff --git a/src/ValueParsers/FloatParser.php b/src/ValueParsers/FloatParser.php index c24999a..ae5b27a 100644 --- a/src/ValueParsers/FloatParser.php +++ b/src/ValueParsers/FloatParser.php @@ -14,7 +14,7 @@ */ class FloatParser extends StringValueParser { - const FORMAT_NAME = 'float'; + private const FORMAT_NAME = 'float'; /** * @see StringValueParser::stringParse diff --git a/src/ValueParsers/IntParser.php b/src/ValueParsers/IntParser.php index 964b02c..d69439f 100644 --- a/src/ValueParsers/IntParser.php +++ b/src/ValueParsers/IntParser.php @@ -14,7 +14,7 @@ */ class IntParser extends StringValueParser { - const FORMAT_NAME = 'int'; + private const FORMAT_NAME = 'int'; /** * @see StringValueParser::stringParse From a44c3b51fbbdb9bbdef89d081db12d30946a190e Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Thu, 15 Oct 2020 13:16:23 +0200 Subject: [PATCH 44/70] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 68bf8ab..115a8ce 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ employees for the [Wikidata project](https://wikidata.org/). * The `StringFormatter` constructor does not accept options any more * `StringParser::parse` now throws a `ParseException` instead of an `InvalidArgumentException` * Added `TrimmingStringNormalizer` +* Made `FORMAT_NAME` constants in the Parser classes private * Updated minimum required PHP version from 5.5.9 to 7.2 ### 0.4.2 (2018-08-16) From 95e498c4bb324723b310bfdeb6f8537f8766edd1 Mon Sep 17 00:00:00 2001 From: addshore Date: Mon, 18 Jan 2021 23:02:29 +0000 Subject: [PATCH 45/70] README, Re add 0.4.3 release notes These are copied from 844359d1e782884a2b79460a49624d9c08673666 which is merged. But these seemingly vanished at some point --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 115a8ce..eaf467f 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,10 @@ employees for the [Wikidata project](https://wikidata.org/). * Made `FORMAT_NAME` constants in the Parser classes private * Updated minimum required PHP version from 5.5.9 to 7.2 +### 0.4.3 (2019-06-28) + +* Fixed typo in error message in `DispatchingValueParser` + ### 0.4.2 (2018-08-16) * The component can now be installed together with DataValues 2.x From 059c3946c4b7c3e7130541bccc499df75aef8b60 Mon Sep 17 00:00:00 2001 From: addshore Date: Mon, 18 Jan 2021 23:22:02 +0000 Subject: [PATCH 46/70] Switch from Travis to Github Actions --- .github/workflows/php.yml | 64 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 23 -------------- README.md | 4 +-- 3 files changed, 65 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/php.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..547cf6c --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,64 @@ +name: PHP Composer + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: ['7.2', '7.3', '7.4'] + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Run test suite + run: composer ci + + - name: Run test suite + run: composer ci + + - name: Setup PHP for coverage + if: matrix.php-version == '7.4' + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: xdebug + + - name: Generate coverage + if: matrix.php-version == '7.4' + run: vendor/bin/phpunit --coverage-clover coverage.clover + + - name: Upload Scrutinizer coverage + if: matrix.php-version == '7.4' + uses: sudo-bot/action-scrutinizer@latest + with: + cli-args: "--format=php-clover coverage.clover" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bd64dfb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: php - -dist: trusty - -php: - - 7.2 - - 7.3 - -sudo: false - -install: travis_retry composer install - -script: composer ci - -after_success: - - if [[ "`phpenv version-name`" != "7.3" ]]; then exit 0; fi - - vendor/bin/phpunit --coverage-clover coverage.clover - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover coverage.clover - -cache: - directories: - - $HOME/.composer/cache diff --git a/README.md b/README.md index eaf467f..b706f7e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ implementations of the DataValues, ValueParsers, ValueFormatters and ValueValida It is part of the [DataValues set of libraries](https://github.com/DataValues). -[![Build Status](https://secure.travis-ci.org/DataValues/Common.png?branch=master)](http://travis-ci.org/DataValues/Common) [![Code Coverage](https://scrutinizer-ci.com/g/DataValues/Common/badges/coverage.png?s=728b9287ebdd13fbe15255d4d55575c5b5d47b8f)](https://scrutinizer-ci.com/g/DataValues/Common/) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/DataValues/Common/badges/quality-score.png?s=3195539d2e929aafaefb4bc006fb0da6c09a4d2a)](https://scrutinizer-ci.com/g/DataValues/Common/) @@ -32,7 +31,7 @@ version 0.4.2 of this package: This library comes with a set up PHPUnit tests that cover all non-trivial code. You can run these tests using the PHPUnit configuration file found in the root directory. The tests can also be run -via TravisCI, as a TravisCI configuration file is also provided in the root directory. +via Github Actions. ### Running the tests @@ -143,4 +142,3 @@ Initial release with these features: ## Links * [DataValues Common on Packagist](https://packagist.org/packages/data-values/common) -* [DataValues Common on TravisCI](https://travis-ci.org/DataValues/Common) From 9150b482a19606e14c29926b1400f7f760c27e23 Mon Sep 17 00:00:00 2001 From: addshore Date: Tue, 19 Jan 2021 09:51:15 +0000 Subject: [PATCH 47/70] Update .github/workflows/php.yml Co-authored-by: Jakob Warkotsch --- .github/workflows/php.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 547cf6c..db57ade 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -43,9 +43,6 @@ jobs: - name: Run test suite run: composer ci - - name: Run test suite - run: composer ci - - name: Setup PHP for coverage if: matrix.php-version == '7.4' uses: shivammathur/setup-php@v2 From b17562d40032a45ae61d40781334e694e72ed966 Mon Sep 17 00:00:00 2001 From: addshore Date: Tue, 19 Jan 2021 13:04:30 +0000 Subject: [PATCH 48/70] Update .github/workflows/php.yml Co-authored-by: Lucas Werkmeister --- .github/workflows/php.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index db57ade..aef5ac6 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -2,9 +2,7 @@ name: PHP Composer on: push: - branches: [ master ] pull_request: - branches: [ master ] jobs: build: From 6d3f05d03fc4a5352aa53f8236f8e3e75ede6728 Mon Sep 17 00:00:00 2001 From: addshore Date: Tue, 19 Jan 2021 13:04:40 +0000 Subject: [PATCH 49/70] Update .github/workflows/php.yml Co-authored-by: Lucas Werkmeister --- .github/workflows/php.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index aef5ac6..05d48d5 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -12,7 +12,10 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['7.2', '7.3', '7.4'] + php-version: + - '7.2', + - '7.3' + - '7.4' steps: - uses: actions/checkout@v2 From 3aa96662d5e68f4d5bc0e78e489739c5e711f142 Mon Sep 17 00:00:00 2001 From: addshore Date: Tue, 19 Jan 2021 14:02:03 +0000 Subject: [PATCH 50/70] rename composer validate step --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 05d48d5..eec9622 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -25,7 +25,7 @@ jobs: with: php-version: ${{ matrix.php-version }} - - name: Validate composer.json and composer.lock + - name: Composer validate run: composer validate - name: Cache Composer packages From 494f7740b204bceb5a52cb9c41e5344d5d60615a Mon Sep 17 00:00:00 2001 From: addshore Date: Tue, 19 Jan 2021 14:04:11 +0000 Subject: [PATCH 51/70] Alter composer caching --- .github/workflows/php.yml | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index eec9622..c68fb66 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -12,8 +12,8 @@ jobs: strategy: fail-fast: false matrix: - php-version: - - '7.2', + php: + - '7.2' - '7.3' - '7.4' @@ -23,40 +23,35 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: ${{ matrix.php }} - name: Composer validate run: composer validate - - name: Cache Composer packages - id: composer-cache + - name: Cache Composer cache uses: actions/cache@v2 with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- - - - name: Install dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' - run: composer install --prefer-dist --no-progress --no-suggest + path: ~/.composer/cache + key: composer-cache-php${{ matrix.php }} + - name: Composer install + run: composer install --no-progress --no-suggest --no-interaction --prefer-dist --optimize-autoloader - name: Run test suite run: composer ci - name: Setup PHP for coverage - if: matrix.php-version == '7.4' + if: matrix.php == '7.4' uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: ${{ matrix.php }} coverage: xdebug - name: Generate coverage - if: matrix.php-version == '7.4' + if: matrix.php == '7.4' run: vendor/bin/phpunit --coverage-clover coverage.clover - name: Upload Scrutinizer coverage - if: matrix.php-version == '7.4' + if: matrix.php == '7.4' uses: sudo-bot/action-scrutinizer@latest with: cli-args: "--format=php-clover coverage.clover" From 71f5783202e7549ae0da82272fbfdad5b7fddc40 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 22 Jan 2021 15:27:07 +0100 Subject: [PATCH 52/70] Update release notes for 1.0.0 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b706f7e..44d7be6 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ The recommended way to use this library is via [Composer](http://getcomposer.org To add this package as a local, per-project dependency to your project, simply add a dependency on `data-values/common` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on -version 0.4.2 of this package: +version 1.x of this package: { "require": { - "data-values/common": "^0.4.2" + "data-values/common": "^1.0.0" } } @@ -54,8 +54,9 @@ employees for the [Wikidata project](https://wikidata.org/). ## Release notes -### 1.0.0 (dev) +### 1.0.0 (2021-01-22) +* Updated minimum required PHP version from 5.5.9 to 7.2 * Removed the `DATAVALUES_COMMON_VERSION` constant * Deprecated `getSortKey` methods from `DataValue` implementations * Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` @@ -63,7 +64,6 @@ employees for the [Wikidata project](https://wikidata.org/). * `StringParser::parse` now throws a `ParseException` instead of an `InvalidArgumentException` * Added `TrimmingStringNormalizer` * Made `FORMAT_NAME` constants in the Parser classes private -* Updated minimum required PHP version from 5.5.9 to 7.2 ### 0.4.3 (2019-06-28) From 9726088771c2107f605f18f659e455c27ef2e65b Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 22 Jan 2021 15:29:14 +0100 Subject: [PATCH 53/70] Add strict_types --- .gitignore | 4 +++- src/DataValues/MonolingualTextValue.php | 2 ++ src/DataValues/MultilingualTextValue.php | 2 ++ .../Exceptions/MismatchingDataValueTypeException.php | 2 ++ src/ValueFormatters/StringFormatter.php | 2 ++ src/ValueParsers/BoolParser.php | 2 ++ src/ValueParsers/DispatchingValueParser.php | 2 ++ src/ValueParsers/FloatParser.php | 2 ++ src/ValueParsers/IntParser.php | 2 ++ src/ValueParsers/Normalizers/NullStringNormalizer.php | 2 ++ src/ValueParsers/Normalizers/StringNormalizer.php | 2 ++ src/ValueParsers/Normalizers/TrimmingStringNormalizer.php | 2 ++ src/ValueParsers/NullParser.php | 2 ++ src/ValueParsers/StringParser.php | 2 ++ src/ValueParsers/StringValueParser.php | 2 ++ tests/DataValues/MonolingualTextValueTest.php | 2 ++ tests/DataValues/MultilingualTextValueTest.php | 2 ++ .../Exceptions/MismatchingDataValueTypeExceptionTest.php | 2 ++ tests/ValueFormatters/StringFormatterTest.php | 2 ++ tests/ValueParsers/BoolParserTest.php | 2 ++ tests/ValueParsers/DispatchingValueParserTest.php | 2 ++ tests/ValueParsers/FloatParserTest.php | 2 ++ tests/ValueParsers/IntParserTest.php | 2 ++ tests/ValueParsers/Normalizers/NullStringNormalizerTest.php | 2 ++ .../ValueParsers/Normalizers/TrimmingStringNormalizerTest.php | 2 ++ tests/ValueParsers/NullParserTest.php | 2 ++ tests/ValueParsers/StringParserTest.php | 2 ++ tests/ValueParsers/StringValueParserTest.php | 2 ++ tests/ValueParsers/ValueParserTestBase.php | 2 ++ tests/bootstrap.php | 4 +++- 30 files changed, 62 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 577795c..da794e8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ build/ vendor/ composer.phar -composer.lock \ No newline at end of file +composer.lock + +.phpunit.result.cache diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index e65d408..4a969a2 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -1,5 +1,7 @@ Date: Fri, 22 Jan 2021 15:31:14 +0100 Subject: [PATCH 54/70] Use MW CS instead of WB CS --- composer.json | 4 ++-- phpcs.xml | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index e543513..45ceb34 100644 --- a/composer.json +++ b/composer.json @@ -28,9 +28,9 @@ "data-values/interfaces": "~1.0|~0.2.0" }, "require-dev": { - "ockcyp/covers-validator": "~1.2", "phpunit/phpunit": "~8.0", - "wikibase/wikibase-codesniffer": "^1.2.0" + "ockcyp/covers-validator": "^1.3.3", + "mediawiki/mediawiki-codesniffer": "^34" }, "extra": { "branch-alias": { diff --git a/phpcs.xml b/phpcs.xml index ac20681..8649f80 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,12 +1,10 @@ - + src/ + tests/ - - - + + - - . From 8e2435f130e6d11c04ee940eb6f390f6f2b73c1a Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 22 Jan 2021 15:33:57 +0100 Subject: [PATCH 55/70] Use consistent PSR-4 autoloading for tests --- composer.json | 8 +++++--- tests/ValueFormatters/StringFormatterTest.php | 2 +- tests/ValueParsers/BoolParserTest.php | 2 +- tests/ValueParsers/DispatchingValueParserTest.php | 2 +- tests/ValueParsers/FloatParserTest.php | 2 +- tests/ValueParsers/IntParserTest.php | 2 +- .../ValueParsers/Normalizers/NullStringNormalizerTest.php | 2 +- .../Normalizers/TrimmingStringNormalizerTest.php | 2 +- tests/ValueParsers/NullParserTest.php | 2 +- tests/ValueParsers/StringParserTest.php | 2 +- tests/ValueParsers/StringValueParserTest.php | 2 +- tests/ValueParsers/ValueParserTestBase.php | 2 +- 12 files changed, 16 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 45ceb34..e7f7d6c 100644 --- a/composer.json +++ b/composer.json @@ -45,9 +45,11 @@ } }, "autoload-dev": { - "classmap": [ - "tests/ValueParsers" - ] + "psr-4": { + "DataValues\\Tests\\": "tests/DataValues/", + "ValueFormatters\\Tests\\": "tests/ValueFormatters/", + "ValueParsers\\Tests\\": "tests/ValueParsers/" + } }, "scripts": { "fix": [ diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index cfa9d61..5af2df0 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueFormatters\Test; +namespace ValueFormatters\Tests; use DataValues\StringValue; use InvalidArgumentException; diff --git a/tests/ValueParsers/BoolParserTest.php b/tests/ValueParsers/BoolParserTest.php index 85db4b5..2c2bfc5 100644 --- a/tests/ValueParsers/BoolParserTest.php +++ b/tests/ValueParsers/BoolParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use DataValues\BooleanValue; use ValueParsers\BoolParser; diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php index 7f1937d..0a547a7 100644 --- a/tests/ValueParsers/DispatchingValueParserTest.php +++ b/tests/ValueParsers/DispatchingValueParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use InvalidArgumentException; use PHPUnit\Framework\TestCase; diff --git a/tests/ValueParsers/FloatParserTest.php b/tests/ValueParsers/FloatParserTest.php index a4e2667..c931ed2 100644 --- a/tests/ValueParsers/FloatParserTest.php +++ b/tests/ValueParsers/FloatParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use DataValues\NumberValue; use ValueParsers\FloatParser; diff --git a/tests/ValueParsers/IntParserTest.php b/tests/ValueParsers/IntParserTest.php index 2f8c0ed..05b442b 100644 --- a/tests/ValueParsers/IntParserTest.php +++ b/tests/ValueParsers/IntParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use DataValues\NumberValue; use ValueParsers\IntParser; diff --git a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php index 9ceb6ef..b568bfa 100644 --- a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Normalizers\Test; +namespace ValueParsers\Tests\Normalizers; use DataValues\StringValue; use InvalidArgumentException; diff --git a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php index 3deb2db..23e267c 100644 --- a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Normalizers\Test; +namespace ValueParsers\Tests\Normalizers; use DataValues\StringValue; use InvalidArgumentException; diff --git a/tests/ValueParsers/NullParserTest.php b/tests/ValueParsers/NullParserTest.php index 3028bfa..68a2af5 100644 --- a/tests/ValueParsers/NullParserTest.php +++ b/tests/ValueParsers/NullParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use DataValues\UnknownValue; use ValueParsers\NullParser; diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index ffd84f3..410f2d4 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use DataValues\DataValue; use DataValues\StringValue; diff --git a/tests/ValueParsers/StringValueParserTest.php b/tests/ValueParsers/StringValueParserTest.php index 76d4d55..b312f4e 100644 --- a/tests/ValueParsers/StringValueParserTest.php +++ b/tests/ValueParsers/StringValueParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use ValueParsers\ParserOptions; use ValueParsers\StringValueParser; diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php index 42fee08..6e57c32 100644 --- a/tests/ValueParsers/ValueParserTestBase.php +++ b/tests/ValueParsers/ValueParserTestBase.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use Comparable; use DataValues\DataValue; From 315bd95ef8e5c360ce8a1cf02c0eef35bbb92561 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 22 Jan 2021 15:36:48 +0100 Subject: [PATCH 56/70] Add added compat to release notes --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 44d7be6..991a1e9 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ employees for the [Wikidata project](https://wikidata.org/). ### 1.0.0 (2021-01-22) * Updated minimum required PHP version from 5.5.9 to 7.2 +* Added compatibility with `data-values/data-values` 3.x +* Added compatibility with `data-values/interfaces` 1.x * Removed the `DATAVALUES_COMMON_VERSION` constant * Deprecated `getSortKey` methods from `DataValue` implementations * Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` From 85e4c1f927c826490cfdd1388eaa9b8ab6a37c7a Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Mon, 12 Apr 2021 22:54:18 +0100 Subject: [PATCH 57/70] .gitattributes: Add .github to export-ignore --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 3f150e3..a0593aa 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,6 @@ .editorconfig export-ignore .gitattributes export-ignore +.github/ export-ignore .gitignore export-ignore .scrutinizer.yml export-ignore .travis.yml export-ignore From 1dfcc7155728376ce90f5f4306e9ef904c0bd3b8 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 14 Oct 2022 14:39:05 +0200 Subject: [PATCH 58/70] Bump actions/checkout fetch-depth to 2 The default of 1 (only HEAD, no parents) is not enough for Scrutinizer, it seems. Problem witnessed in #96. --- .github/workflows/php.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index c68fb66..3b16ee3 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -19,6 +19,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 2 - name: Setup PHP uses: shivammathur/setup-php@v2 From 6334c72cf17837732858bbe67cb9ecc1e657fca4 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 14 Oct 2022 13:08:25 +0200 Subject: [PATCH 59/70] Implement _serialize()/__unserialize() Bug: T301249 --- src/DataValues/MonolingualTextValue.php | 12 ++++++++++-- src/DataValues/MultilingualTextValue.php | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index 4a969a2..03eb876 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -48,7 +48,11 @@ public function __construct( $languageCode, $text ) { * @return string */ public function serialize() { - return serialize( [ $this->languageCode, $this->text ] ); + return serialize( $this->__serialize() ); + } + + public function __serialize(): array { + return [ $this->languageCode, $this->text ]; } /** @@ -57,7 +61,11 @@ public function serialize() { * @param string $value */ public function unserialize( $value ) { - list( $languageCode, $text ) = unserialize( $value ); + $this->__unserialize( unserialize( $value ) ); + } + + public function __unserialize( array $data ): void { + list( $languageCode, $text ) = $data; $this->__construct( $languageCode, $text ); } diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index 5492f1e..32165cf 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -52,7 +52,11 @@ public function __construct( array $monolingualValues ) { * @return string */ public function serialize() { - return serialize( $this->texts ); + return serialize( $this->__serialize() ); + } + + public function __serialize(): array { + return $this->texts; } /** @@ -61,7 +65,11 @@ public function serialize() { * @param string $value */ public function unserialize( $value ) { - $this->__construct( unserialize( $value ) ); + $this->__unserialize( unserialize( $value ) ); + } + + public function __unserialize( array $data ): void { + $this->__construct( $data ); } /** From 3d43c4344dcd6d72ebdfd2a02d4c466b77e31c39 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 21 Oct 2022 12:51:01 +0200 Subject: [PATCH 60/70] Release 1.1.0 --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 991a1e9..41723d8 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ version 1.x of this package: { "require": { - "data-values/common": "^1.0.0" + "data-values/common": "^1.1.0" } } @@ -54,6 +54,13 @@ employees for the [Wikidata project](https://wikidata.org/). ## Release notes +### 1.1.0 (2022-10-21) + +* Improved compatibility with PHP 8.1; + in particular, the new `__serialize`/`__unserialize` methods are implemented now + (in addition to the still supported `Serializable` interface). + Make sure to also use `data-values/data-values` version 3.1.0 (or later) to keep hashes stable. + ### 1.0.0 (2021-01-22) * Updated minimum required PHP version from 5.5.9 to 7.2 From 16ebf7de2011a42f6b72f92439faaac432b3ee1d Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 21 Oct 2022 16:10:07 +0200 Subject: [PATCH 61/70] Update build badges --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 41723d8..c494d07 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ implementations of the DataValues, ValueParsers, ValueFormatters and ValueValida It is part of the [DataValues set of libraries](https://github.com/DataValues). +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/DataValues/Common/PHP%20Composer)](https://github.com/DataValues/Common/actions?query=workflow%3APHP%20Composer) [![Code Coverage](https://scrutinizer-ci.com/g/DataValues/Common/badges/coverage.png?s=728b9287ebdd13fbe15255d4d55575c5b5d47b8f)](https://scrutinizer-ci.com/g/DataValues/Common/) -[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/DataValues/Common/badges/quality-score.png?s=3195539d2e929aafaefb4bc006fb0da6c09a4d2a)](https://scrutinizer-ci.com/g/DataValues/Common/) On [Packagist](https://packagist.org/packages/data-values/common): [![Latest Stable Version](https://poser.pugx.org/data-values/common/version.png)](https://packagist.org/packages/data-values/common) From 9f5e6216ec66ac8f2281351b110bad0eded43e65 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 21 Oct 2022 16:13:11 +0200 Subject: [PATCH 62/70] Fix CI badge URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c494d07..de4bb6d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ implementations of the DataValues, ValueParsers, ValueFormatters and ValueValida It is part of the [DataValues set of libraries](https://github.com/DataValues). -[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/DataValues/Common/PHP%20Composer)](https://github.com/DataValues/Common/actions?query=workflow%3APHP%20Composer) +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/DataValues/Common/PHP%20Composer)](https://github.com/DataValues/Common/actions?query=workflow%3A"PHP+Composer") [![Code Coverage](https://scrutinizer-ci.com/g/DataValues/Common/badges/coverage.png?s=728b9287ebdd13fbe15255d4d55575c5b5d47b8f)](https://scrutinizer-ci.com/g/DataValues/Common/) On [Packagist](https://packagist.org/packages/data-values/common): From 2243b64f0148251bcd36421258405fb7ccce21a2 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 10 Nov 2022 10:52:12 +1100 Subject: [PATCH 63/70] Add tests/ to export-ignore To reduce the composer package size. --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index a0593aa..cdba42e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,3 +7,4 @@ composer.json export-ignore phpcs.xml export-ignore phpunit.xml.dist export-ignore +tests/ export-ignore From 06415a03d13e35ea471630ec6fa0f1f44cd45053 Mon Sep 17 00:00:00 2001 From: Arthur Taylor Date: Fri, 6 Dec 2024 14:07:02 +0100 Subject: [PATCH 64/70] 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 #100 Bug: T379481 --- .github/workflows/php.yml | 2 -- composer.json | 9 +++++++-- phpcs.xml | 1 + src/DataValues/MonolingualTextValue.php | 2 +- .../Exceptions/MismatchingDataValueTypeException.php | 2 +- src/ValueParsers/BoolParser.php | 4 ++++ src/ValueParsers/StringParser.php | 2 +- src/ValueParsers/StringValueParser.php | 2 +- tests/ValueParsers/DispatchingValueParserTest.php | 6 +++--- tests/ValueParsers/NullParserTest.php | 2 +- tests/ValueParsers/StringParserTest.php | 4 ++-- tests/ValueParsers/ValueParserTestBase.php | 4 ++-- 12 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 3b16ee3..641f7c7 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -13,8 +13,6 @@ jobs: fail-fast: false matrix: php: - - '7.2' - - '7.3' - '7.4' steps: diff --git a/composer.json b/composer.json index e7f7d6c..6e51d8f 100644 --- a/composer.json +++ b/composer.json @@ -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": { @@ -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(); } From b3114dcc9da1bc37cc6b0cd66137f951d17c0ee7 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 6 Dec 2024 17:11:44 +0100 Subject: [PATCH 65/70] Test with modern PHP --- .github/workflows/php.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 641f7c7..41cef68 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -14,6 +14,11 @@ jobs: matrix: php: - '7.4' + - '8.0' + - '8.1' + - '8.2' + - '8.3' + - '8.4' steps: - uses: actions/checkout@v2 From 9799074609af63d76b29f582d8f34e6f24b51bf1 Mon Sep 17 00:00:00 2001 From: Arthur Taylor Date: Mon, 9 Dec 2024 11:18:27 +0100 Subject: [PATCH 66/70] Bump version to 1.2.0 * Drop support for PHP 7.2, 7.3 * Upgrade codesniffer rules to current `mediawiki/mediawiki-codesniffer` version (45.0.0) * Make nullable type parameter declarations explicit for compatibility with PHP 8.4 * Start testing with modern versions of PHP (8.1-8.4) --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index de4bb6d..dc2ce75 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,13 @@ employees for the [Wikidata project](https://wikidata.org/). ## Release notes +### 1.2.0 (2024-12-10) + +* Drop support for PHP 7.2, 7.3 +* Upgrade codesniffer rules to current `mediawiki/mediawiki-codesniffer` version (45.0.0) +* Make nullable type parameter declarations explicit for compatibility with PHP 8.4 +* Start testing with modern versions of PHP (8.1-8.4) + ### 1.1.0 (2022-10-21) * Improved compatibility with PHP 8.1; From b21c2bd3b213d6233a645003df4f88956afc52f4 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Mon, 9 Dec 2024 23:42:56 +0100 Subject: [PATCH 67/70] Improve release notes --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dc2ce75..0e9172e 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,10 @@ employees for the [Wikidata project](https://wikidata.org/). ### 1.2.0 (2024-12-10) -* Drop support for PHP 7.2, 7.3 -* Upgrade codesniffer rules to current `mediawiki/mediawiki-codesniffer` version (45.0.0) -* Make nullable type parameter declarations explicit for compatibility with PHP 8.4 -* Start testing with modern versions of PHP (8.1-8.4) +* Dropped support for PHP 7.2 and PHP 7.3 +* Improved support for PHP 8.4 by explicitly declaring nullable types +* Upgraded codesniffer rules to current `mediawiki/mediawiki-codesniffer` version (45.0.0) +* Added testing with PHP 8.1 up to 8.4 ### 1.1.0 (2022-10-21) From 7a1c1037729462cd536eaed1236eb31cff4c5820 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Tue, 10 Dec 2024 00:16:25 +0100 Subject: [PATCH 68/70] Fix badges --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0e9172e..f0d5acd 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ # DataValues Common -DataValues Common is a small library build on top of DataValues that provides common -implementations of the DataValues, ValueParsers, ValueFormatters and ValueValidators interfaces. +DataValues Common is a small library built on top of DataValues that provides common +implementations of the DataValues, ValueParsers, ValueFormatters, and ValueValidators interfaces. It is part of the [DataValues set of libraries](https://github.com/DataValues). -[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/DataValues/Common/PHP%20Composer)](https://github.com/DataValues/Common/actions?query=workflow%3A"PHP+Composer") -[![Code Coverage](https://scrutinizer-ci.com/g/DataValues/Common/badges/coverage.png?s=728b9287ebdd13fbe15255d4d55575c5b5d47b8f)](https://scrutinizer-ci.com/g/DataValues/Common/) +[![Build Status](https://img.shields.io/github/actions/workflow/status/DataValues/Common/php.yml?branch=master)](https://github.com/DataValues/Common/actions/workflows/php.yml?query=workflow%3APHP) +[![Code Coverage](https://scrutinizer-ci.com/g/DataValues/Common/badges/coverage.png?s=6432d29bf3fed068995e66093ad52e053099a916)](https://scrutinizer-ci.com/g/DataValues/Common/) On [Packagist](https://packagist.org/packages/data-values/common): -[![Latest Stable Version](https://poser.pugx.org/data-values/common/version.png)](https://packagist.org/packages/data-values/common) -[![Download count](https://poser.pugx.org/data-values/common/d/total.png)](https://packagist.org/packages/data-values/common) +[![Latest Stable Version](https://poser.pugx.org/data-values/common/v/stable)](https://packagist.org/packages/data-values/common) +[![Download count](https://poser.pugx.org/data-values/common/downloads)](https://packagist.org/packages/data-values/common) ## Installation From c586bd6e6c7e6488f7d8332c70d1ad0c497975a9 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 12 Dec 2024 16:41:53 +0000 Subject: [PATCH 69/70] php.yml: Update to actions/cache@v4 --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 41cef68..70485e9 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -34,7 +34,7 @@ jobs: run: composer validate - name: Cache Composer cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.composer/cache key: composer-cache-php${{ matrix.php }} From 043f5e0ab9c034ee2a91366ea55d404d57df0549 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 8 Jan 2026 01:21:36 +0000 Subject: [PATCH 70/70] php.yml: Test on PHP 8.5 --- .github/workflows/php.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 70485e9..de76a8d 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -19,6 +19,7 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' steps: - uses: actions/checkout@v2